get data through belongsToMany relation between two table
Users Model :`
public function favorites(){
return $this->belongsToMany('App\job','favourites',
'user_id','job_id')
->withTimestamps();
}`
job Model :`
public function favorites(){
return $this->belongsToMany(job::class,'favourites',
'job_id','user_id')
->withTimestamps();
}`
Controller :`
public function index() {
$jobs = Auth::user()->favorites;
return view('home',compact('jobs'));
}`
nothing appears any errors and any data
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire