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/ipsremont-demo/app/Models/Statuses.php
<?php

namespace App\Models;

use App\Traits\Displayed;
use App\Traits\My;
use App\Traits\Sortable;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @property int $id
 * @property string $name
 * @property string $slug
 * @property ?string $external_id
 * @property int $position
 * @property ?string $deleted_at
 * @property ?string $created_at
 * @property ?string $updated_at
 * @property string $type
 * @property ?string $color
 */
class Statuses extends BaseModel
{
    use SoftDeletes, Sortable, Displayed, My;

    protected $table = 'statuses';

    const type_orders = 'order';
    const type_repair = 'repair';
    const type_acttc = 'acttc';
    const TYPE_SHIPMENT = 'shipment';

    protected $fillable = [
        'name',
        'slug',
        'external_id',
        'position',
        'type',
        'color'
    ];

    protected static $labels = [
        'name' => 'statuses.name',
        'slug' => 'statuses.slug',
        'external_id' => 'statuses.external_id',
        'position' => 'statuses.position',
        'type' => 'statuses.type',
    ];

    public static function columns()
    {
        return [
            "fields" => [
                [
                    "displayName" => 'grid.name',
                    "field" => "name",
                    "sort" => true,
                    "sortType" => 'asc',
                    'class' => 'text-left',
                ],
                [
                    "displayName" => 'grid.slug',
                    "field" => "slug",
                    "sort" => true,
                    "sortType" => 'asc',
                    'class' => 'text-left',
                ],
                [
                    "displayName" => 'grid.external_id',
                    "field" => "external_id",
                    "sort" => true,
                    "sortType" => 'asc',
                    'class' => 'text-left',
                ],
                [
                    "displayName" => 'grid.position',
                    "field" => "position",
                    "sort" => true,
                    "sortType" => 'asc',
                    'class' => 'text-left',
                ],
                [
                    "displayName" => '',
                    "field" => 'action',
                    "sort" => false,
                    'class' => 'w-100px',
                ]
            ],
            "sortDefault" => [
                [
                    "field" => 'position',
                    "sort" => 'asc'
                ],
            ]
        ];
    }

    public function getName() {
        $key = 'statuses.'.$this->type.'.'.$this->slug;
        $lang = __($key);
        return ($lang <> $key)?$lang:$this->name;
    }

    public function getColoredName()
    {
        return '<span class="' . $this->getColor() . '">' . $this->getName() . '</span>';
    }

    public function getSlug() {
        return $this->slug;
    }

    public function getColor() {
        return $this->color;
    }

    public function getCode() {
        return $this->external_id;
    }

    public function getPosition() {
        return $this->position;
    }

    /**
     * Scope a query to only include My items
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @param $slug
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeBySlug($query, $slug) {
        $query->where(['slug' => $slug]);
    }
}