Make custom controller in Laravel Nova
opanegro/nova-custom-controller is a Laravel package for make custom controller in laravel nova.
It currently has 14 GitHub stars and 4.407 downloads on Packagist (latest version 1.5).
Install it with composer require opanegro/nova-custom-controller.
Discover more Laravel packages by opanegro
or browse all Laravel packages to compare alternatives.
Last updated
Package Nova Custom Controller berfungsi untuk mengolah request tanpa perlu membuat controller baru, karna fitur ini sudah otomatis meng-override controller pada Laravel Nova anda.
composer require opanegro/nova-custom-controller
trait di file app/Nova/Resource.php...
use Opanegro\NovaCustomController\Traits\NovaCustomEvents;
abstract class Resource extends NovaResource
{
use NovaCustomEvents;
...
}
app/Nova/User.phpclass User extends Resource
{
...
/**
* Before updated in controller
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Database\Eloquent\Model $model
*/
public static function beforeUpdated(Request $request, Model $model)
{
// your codes
}
}
php artisan nova:custom-controller User --event=store --custom-uri-key=users
User: is the name of resource--event: is event if you want, available store, update--custom-uri-key: if you set the resource with custom uri key| Method Name | Type | Return | Description |
|---|---|---|---|
| beforeCreated() | static function | | Proses sebelum melakukan penyimpanan data baru |
| afterCreated() | static function | | Proses setelah melakukan penyimpanan data baru |
| beforeUpdated() | static function | | Proses sebelum melakukan penyimpanan data lama |
| afterUpdated() | static function | | Proses setelah melakukan penyimpanan data lama |
| afterSave() | static function | | Proses setelah melakukan penyimpanan data baru & lama |
| beforeSave() | static function | | Proses sebelum melakukan penyimpanan data baru & lama |
| customStoreController() | static function | | Custom full store process controller |
| customUpdateController() | static function | | Custom full update process controller |
| $unsetCustomFields | static variable | array | Unset model jika terdapat nama custom field yang tidak tersedia di fillable |
| $setCustomRequests | static variable | array | Menambah request baru untuk melakukan process pada model |