Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Livewire\Pages\Karyawan;
- use Livewire\Component;
- class KaryawanIndex extends Component
- {
- /**
- * this is a global variable to work with
- * wire:model="employee_number",
- * wire:model="employee_name"
- * wire:model="gender"
- */
- public $employee_number, $employee_name, $gender;
- /**
- * giving validation rule
- * this is a global validation rule
- */
- protected $rules = [
- 'employee_number' => 'required|min:10',
- 'employee_name' => 'required|min:5',
- 'gender' => 'required'
- ];
- /**
- * will run after render function
- */
- public function mount()
- {
- $this->resetData();
- }
- /**
- * This function is to make real-time validation to form, when the user do a change
- */
- public function updated($propertyName)
- {
- $this->validateOnly($propertyName);
- }
- /**
- * this function will used to reset input field in a form with the wire:model
- */
- public function resetData()
- {
- $this->employee_number = '';
- $this->employee_name = '';
- $this->gender = '';
- }
- public function render()
- {
- return view('livewire.pages.karyawan.karyawan-index');
- }
- /**
- * this function will used to add data to the karyawan table
- */
- public function addData() {
- $this->validate();
- }
- }
Add Comment
Please, Sign In to add comment