1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class Post extends Model
8{
9 /**
10 * Get the comments for the blog post.
11 */
12 public function comments()
13 {
14 return $this->hasMany(Comment::class);
15 }
16}
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class Comment extends Model
8{
9 /**
10 * Get the post that owns the comment.
11 */
12 public function post()
13 {
14 return $this->belongsTo(Post::class);
15 }
16}