Laravel Eloquent Always Load Model Relation Example

Laravel Eloquent Always Load Model Relation Example

Create Post Model with $with variable

app/Models/Post.php

hasMany(Comment::class);
    }
}

Get Post with comments

$post = Post::find($id);
  
$post->comments;

Leave a Comment