Hi, I made an api that will take my pages from the database according to its name, but any year parameter I would give it, it will take according to its name and the year will ignore it
Do you know what this problem is about?
public function viewPageByYear(Request $request, $slug, $year)
{
$data = DB::table('pages')->where('meta_title', '=', $slug)
->orWhere('meta_title_en', '=', $slug)->where('year', '=', $year)->get();
$media = DB::table('files')->where('model_id', '=', $data->id)
->where('model_type', '=', 'App\Pages')->first();
return response()->json([$data, $media]);
}
//api.php
Route::get('/pages/{slug}/{year}', [AjaxController::class, 'viewPageByYear']);
So this is the function, the year is always ignored and is taken only according to the meta_title
api/pages/something/2021 - show
api/pages/something/2022 - show ( but this don`t exist in database)