Initial commit

This commit is contained in:
Ronald Huynen
2026-03-23 21:37:59 +01:00
commit 2547717edb
2193 changed files with 972171 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Http\Livewire;
use App\Models\Category;
use Livewire\Component;
class CategorySelectbox extends Component
{
public $categoryOptions = [];
public $categorySelected;
/**
* Prepare the component.
*
* @return void
*/
public function mount($categorySelected)
{
$this->categoryOptions = Category::with('translations')
->whereNot('type', 'App\Models\Tag')
->get()
->sortBy(function ($category) {
// Use the translated name (accessor) for sorting, checking if translation exists
return $category->translation->name ?? __('Untitled category');
})
->mapWithKeys(function ($category) {
return [
$category->id => [
'category_id' => $category->id,
// Check if translation exists before trying to access its name property
'name' => $category->translation ? $category->translation->name : __('Category') . ' ' . __('id') . ' ' . $category->id . ' ' . $category->type,
]
];
})
->toArray();
$this->categorySelected = $categorySelected;
$this->updated();
}
/**
* When component is updated
*
* @return void
*/
public function updated()
{
$this->dispatch('categorySelected', $this->categorySelected);
}
public function render()
{
return view('livewire.category-selectbox');
}
}