Answers for "laravel relation has many"

PHP
0

laravel relation has many

// Post model 
public function comments()
{
  return $this->hasMany(Comment::class);
}

// Post controller
$comments = Post::find(1)->comments;
Posted by: Guest on May-11-2021

Code answers related to "laravel relation has many"

Browse Popular Code Answers by Language