109 lines
2.6 KiB
PHP
109 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Nova;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Laravel\Nova\Auth\PasswordValidationRules;
|
|
use Laravel\Nova\Fields\Gravatar;
|
|
use Laravel\Nova\Fields\ID;
|
|
use Laravel\Nova\Fields\Password;
|
|
use Laravel\Nova\Fields\Text;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
|
|
class User extends Resource
|
|
{
|
|
use PasswordValidationRules;
|
|
|
|
/**
|
|
* The model the resource corresponds to.
|
|
*
|
|
* @var class-string<\App\Models\User>
|
|
*/
|
|
public static $model = \App\Models\User::class;
|
|
|
|
/**
|
|
* The single value that should be used to represent the resource when being displayed.
|
|
*
|
|
* @var string
|
|
*/
|
|
public static $title = 'name';
|
|
|
|
/**
|
|
* The columns that should be searched.
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $search = [
|
|
'id', 'name', 'email',
|
|
];
|
|
|
|
/**
|
|
* Get the fields displayed by the resource.
|
|
*
|
|
* @return array<int, \Laravel\Nova\Fields\Field|\Laravel\Nova\Panel|\Laravel\Nova\ResourceTool|\Illuminate\Http\Resources\MergeValue>
|
|
*/
|
|
public function fields(NovaRequest $request): array
|
|
{
|
|
return [
|
|
ID::make()->sortable(),
|
|
|
|
Gravatar::make()->maxWidth(50),
|
|
|
|
Text::make('Name')
|
|
->sortable()
|
|
->rules('required', 'max:255'),
|
|
|
|
Text::make('Email')
|
|
->sortable()
|
|
->rules('required', 'email', 'max:254')
|
|
->creationRules('unique:users,email')
|
|
->updateRules('unique:users,email,{{resourceId}}'),
|
|
|
|
Password::make('Password')
|
|
->onlyOnForms()
|
|
->creationRules($this->passwordRules())
|
|
->updateRules($this->optionalPasswordRules()),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the cards available for the request.
|
|
*
|
|
* @return array<int, \Laravel\Nova\Card>
|
|
*/
|
|
public function cards(NovaRequest $request): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the filters available for the resource.
|
|
*
|
|
* @return array<int, \Laravel\Nova\Filters\Filter>
|
|
*/
|
|
public function filters(NovaRequest $request): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the lenses available for the resource.
|
|
*
|
|
* @return array<int, \Laravel\Nova\Lenses\Lens>
|
|
*/
|
|
public function lenses(NovaRequest $request): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the actions available for the resource.
|
|
*
|
|
* @return array<int, \Laravel\Nova\Actions\Action>
|
|
*/
|
|
public function actions(NovaRequest $request): array
|
|
{
|
|
return [];
|
|
}
|
|
}
|