41 lines
896 B
PHP
41 lines
896 B
PHP
<?php
|
|
|
|
namespace App\View\Components;
|
|
|
|
use App\Models\Location;
|
|
use Illuminate\View\Component;
|
|
use Illuminate\View\View;
|
|
|
|
class LocationSelectorSidebar extends Component
|
|
{
|
|
public Location $selected;
|
|
|
|
public $locations;
|
|
|
|
/**
|
|
* Create a new component instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
// Get location ID from session, default to 22 if not set
|
|
$locationId = session('location_id', 22);
|
|
|
|
$this->selected = Location::where('id', $locationId)->first();
|
|
|
|
$this->locations = Location::whereNotNull('display_name')
|
|
->whereNot('display_name', '=', '')
|
|
->orderBy('display_name')
|
|
->get();
|
|
|
|
}
|
|
|
|
/**
|
|
* Get the view/contents that represent the component.
|
|
*/
|
|
public function render(): View
|
|
{
|
|
|
|
return view('components.location-selector-sidebar');
|
|
}
|
|
}
|