lundi 17 octobre 2016

laravel Auth::user()->with return all not just authenticated user

wrong: this return all Users with their persons:

$me = Auth::user()->with('persons')->get();

correct: this return just the authenticated user with his persons

Auth::user()->persons()->get()

Model

 public function persons(){
        return $this->hasMany('App\Person', 'user_id');
    }

where is the difference? why first line returns ALL users?

thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire