i want to show the name of the category in post table but this give me error here my code check this
this is the modal
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Post extends Model
{
protected $fillable=['seotitle', 'h1title', 'image' , 'alt', 'url' , 'meta','author','status','keywords', 'tags', 'category_id', 'text','read', 'view'];
public function Category(){
return $this->belongsTo(Category::class);
}
}
i also use the fillable for 'name' in category modal
post controller
namespace App\Http\Controllers;
use DB;
use App\Post;
use App\categoriesegory;
use Illuminate\Http\Request;
use App\Http\Requests\Posts\CreatePostsRequest;
use App\Http\Requests\Posts\UpdatePostRequest;
use Illuminate\Support\Facades\Storage;
public function index()
{
// $select=DB::select("SELECT * From posts where status='publish'");
return view('/admin/posts/index')->with('posts' , Post::all());
}
blade file
<td>{{$post->Category->name}}</td>
Category= this is modal function name in relationship
how can i solve this issue ?
i want to show the name of category in the post table but getting error can you show me what the issue laravel 5.8
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire