⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.19
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
dalily-1.dev-unit.com
/
app
/
Http
/
Livewire
/
View File Name :
CategorySubcategoryComponent.php
<?php namespace App\Http\Livewire; use Livewire\Component; use Modules\Category\Entities\Category; use Modules\Category\Entities\SubCategory; class CategorySubcategoryComponent extends Component { public $category_modal = false; public $active_category = ''; public $active_subcategory = ''; public $active_category_id = ''; public $active_subcategory_id = ''; public $categories = []; public $subCategories = []; public function mount($category_id = null, $subcategory_id = null) { // While Edit if ($category_id && $subcategory_id) { $this->subCategories = SubCategory::active()->where('category_id', $category_id)->get(); $categories = Category::active()->where('id', $category_id)->first(); $subCategories = SubCategory::active()->where('id', $subcategory_id)->first(); $this->getSubCategories($category_id, $categories->name); $this->setSubCategory($subcategory_id, $subCategories?->name); } $this->categories = Category::active()->get(); } public function getSubCategories($id, $name) { $this->subCategories = SubCategory::active()->where('category_id', $id)->get(); $this->active_category = $name; $this->active_category_id = $id; $this->active_subcategory = ''; $this->active_subcategory_id = ''; } public function setSubCategory($id, $name) { $this->active_subcategory = $name; $this->active_subcategory_id = $id; $this->closeModal(); } public function openModal() { $this->category_modal = true; $this->dispatchBrowserEvent('contentChanged'); } public function closeModal() { $this->category_modal = false; } public function render() { return view('livewire.category-subcategory-component'); } }