lundi 5 mars 2018

Laravel whereHas on multiple rows

$search = Workforce::whereHas('task_schedule', function($q) use($request){
        if($request->search_schedule_day != null){
            foreach($request->search_schedule_day as $day){
                /*$q->whereIn('schedule_day', 'like', '%'. $day .'%');*/
                var_dump($day);
            }
        }
        if($request->search_time_in != null){
            $q->where('schedule_time_in', 'like', '%' . $request->search_time_in . '%');
        }
        if($request->search_time_out != null){
            $q->where('schedule_time_out', 'like', '%' . $request->search_time_out . '%');
        }
    })

I am currently making an advanced search feature, and I have encountered this problem wherein I have an array of search_schedule[] . Then in the database, it is saved one day per row. How do I set a query for searching the days in that array ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FvlMs6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire