Downloads
Stars
Version
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.php
class 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 keyMethod 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 |