jeudi 30 novembre 2017

Attain many has-many-through

I need to attain latest comments from array of users through posts.

Users model

public function comments()
 {
   return $this->hasManyThrough('App\Comment', 'App\Post');
 }

has-many-through

$user = users::where('id',5)->first();

$user->comments()->get()

many has-many-through

$user = users::where('role','member')->get();

How can I achieve this.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BoWeHJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire