When I try to get all the records that have a relation to the category table, where the category_definition_id is the search input, I cannot access the $request->category variable in the sub method. It is in Laravel 5.5. Any ideas?
public function jobopenings(Request $request)
{
$category_definitions = Category_definition::all();
$skill_definitions = Skill_definition::all();
$ads = new Ad;
// Search for a user based on their name.
if ($request->has('category')) {
$ads = $ads->whereHas('categories', function($query){
$query->where('category_definition_id', $request->category);
});
}
$ads = $ads->where('type','1')->orderBy('created_at','desc')->paginate(15);
return View::make('jobs')
->with('ads', $ads)
->with('category_definitions',$category_definitions)
->with('skill_definitions', $skill_definitions)
->with('ad_type','1');
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Av3bdv
via IFTTT
Aucun commentaire:
Enregistrer un commentaire