File: D:/HostingSpaces/SBogers10/ste.komma.pro/app/Locations/LocationService.php
<?php
namespace App\Locations;
use App\Base\Service;
use App\C4\C4;
use App\Locations\Models\Location;
use App\Types\TrainingFilter;
use App\Types\TrainingFilterOption;
final class LocationService extends Service
{
/**
* Base query for get locations from DB
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
private function basLocationQuery()
{
return Location::where('active', 1)
->orderBy('lft', 'asc')
->with('images');
}
/**
* Get all locations
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getLocations()
{
return $this->basLocationQuery()->get();
}
public function getLocationByC4Code(string $c4Code): ?Location
{
if(! isset(C4::LOCATIONS[$c4Code])) return null;
$locationId = C4::LOCATIONS[$c4Code];
return Location::find($locationId);
}
}