battle with structure
This commit is contained in:
74
app/Console/Commands/stubs/make-module/nova-resource.stub
Normal file
74
app/Console/Commands/stubs/make-module/nova-resource.stub
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace $NAMESPACE$;
|
||||
|
||||
use App\Nova\Resource;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
/**
|
||||
* @template TModel of \$MODEL_NAMESPACE$
|
||||
*
|
||||
* @extends Resource<TModel>
|
||||
*/
|
||||
class $RESOURCE_NAME_SINGULAR$ extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var class-string<\$MODEL_NAMESPACE$>
|
||||
*/
|
||||
public static $model = \$MODEL_NAMESPACE$::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $title = 'id';
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
public static $search = [
|
||||
'id',
|
||||
];
|
||||
|
||||
/**
|
||||
* The relationships that should be eager loaded on index queries.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
// public static $with = [];
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return __('$MODEL_NAME_PLURAL$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return __('$MODEL_NAME_SINGULAR$');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return array<int, \Laravel\Nova\Fields\FieldElement|\Laravel\Nova\Panel>
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
ID::make('id')->sortable(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user