Skip to content

Commit 3e43a32

Browse files
committed
HasPosts trait for user model
1 parent c641339 commit 3e43a32

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Traits/User/HasPosts.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Chrisjk123\Blogger\Traits\User;
4+
5+
use Chrisjk123\Blogger\Post;
6+
7+
trait HasPosts
8+
{
9+
public function posts()
10+
{
11+
return $this->hasMany(Post::class, 'user_id', $this->getKeyName());
12+
}
13+
}

0 commit comments

Comments
 (0)