vendredi 15 juin 2018

Laravel query builder serialization

I have below Models and I need to get an array of district_id without field name. (like, [1, 2, 3, 4])

Province [id, description]

District [id, description, province_id]

$province_arr = DB::table('provinces')->pluck('id')->toArray();

$district_arr = DB::table('districts')->pluck('id')
     ->whereIn('province_id', $province_arr)->toArray();

But $district_arr is always empty. (i.e. dd($district_arr) always give [])

Database contains data to match the query. Can someone help me figure out why doesn't this work?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire