samedi 3 octobre 2015

Laravel Eloquent retrive data from multiple tables

I have four tables

**Articles table**

 id
 title
 body
 owner_id
 category_id

**Favorite articles table**

  id
  user_id
  article_id

**User table**

 id
 user_name
 user_type

**Category table**

 id
 category_name

How to get list of favorite articles (article_name,owner_name,category_name) which related to currently logged user from db using laravel eloquent?

Is it possible to do it in single line request? e.g.:

$articles_data=Auth::user()->favorite_articles->article...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire