lundi 30 mai 2016

How to use join in Laravel Elocuent?

I have following two tables.

users - id,name,title
posts - id,author

where post.author = user.id

My Post model as follows.

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    public function users()
    {
       return $this->belongsTo('App\User');
    }
}

I use Project::find(1)->users

But it giving following error.

SQLSTATE[42S02]: Base table or view not found.

Can anyone please help ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire