@@ -15,10 +15,19 @@ class ListPages extends ListRecords
1515
1616 protected static string $ resource = PageResource::class;
1717
18+ public ?int $ sectionId = null ;
19+
20+ public function mount (): void
21+ {
22+ parent ::mount ();
23+
24+ $ this ->sectionId = request ()->get ('sId ' );
25+ }
26+
1827 public function getTitle (): string
1928 {
20- if ($ sectionId = request ()-> get ( ' sId ' ) ) {
21- $ section = Section::find ($ sectionId );
29+ if ($ this -> sectionId ) {
30+ $ section = Section::find ($ this -> sectionId );
2231 if ($ section ) {
2332 return $ section ->name ;
2433 }
@@ -29,8 +38,8 @@ public function getTitle(): string
2938
3039 public function getBreadcrumb (): ?string
3140 {
32- if ($ sectionId = request ()-> get ( ' sId ' ) ) {
33- $ section = Section::find ($ sectionId );
41+ if ($ this -> sectionId ) {
42+ $ section = Section::find ($ this -> sectionId );
3443 if ($ section ) {
3544 return $ section ->name ;
3645 }
@@ -43,8 +52,8 @@ protected function getTableQuery(): Builder
4352 {
4453 $ query = parent ::getTableQuery ();
4554
46- if ($ sectionId = request ()-> get ( ' sId ' ) ) {
47- $ query ->where ('section_id ' , $ sectionId );
55+ if ($ this -> sectionId ) {
56+ $ query ->where ('section_id ' , $ this -> sectionId );
4857 }
4958
5059 return $ query ;
@@ -54,10 +63,10 @@ protected function getHeaderActions(): array
5463 {
5564 $ createAction = CreateAction::make ();
5665
57- if (request ()-> get ( ' sId ' ) ) {
66+ if ($ this -> sectionId ) {
5867 $ createAction
5968 ->url (fn () => PageResource::getUrl ('create ' , [
60- 'sId ' => request ()-> get ( ' sId ' ) ,
69+ 'sId ' => $ this -> sectionId ,
6170 ]));
6271 }
6372
0 commit comments