134 lines
3.1 KiB
PHP
134 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Nova\Resources\Post\UserDocs;
|
|
|
|
use App\Models\Post\User\UserDoc;
|
|
use App\Nova\Forms\NovaForm;
|
|
use App\Nova\Resource;
|
|
use App\Nova\User;
|
|
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
|
|
use Illuminate\Http\Request;
|
|
use Laravel\Nova\Fields\BelongsTo;
|
|
use Laravel\Nova\Fields\ID;
|
|
use Laravel\Nova\Fields\Image;
|
|
use Laravel\Nova\Fields\Select;
|
|
use Laravel\Nova\Fields\Text;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
|
|
class UserDocResource extends Resource
|
|
{
|
|
/**
|
|
* The model the resource corresponds to.
|
|
*
|
|
* @var class-string<\App\Models\Post\User\UserDoc>
|
|
*/
|
|
public static $model = \App\Models\Post\User\UserDoc::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
|
|
*/
|
|
public static $search = [
|
|
'id',
|
|
];
|
|
|
|
/**
|
|
* Return the location to redirect the user after creation.
|
|
*
|
|
* @param \Laravel\Nova\Resource $resource
|
|
* @return \Laravel\Nova\URL|string
|
|
*/
|
|
public static function redirectAfterCreate(NovaRequest $request, $resource)
|
|
{
|
|
return sprintf('/resources/users/%s', $resource->user_id);
|
|
}
|
|
|
|
/**
|
|
* Return the location to redirect the user after update.
|
|
*
|
|
* @param \Laravel\Nova\Resource $resource
|
|
* @return \Laravel\Nova\URL|string
|
|
*/
|
|
public static function redirectAfterUpdate(NovaRequest $request, $resource)
|
|
{
|
|
return sprintf('/resources/users/%s', $resource->user_id);
|
|
}
|
|
|
|
/**
|
|
* Get the fields displayed by the resource.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function fields(NovaRequest $request)
|
|
{
|
|
return [
|
|
ID::make()->sortable(),
|
|
|
|
BelongsTo::make(__('User'), 'user', User::class),
|
|
|
|
Select::make(__('Type'), 'corporation_type')
|
|
->options(UserDoc::corparationTypes())
|
|
->rules('required')
|
|
->displayUsingLabels(),
|
|
|
|
Text::make(__('Name'), 'corporation_name')->rules('required'),
|
|
|
|
Image::make(__('Patent'), 'patent_data')
|
|
->deletable(false)
|
|
->creationRules('required'),
|
|
|
|
Images::make(__('Goşmaça'), 'main')
|
|
->conversionOnIndexView('thumb150x150')
|
|
->setFileName(NovaForm::hashFileName()),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get the cards available for the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function cards(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the filters available for the resource.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function filters(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the lenses available for the resource.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function lenses(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Get the actions available for the resource.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function actions(NovaRequest $request)
|
|
{
|
|
return [];
|
|
}
|
|
}
|