mercredi 24 juillet 2019

how to search from specifc data in laravel?

let's say i have this table in database...

enter image description here

So i want to search from specific data, for example

  • i want to search from all schedules where station_id is equal 1

so I did it like this...

$schedule = DB::table('schedules')
                ->where('station_id', 1)
                ->where('schedule_number', 'like', '%'.$query.'%')
                ->orWhere('route_name', 'like', '%'.$query.'%')
                ->orWhere('user_first', 'like', '%'.$query.'%')
                ->orWhere('id', 'like', '%'.$query.'%')
                ->orWhere('created_at', 'like', '%'.$query.'%')
                ->get();

But this will search from all schedules



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire