dimanche 6 novembre 2016

Laravel 5.3 Call to a member function getRelationQuery() on null

class User extends Authenticatable
{
public function applications()
{
    $this->belongsToMany('Application');
}
}

class Application extends Model
{
 public function user()
{
    $this->belongsTo('SwapSome\User');
}
}

If i write:

$applications=Application::whereHas('user',function($q) use ($company_id)
    {
        $q->where('company_id',$company_id);
    })->get();

I get the error: Call to a member function getRelationQuery() on null

But Application::where('company_id',$company_id)->get(); returns the applications. What am I missing?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire