Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppPagesResources;
- use IlluminateHttpRequest;
- use LaravelNovaResource;
- use LaravelNovaFieldsID;
- use LaravelNovaFieldsText;
- use LaravelNovaFieldsHasMany;
- class Page extends Resource
- {
- /**
- * The model the resource corresponds to.
- *
- * @var string
- */
- public static $model = 'AppPagesModelsPage';
- /**
- * The single value that should be used to represent the resource when being displayed.
- *
- * @var string
- */
- public static $title = 'working_title';
- /**
- * @var string
- */
- public static $group = 'Pages';
- /**
- * The columns that should be searched.
- *
- * @var array
- */
- public static $search = [
- 'id', 'working_title'
- ];
- /**
- * Eager load translations
- */
- public static $with = ['translations'];
- /**
- * Get the fields displayed by the resource.
- *
- * @param IlluminateHttpRequest $request
- * @return array
- */
- public function fields(Request $request)
- {
- return [
- ID::make()->sortable(),
- Text::make('Title', 'working_title')
- ->sortable()
- ->rules('required', 'max:256'),
- HasMany::make('Translations', 'translations', AppPagesResourcesPageTranslation::class)
- ];
- }
- }
- <?php
- namespace CodedorPagesResources;
- use IlluminateHttpRequest;
- use LaravelNovaResource;
- use LaravelNovaFieldsID;
- use LaravelNovaFieldsText;
- class PageTranslation extends Resource
- {
- /**
- * The model the resource corresponds to.
- *
- * @var string
- */
- public static $model = 'CodedorPagesModelsPageTranslation';
- /**
- * Hide resource from Nova's standard menu.
- * @var bool
- */
- public static $displayInNavigation = false;
- /**
- * Get the fields displayed by the resource.
- *
- * @param IlluminateHttpRequest $request
- * @return array
- */
- public function fields(Request $request)
- {
- return [
- ID::make()->sortable(),
- Text::make('Locale')
- ->sortable()
- ->rules('required', 'max:256')
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement