|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Nova; |
| 4 | + |
| 5 | +use Illuminate\Http\Request; |
| 6 | +use Laravel\Nova\Fields\Boolean; |
| 7 | +use Laravel\Nova\Fields\ID; |
| 8 | +use Laravel\Nova\Fields\Select; |
| 9 | +use Laravel\Nova\Fields\Text; |
| 10 | +use Laravel\Nova\Fields\Textarea; |
| 11 | +use Laravel\Nova\Http\Requests\NovaRequest; |
| 12 | + |
| 13 | +class GetInvolvedPage extends Resource |
| 14 | +{ |
| 15 | + public static $group = 'Content'; |
| 16 | + |
| 17 | + public static $model = \App\StaticPage::class; |
| 18 | + |
| 19 | + public static $title = 'name'; |
| 20 | + |
| 21 | + public static $priority = 10; |
| 22 | + |
| 23 | + public static function label() |
| 24 | + { |
| 25 | + return 'Get Involved'; |
| 26 | + } |
| 27 | + |
| 28 | + public static function singularLabel() |
| 29 | + { |
| 30 | + return 'Get Involved Page'; |
| 31 | + } |
| 32 | + |
| 33 | + public static function uriKey(): string |
| 34 | + { |
| 35 | + return 'get-involved-page'; |
| 36 | + } |
| 37 | + |
| 38 | + public static function authorizedToViewAny(Request $request): bool |
| 39 | + { |
| 40 | + return true; |
| 41 | + } |
| 42 | + |
| 43 | + public static function indexQuery(NovaRequest $request, $query) |
| 44 | + { |
| 45 | + return $query->where('path', '/get-involved'); |
| 46 | + } |
| 47 | + |
| 48 | + public static function relatableQuery(NovaRequest $request, $query) |
| 49 | + { |
| 50 | + return $query->where('path', '/get-involved'); |
| 51 | + } |
| 52 | + |
| 53 | + public static function authorizedToCreate(Request $request): bool |
| 54 | + { |
| 55 | + return false; |
| 56 | + } |
| 57 | + |
| 58 | + public function fields(Request $request): array |
| 59 | + { |
| 60 | + return [ |
| 61 | + ID::make()->sortable(), |
| 62 | + |
| 63 | + Text::make('Name') |
| 64 | + ->sortable() |
| 65 | + ->rules('required', 'max:255'), |
| 66 | + |
| 67 | + Boolean::make('Is Searchable', 'is_searchable'), |
| 68 | + |
| 69 | + Select::make('Category') |
| 70 | + ->options([ |
| 71 | + 'General' => 'General', |
| 72 | + 'Challenges' => 'Challenges', |
| 73 | + 'Tranning' => 'Tranning', |
| 74 | + 'Online Courses' => 'Online Courses', |
| 75 | + 'Other' => 'Other', |
| 76 | + ]) |
| 77 | + ->nullable() |
| 78 | + ->displayUsingLabels(), |
| 79 | + |
| 80 | + Select::make('Link Type', 'link_type') |
| 81 | + ->options([ |
| 82 | + 'internal_link' => 'Internal Link', |
| 83 | + 'external_link' => 'External Link', |
| 84 | + ]) |
| 85 | + ->rules('required') |
| 86 | + ->displayUsingLabels(), |
| 87 | + |
| 88 | + Textarea::make('Description')->nullable(), |
| 89 | + |
| 90 | + Text::make('Language') |
| 91 | + ->sortable() |
| 92 | + ->rules('required', 'size:2') |
| 93 | + ->default('en'), |
| 94 | + |
| 95 | + Text::make('Unique Identifier') |
| 96 | + ->rules('required', 'unique:static_pages,unique_identifier,{{resourceId}}'), |
| 97 | + |
| 98 | + Text::make('Path') |
| 99 | + ->readonly() |
| 100 | + ->rules('required', 'unique:static_pages,path,{{resourceId}}'), |
| 101 | + |
| 102 | + Text::make('Keywords') |
| 103 | + ->rules('nullable') |
| 104 | + ->help('Enter keywords separated by commas, e.g., coding, education, technology.'), |
| 105 | + |
| 106 | + Text::make('Thumbnail')->nullable(), |
| 107 | + |
| 108 | + Text::make('Meta Title')->nullable(), |
| 109 | + |
| 110 | + Textarea::make('Meta Description')->nullable(), |
| 111 | + |
| 112 | + Textarea::make('Meta Keywords')->nullable(), |
| 113 | + ]; |
| 114 | + } |
| 115 | +} |
0 commit comments