【发布时间】:2020-11-22 04:59:03
【问题描述】:
模特视频
protected $table = 'lokit_video';
protected $fillable =
[
'title',
'cover_img',
'trailer',
'url',
'order_',
'active',
'description',
'lokit_category_id',
'duration'
];
public function lokit_category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
型号类别
protected $table = 'lokit_category';
protected $fillable = ['name'];
在控制器中
public function index(){
$dataCategory = Category::all();
$dataVideo = Video::all();
$video = Video::where('lokit_category_id', $dataCategory)->get();
dd($video);
return View('bnpt.content.home',compact('dataCategory','dataVideo'));
}
当我尝试上面的代码时,代码为空,如何解决?
【问题讨论】:
-
您想显示某个类别的所有视频?
-
是的,就像那样,但是我写代码很困惑
-
You want to display all the videos for a certain category?你同意了。所以你想获取哪个分类的视频,请注明分类 -
我想显示某个 lokit_category_id 的视频
标签: php mysql laravel laravel-5 eloquent