File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/Http/Controllers/Pages Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ class PageController extends Controller
1818
1919 protected bool $ currentPage = false ;
2020
21+ protected string $ model = Menu::class;
22+
2123 public function __construct (
2224 protected ?int $ pageId = null
2325 ) {
@@ -52,10 +54,17 @@ public function id(): int
5254 return $ this ->pageId ;
5355 }
5456
57+ /**
58+ * menuItem
59+ *
60+ * This will fetch the Menu model for the current page.
61+ * You can subclass Menu and add a custom model to the
62+ * $model property to use a custom model.
63+ */
5564 protected function menuItem (): Menu
5665 {
5766 if ($ this ->menuItem === null ) {
58- $ this ->menuItem = Menu ::whereId ($ this ->id ())->firstOrFail ();
67+ $ this ->menuItem = $ this -> model ::whereId ($ this ->id ())->firstOrFail ();
5968 }
6069
6170 return $ this ->menuItem ;
You can’t perform that action at this time.
0 commit comments