I have two tables:
- Users:
id, first_name, last_name, email
- Employees
id, user_id, wage
There has a relationship between users
and employees
. The problem comes from when I have a scope
inside the model:
public function scopeSearchPaginateAndOrder($query) {
$request = app()->make('request');
return $query->whereHas('user.internal_companies', function ($company) {
$company->where('companies.id', '=', \Session::get('current_company')['id']);
})->where(function ($query) use ($request) {
})->select(['user.first_name'])->get();
}
I am getting the following error:
Unknown column 'user.first_name' in 'field list
However, the relationship does exist:
public function user() {
return $this->belongsTo('App\User', 'user_id');
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rzXdnz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire