Good friends, the question is simple, I need to do a search engine in laravel but the way I'm doing it, complicates me a bit because I'm doing the following:
currently in the controller I have this:
public function index(Request $request)
{
$events = Event::Events();
return view('event.index', compact('events'));
}
Which I send to the index and lists the categories with the method:
public static function Events(){
return DB::table('events')
->join('categories', 'categories.id', '=', 'events.category_id')
->select('events.*', 'categories.name_cat')
->get();
}
The question is that I am trying to do with a scope the search engine but the problem is that I have the method I need to list the categories, since it has the query and I do not know how to use the scope and also the Events method, as I think doing it is something like this:
public function index(Request $request)
{
$events = Event::name($request->get('name_eve'))->orderBy('id','DESC')->paginate(2);
return view('event.index', compact('events'));
}
Which works for me, but the problem is that it does not show me the category in the index because I need to use the Events method.