get relationship of relationship laravel code example
Example 1: laravel docs get relationship from relationship
$books = Book::with('author.contacts')->get();
Example 2: laravel has many
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
/**
* Get the comments for the blog post.
*/
public function comments()
{
return $this->hasMany('App\Models\Comment');
}
}