laravel relation many code example
Example: laravel relation has many
// Post model
public function comments()
{
return $this->hasMany(Comment::class);
}
// Post controller
$comments = Post::find(1)->comments;
// Post model
public function comments()
{
return $this->hasMany(Comment::class);
}
// Post controller
$comments = Post::find(1)->comments;