added a relationship between User, and Posts
This commit is contained in:
parent
dff18be098
commit
3deef3707e
@ -15,4 +15,13 @@ class Post extends Model
|
||||
"image",
|
||||
"user_id"
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class)->select([
|
||||
"id",
|
||||
"name",
|
||||
"username"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -45,4 +45,9 @@ class User extends Authenticatable
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function posts()
|
||||
{
|
||||
return $this->hasMany(Post::class);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user