HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
    }

}