i am new in laravel, i tried code for array
$videos = ResourcesVideo::where('resource_type', 'video')->take(2)->get();
$music = ResourcesVideo::where('resource_type', 'music')->take(2)->get();
$mediation = ResourcesVideo::where('resource_type', 'mediation')->take(2)->get();
$tedtalk = TedTalk::take(2)->get();
$response['data'] = [
"ted_talks" => $tedtalk,
"video" => $videos,
"music" => $music,
"mediation" => $mediation,
];
i got right data like
{
"data": {
"ted_talks": [
],
"videos": [
],
"music": [
],
.
.
.
}
}
i have question for how can i reduce that repeated code. please check my code it shown same logic repeated 3 times.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire