3030 *
3131 * @mixin \Eloquent
3232 *
33- * @use HasFactory<Article >
33+ * @phpstan- use \Illuminate\Database\Eloquent\Factories\ HasFactory<self >
3434 */
3535final class Article extends Model
3636{
@@ -52,58 +52,79 @@ protected function casts(): array
5252 }
5353
5454 /**
55- * @return BelongsTo<User,Article>
55+ * @return BelongsTo<User, Article>
5656 */
5757 public function author (): BelongsTo
5858 {
59- return $ this ->belongsTo (User::class, 'created_by ' );
59+ /** @var BelongsTo<User, Article> $relation */
60+ $ relation = $ this ->belongsTo (User::class, 'created_by ' );
61+
62+ return $ relation ;
6063 }
6164
6265 /**
63- * @return BelongsTo<User,Article>
66+ * @return BelongsTo<User, Article>
6467 */
6568 public function approver (): BelongsTo
6669 {
67- return $ this ->belongsTo (User::class, 'approved_by ' );
70+ /** @var BelongsTo<User, Article> $relation */
71+ $ relation = $ this ->belongsTo (User::class, 'approved_by ' );
72+
73+ return $ relation ;
6874 }
6975
7076 /**
71- * @return BelongsTo<User,Article>
77+ * @return BelongsTo<User, Article>
7278 */
7379 public function updater (): BelongsTo
7480 {
75- return $ this ->belongsTo (User::class, 'updated_by ' );
81+ /** @var BelongsTo<User, Article> $relation */
82+ $ relation = $ this ->belongsTo (User::class, 'updated_by ' );
83+
84+ return $ relation ;
7685 }
7786
7887 /**
79- * @return HasMany<Comment,Article>
88+ * @return HasMany<Comment, Article>
8089 */
8190 public function comments (): HasMany
8291 {
83- return $ this ->hasMany (Comment::class);
92+ /** @var HasMany<Comment, Article> $relation */
93+ $ relation = $ this ->hasMany (Comment::class);
94+
95+ return $ relation ;
8496 }
8597
8698 /**
87- * @return BelongsToMany<Category,Article>
99+ * @return BelongsToMany<Category, Article, \Illuminate\Database\Eloquent\Relations\Pivot, 'pivot' >
88100 */
89101 public function categories (): BelongsToMany
90102 {
91- return $ this ->belongsToMany (Category::class, 'article_categories ' );
103+ /** @var BelongsToMany<Category, Article, \Illuminate\Database\Eloquent\Relations\Pivot, 'pivot'> $relation */
104+ $ relation = $ this ->belongsToMany (Category::class, 'article_categories ' );
105+
106+ return $ relation ;
92107 }
93108
94109 /**
95- * @return BelongsToMany<Tag,Article>
110+ * @return BelongsToMany<Tag, Article, \Illuminate\Database\Eloquent\Relations\Pivot, 'pivot' >
96111 */
97112 public function tags (): BelongsToMany
98113 {
99- return $ this ->belongsToMany (Tag::class, 'article_tags ' );
114+ /** @var BelongsToMany<Tag, Article, \Illuminate\Database\Eloquent\Relations\Pivot, 'pivot'> $relation */
115+ $ relation = $ this ->belongsToMany (Tag::class, 'article_tags ' );
116+
117+ return $ relation ;
100118 }
101119
102120 /**
103- * @return BelongsToMany<User,Article>
121+ * @return BelongsToMany<User, Article, \Illuminate\Database\Eloquent\Relations\Pivot, 'pivot' >
104122 */
105123 public function authors (): BelongsToMany
106124 {
107- return $ this ->belongsToMany (User::class, 'article_authors ' )->withPivot ('role ' );
125+ /** @var BelongsToMany<User, Article, \Illuminate\Database\Eloquent\Relations\Pivot, 'pivot'> $relation */
126+ $ relation = $ this ->belongsToMany (User::class, 'article_authors ' )->withPivot ('role ' );
127+
128+ return $ relation ;
108129 }
109130}
0 commit comments