Update Submissions and add fields
This commit is contained in:
41
app/View/Components/CategorySelector.php
Normal file
41
app/View/Components/CategorySelector.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Language;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class CategorySelector extends Component
|
||||
{
|
||||
|
||||
public $categories;
|
||||
|
||||
/**f
|
||||
* Create a new component instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public string $section,
|
||||
public array $selected = [],
|
||||
public bool $required = true
|
||||
)
|
||||
{
|
||||
$this->categories = Category::query()
|
||||
->where(function ($query) {
|
||||
$query->whereJsonContains('restricted_to', $this->section)
|
||||
->orWhereNull('restricted_to');
|
||||
})
|
||||
->orderBy('name')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
{
|
||||
return view('components.category-selector');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user