2626use Carbon \Carbon ;
2727use Illuminate \Database \Eloquent \Builder ;
2828use Illuminate \Database \Eloquent \Collection ;
29+ use Illuminate \Database \Eloquent \Relations \BelongsTo ;
2930use Illuminate \Database \Eloquent \Relations \MorphMany ;
3031use Illuminate \Database \Eloquent \SoftDeletes ;
3132
@@ -283,10 +284,14 @@ abstract public function getUrl(string $path = '/'): string;
283284 public function getParent (): ?self
284285 {
285286 if ($ this instanceof Page) {
286- return $ this ->chapter_id ? $ this ->chapter ()->withTrashed ()->first () : $ this ->book ()->withTrashed ()->first ();
287+ /** @var BelongsTo<Chapter|Book, Page> $builder */
288+ $ builder = $ this ->chapter_id ? $ this ->chapter () : $ this ->book ();
289+ return $ builder ->withTrashed ()->first ();
287290 }
288291 if ($ this instanceof Chapter) {
289- return $ this ->book ()->withTrashed ()->first ();
292+ /** @var BelongsTo<Book, Page> $builder */
293+ $ builder = $ this ->book ();
294+ return $ builder ->withTrashed ()->first ();
290295 }
291296
292297 return null ;
@@ -295,15 +300,15 @@ public function getParent(): ?self
295300 /**
296301 * Rebuild the permissions for this entity.
297302 */
298- public function rebuildPermissions ()
303+ public function rebuildPermissions (): void
299304 {
300305 app ()->make (JointPermissionBuilder::class)->rebuildForEntity (clone $ this );
301306 }
302307
303308 /**
304309 * Index the current entity for search.
305310 */
306- public function indexForSearch ()
311+ public function indexForSearch (): void
307312 {
308313 app ()->make (SearchIndex::class)->indexEntity (clone $ this );
309314 }
0 commit comments