samedi 1 août 2020

how to display video per category in laravel eloquent

model video

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);
}

model category

protected $table = 'lokit_category';
    protected $fillable = ['name'];

in controller

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'));
    }

when I try the code above what happens with the code is null, how to fix it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire