|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Nova; |
| 4 | + |
| 5 | +use Illuminate\Http\Request; |
| 6 | +use Laravel\Nova\Fields\Boolean; |
| 7 | +use Laravel\Nova\Fields\HasMany; |
| 8 | +use Laravel\Nova\Fields\ID; |
| 9 | +use Laravel\Nova\Fields\Text; |
| 10 | +use Laravel\Nova\Fields\Trix; |
| 11 | +use Laravel\Nova\Http\Requests\NovaRequest; |
| 12 | +use Laravel\Nova\Panel; |
| 13 | + |
| 14 | +class CsrCampaignPage extends Resource |
| 15 | +{ |
| 16 | + public static $group = 'Content'; |
| 17 | + public static $model = \App\CsrCampaignPage::class; |
| 18 | + public static $title = 'id'; |
| 19 | + |
| 20 | + public static function label() |
| 21 | + { |
| 22 | + return 'Future Ready CSR'; |
| 23 | + } |
| 24 | + |
| 25 | + public static function singularLabel() |
| 26 | + { |
| 27 | + return 'Future Ready CSR Page'; |
| 28 | + } |
| 29 | + |
| 30 | + public static function uriKey(): string |
| 31 | + { |
| 32 | + return 'csr-campaign-page'; |
| 33 | + } |
| 34 | + |
| 35 | + public static function indexQuery(NovaRequest $request, $query) |
| 36 | + { |
| 37 | + return $query->where('id', 1); |
| 38 | + } |
| 39 | + |
| 40 | + public static function authorizedToCreate(Request $request): bool |
| 41 | + { |
| 42 | + return false; |
| 43 | + } |
| 44 | + |
| 45 | + public function fields(Request $request): array |
| 46 | + { |
| 47 | + return [ |
| 48 | + ID::make()->onlyOnForms(), |
| 49 | + Panel::make('General', [ |
| 50 | + Boolean::make('Use dynamic content for this page', 'use_dynamic_content'), |
| 51 | + ])->collapsable()->collapsedByDefault(), |
| 52 | + Panel::make('Hero', [ |
| 53 | + Trix::make('Hero text', 'hero_text')->nullable(), |
| 54 | + Text::make('Primary CTA text', 'primary_cta_text')->nullable(), |
| 55 | + Text::make('Primary CTA link', 'primary_cta_link')->nullable(), |
| 56 | + Text::make('Secondary CTA text', 'secondary_cta_text')->nullable(), |
| 57 | + Text::make('Secondary CTA link', 'secondary_cta_link')->nullable(), |
| 58 | + ])->collapsable()->collapsedByDefault(), |
| 59 | + Panel::make('About section', [ |
| 60 | + Text::make('Title', 'about_title')->nullable(), |
| 61 | + Trix::make('Description', 'about_description')->nullable(), |
| 62 | + ])->collapsable()->collapsedByDefault(), |
| 63 | + Panel::make('Resources section', [ |
| 64 | + Text::make('Section title', 'resources_title')->nullable(), |
| 65 | + HasMany::make('Resources', 'resources', CsrCampaignResource::class), |
| 66 | + ])->collapsable()->collapsedByDefault(), |
| 67 | + ]; |
| 68 | + } |
| 69 | +} |
0 commit comments