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/limestate-admin/app/Models/Flat.php
<?php

namespace App\Models;

use App\Collections\FlatOptionCollection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Orchid\Attachment\Attachable;
use Orchid\Attachment\Models\Attachment;
use Orchid\Filters\Filterable;
use Orchid\Filters\Types\Where;
use Orchid\Filters\Types\WhereIn;
use Orchid\Screen\AsSource;

/**
 * @property int $id
 * @property bool $is_secondary
 * @property string $alias
 * @property ?int $floor
 * @property ?int $rooms
 * @property ?float $total_area
 * @property ?float $living_area
 * @property ?float $rooms_area
 * @property ?float $kitchen_area
 * @property ?string $number
 * @property ?float $price
 * @property ?float $base_price
 * @property int $building_id
 * @property ?float $mortgage_price
 * @property ?int $assignment
 * @property ?int $contractor
 * @property ?int $bathroom_type_id
 * @property ?int $balcony_type_id
 * @property ?int $finishing_type_id
 * @property ?int $view_type_id
 * @property ?int $entrance
 * @property ?string $rooms_area_separately
 * @property ?int $old_ID
 * @property ?int $published
 * @property ?string $meta_title
 * @property ?string $meta_description
 * @property ?string $meta_keywords
 * @property ?string $created_at
 * @property ?string $updated_at
 * @property ?string $description
 * @property ?int $plan_id
 * @property ?string $rutube_id
 * @property ?string $deleted_at
 *
 * @method  MorphToMany[] attachment()
 * @property Attachment[] $attachment
 *
 * @property Building $building
 * @property FlatOptionCollection $options
 * @property Attachment $plan
 */
class Flat extends Model
{

    use HasFactory;
    use AsSource;
    use Filterable;
    use Attachable;
    use SoftDeletes;

    protected $fillable = [
        'is_secondary',
        'alias',
        'floor',
        'rooms',
        'total_area',
        'living_area',
        'rooms_area',
        'kitchen_area',
        'number',
        'price',
        'base_price',
        'building_id',
        'mortgage_price',
        'assignment',
        'contractor',
        'bathroom_type_id',
        'balcony_type_id',
        'finishing_type_id',
        'view_type_id',
        'entrance',
        'rooms_area_separately',
        'old_ID',
        'published',
        'meta_title',
        'meta_description',
        'meta_keywords',
        'description',
        'plan_id',
        'rutube_id',
    ];

    protected $casts = [
        'is_secondary' => 'boolean',
    ];

    protected array $allowedSorts = ['id', 'updated_at', 'published'];

    protected array $allowedFilters = [
        'is_secondary' => Where::class,
        'building_id' => WhereIn::class,
        'number' => Where::class,
        'published' => Where::class,
    ];

    public function setDescriptionAttribute($newValue): void
    {
        $this->attributes['description'] = $newValue ?? '';
    }

    // MARK: - Relations

    public function building(): BelongsTo
    {
        return $this->belongsTo(Building::class);
    }

    public function options(): BelongsToMany
    {
        return $this->belongsToMany(FlatOption::class, FlatOptionsRelation::class, 'flat_id', 'option_id');
    }

    public function plan(): BelongsTo
    {
        return $this->belongsTo(Attachment::class, 'plan_id');
    }

}