File tree Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Expand file tree Collapse file tree 3 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Huntie \JsonApi \Tests \Fixtures \Models ;
4
+
5
+ class Post extends Model
6
+ {
7
+ /**
8
+ * The author of the post.
9
+ *
10
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
11
+ */
12
+ public function author ()
13
+ {
14
+ return $ this ->belongsTo (User::class, 'author_id ' );
15
+ }
16
+
17
+ /**
18
+ * The post tag memberships.
19
+ *
20
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
21
+ */
22
+ public function tags ()
23
+ {
24
+ return $ this ->belongsToMany (Tag::class);
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Huntie \JsonApi \Tests \Fixtures \Models ;
4
+
5
+ class Tag extends Model
6
+ {
7
+ /**
8
+ * The posts matching the tag.
9
+ *
10
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
11
+ */
12
+ public function posts ()
13
+ {
14
+ return $ this ->belongsToMany (Post::class);
15
+ }
16
+ }
Original file line number Diff line number Diff line change @@ -10,4 +10,14 @@ class User extends Model
10
10
* @var array
11
11
*/
12
12
protected $ hidden = ['password ' ];
13
+
14
+ /**
15
+ * The posts the user has authored.
16
+ *
17
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
18
+ */
19
+ public function post ()
20
+ {
21
+ return $ this ->hasMany (Post::class, 'author_id ' );
22
+ }
13
23
}
You can’t perform that action at this time.
0 commit comments