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
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2orTYhz
via IFTTT
Aucun commentaire:
Enregistrer un commentaire