what i am trying to do is getting my tvserious and movies from categories class
this is my categories class :
class Category extends Model
{
public function movies()
{
return $this->hasMany(Movie::class);
}
public function tvserious()
{
return $this->hasMany(Tvserious::class);
}
what i tried and it's working
public function CategoryClick($slug){
$media = Category::where('slugid',$slug)->with(['movies' => function($query) {
$query->whereNotNull('title');
},'tvserious' => function($query) {
$query->whereNotNull('title');
}])->inRandomOrder()->paginate(8);
return view('test')->with([
'catclick'=>$media,
'title'=>$slug,
]);
}
the problem with this way is in my blade i have to create a loop for movies and tvserious and the tvserious data will always stay at the end at it will show after the movies loop ends
@foreach($catclick as $media)
@foreach($media->movies as $movie )
@endforeach
@foreach($media->tvserious as $tvserious )
@endforeach
@endforeach
so how can i get both of my movies and serious in my blade mixed together
i don't want all the movies to be at first so where is the problem and how can i fix this ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire