lundi 5 août 2019

Laravel Fetch data from two tables with WhereIn condition

I have two tables joined with junction table want to return Data

$roles = Role::all()->pluck('title', 'id');
$user_fields = DB::table('user_fields')
->Join('role_user_field', 'user_fields.id', '=', 'role_user_field.user_field_id')
->whereIn('role_user_field.role_id', $roles)

I need rows from "user_fields" based on role_id.but it gives

object(Illuminate\Support\Collection)#783 (1) { ["items":protected]=> array(0){}}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire