52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Studio\Master\User;
|
|
|
|
use App\Livewire\Forms\Studio\Master\UserForm;
|
|
use App\Models\Outlet;
|
|
use App\Traits\WithAuthorization;
|
|
use App\Traits\WithOutletSelector;
|
|
use App\Traits\WithRoleSelector;
|
|
use App\Traits\WithToast;
|
|
use App\Traits\WithUpdatedData;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
#[Title('Tambah Pegawai')]
|
|
class Create extends Component
|
|
{
|
|
use WithAuthorization, WithOutletSelector, WithRoleSelector, WithToast, WithUpdatedData;
|
|
|
|
public UserForm $form;
|
|
|
|
public array $outlets = [];
|
|
|
|
public array $roles = [];
|
|
|
|
public function mount()
|
|
{
|
|
$this->outlets = Outlet::pluck('name', 'id')->toArray();
|
|
|
|
$this->roles = Role::where('name', '!=', 'Developer')->orderBy('id')->pluck('name', 'id')->toArray();
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$this->canOrAbort('create user');
|
|
|
|
$this->form->store();
|
|
|
|
$this->toast('Pegawai berhasil ditambahkan.');
|
|
|
|
$this->redirectRoute('studio.master.user.index');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.studio.master.user.form', [
|
|
'pageTitle' => 'Tambah Pegawai',
|
|
]);
|
|
}
|
|
}
|