Path : /var/www/html/phkaynews-v2/app/Http/Livewire/Admin/Partcials/ |
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
Current File : //var/www/html/phkaynews-v2/app/Http/Livewire/Admin/Partcials/CategoryForm.php |
<?php namespace App\Http\Livewire\Admin\Partcials; use Livewire\Component; use App\Models\Category; use Jantinnerezo\LivewireAlert\LivewireAlert; class CategoryForm extends Component { use LivewireAlert; public $category, $modal_id; protected $rules = [ 'category.name' => 'required|string|max:50', 'category.slug' => 'required', ]; public function mount($modalId, $category = null) { $this->modal_id = $modalId; $this->category = $category; } public function render() { return view('livewire.admin.partcials.category-form'); } public function submit() { $this->validate(); if (isset($this->category->id)) { $this->category->update([ 'name' => $this->category['name'], 'slug' => $this->category['slug'] ]); $this->emit('updateCategory'); } else { Category::create($this->category); $this->emit('addCategory', $this->category); $this->category = null; $this->resetValidation(); } $this->dispatchBrowserEvent('closeModal', ['modalId' => $this->modal_id]); } public function closeModal() { $this->category = null; $this->resetValidation(); } }