I want to load that users that have a company_id
= 28
. I put where clause but its not working, collection returning all records.
MyController.php
public function index($type, $company_id = '')
{
$user = User::whereHas('roles', function ($query) use ($type) {
$query->where('name', '=', $type);
})->get();
$users = $user->load(['userSetting' => function ($query) {
$query->where('company_id', '28');
}]);
return response()->json($users);
}
User.php
public function userSetting()
{
return $this->hasOne('App\UserSettings', 'user_id');
}
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2ICozRa
via IFTTT
Aucun commentaire:
Enregistrer un commentaire