norman-huth / nova-breack-out
Use validation rules and other data from a Laravel Nova resource.
Fund package maintenance!
Muetze42
Ko Fi
huth.it/coffee
Requires
- php: ^8.1
- laravel/nova: ^4.2
This package is auto-updated.
Last update: 2024-11-26 17:02:31 UTC
README
Use validation rules and other data from a Laravel Nova resources in order to avoid duplicate content maintenance.
Sorry for the name of the package. My creativity with names is on low level.
Install
composer require norman-huth/nova-breack-out
Usage
Validation
Get Creation Validation Rules From A Nova Resource
public function store(\Illuminate\Http\Request $request) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $rules = $nova->getRulesForCreation( model: \App\Models\User::class, resource: \App\Nova\Resources\User::class );
Validate Request With Creation Rules From A Nova Resource
public function store(\Illuminate\Http\Request $request) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $validated = $nova->validateCreationRequest( model: \App\Models\User::class, resource: \App\Nova\Resources\User::class );
Get Update Validation Rules From A Nova Resource
public function update(\Illuminate\Http\Request $request, \App\Models\User $user) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $rules = $nova->getRulesForUpdate( model: $user, resource: \App\Nova\Resources\User::class );
Validate Request With Update Rules From A Nova Resource
public function update(\Illuminate\Http\Request $request, \App\Models\User $user) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $validated = $nova->validateUpdateRequest( model: $user, resource: \App\Nova\Resources\User::class );
Authorization From Nova Resource
ViewAny
public function index(\Illuminate\Http\Request $request) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $nova->authorizeToViewAny( model: \App\Models\User::class, resource: \App\Nova\Resources\User::class );
Create
public function store(\Illuminate\Http\Request $request) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $nova->authorizeToCreate( model: \App\Models\User::class, resource: \App\Nova\Resources\User::class );
View
public function show(\Illuminate\Http\Request $request, \App\Models\User $user) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $nova->authorizeToView( model: $user, resource: \App\Nova\Resources\User::class );
Update
public function update(\Illuminate\Http\Request $request, \App\Models\User $user) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $nova->authorizeToUpdate( model: $user, resource: \App\Nova\Resources\User::class );
Delete
public function destroy(\Illuminate\Http\Request $request, \App\Models\User $user) { $nova = new \NormanHuth\NovaBreakOut\Resource($request); $nova->authorizeToDelete( model: $user, resource: \App\Nova\Resources\User::class );
More Infos From Nova Resource
Get the displayable label of the resource.
$nova = new \NormanHuth\NovaBreakOut\Resource($request); return $nova->label(resource: \App\Nova\Resources\User::class);
Get the displayable singular label of the resource.
$nova = new \NormanHuth\NovaBreakOut\Resource($request); return $nova->singularLabel(resource: \App\Nova\Resources\User::class);
Get the value that should be displayed to represent the resource.
$nova = new \NormanHuth\NovaBreakOut\Resource($request); return $nova->title(resource: \App\Nova\Resources\User::class);
Get the search result subtitle for the resource.
$nova = new \NormanHuth\NovaBreakOut\Resource($request); return $nova->subtitle(resource: \App\Nova\Resources\User::class);
Get the logical group associated with the resource.
$nova = new \NormanHuth\NovaBreakOut\Resource($request); return $nova->group(resource: \App\Nova\Resources\User::class);
Get the searchable columns for the resource.
$nova = new \NormanHuth\NovaBreakOut\Resource($request); return $nova->searchableColumns(resource: \App\Nova\Resources\User::class);
Todo
- Relation rules