mardi 29 septembre 2015

How to get username from articles in Laravel 5?

Let's say each article is related with a user by holding a user_id value that is a foreign key to the id field in the users table.

And we defined the user method inside Article model with $this->belongsTo('App\User'), and the article method inside User model with $this->hasMany('App\Article').

What is the proper way to get the articles along with the username of the creator, in order to use them in the view?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire