HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/quadcode-jobs/app/Models/Location.php
<?php

namespace App\Models;

use App\Helpers\CollectionHelper;
use App\Repositories\OfficeRepository;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Pagination\LengthAwarePaginator;

/**
 * @property int $id
 * @property string $deleted_at
 * @property string $created_at
 * @property string $updated_at
 * @property int $position
 * @property int $id_external
 * @property string $map_coords
 * @property int $count_positions
 * @property string $slug
 * @property string $title
 * @property string $description
 * @property string $title_prepositional
 * @property string $country
 * @property bool $active
 *
 * @property Vacancy[] $vacancies
 */
class Location extends Model
{

    protected $fillable = [
        'position',
        'id_external',
        'map_coords',
        'count_positions',
        'slug',
        'title',
        'description',
        'title_prepositional',
        'country',
        'about_office',
        'active',
    ];

    public function isLarnaca(): bool
    {
        return OfficeRepository::LARNACA === $this->title;
    }


    public function vacancies(): BelongsToMany
    {
        return $this->belongsToMany(Vacancy::class);
    }

    public function getVacanciesList(): LengthAwarePaginator
    {
        $title = OfficeRepository::LIMASSOL === $this->title ? OfficeRepository::CYPRUS : $this->title;
        /** @var LeverLocation $location */
        $location = LeverLocation::query()->where('title', $title)->first();
        $vacancies = empty($location) ? new Collection([]) : $location->vacancies;

        return CollectionHelper::paginate($vacancies, 10);
    }

}