HEX
Server: nginx/1.24.0
System: Linux localhost 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: www (1000)
PHP: 8.3.27
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/erp.nhatnamsst.com/domains/QuoteRequest/Models/QuoteRequest.php
<?php

namespace Domains\QuoteRequest\Models;

use Domains\Admin\Models\Admin;
use Domains\Brand\Models\Brand;
use Domains\Customer\Models\Customer;
use Domains\Core\Enums\CustomerType;
use Domains\Core\Enums\QuoteRequestStatus;
use Domains\Core\Traits\ModelTrait;
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\HasMany;

class QuoteRequest extends Model
{
    use HasFactory, ModelTrait;

    protected $fillable = [
        'code',
        'sale_id',
        'request_date',
        'brand_id',
        'customer_id',
        'status',
        'selected_inter_id',
        'cannot_quote_reason',
        'requote_request_message',
        'confirm_messages',
        'sales_leader_quote_date',
        'customer_type',
        'new_consultant',
        'spare_parts',
        'project',
        'attached_files',
    ];

    protected function casts(): array
    {
        return [
            'status' => QuoteRequestStatus::class,
            'customer_type' => CustomerType::class,
            'spare_parts' => 'boolean',
            'request_date' => 'date',
            'sales_leader_quote_date' => 'date',
            'attached_files' => 'array',
            'confirm_messages' => 'array',
        ];
    }

    /**
     * Get the sale admin
     */
    public function sale(): BelongsTo
    {
        return $this->belongsTo(Admin::class, 'sale_id');
    }

    /**
     * Get the brand
     */
    public function brand(): BelongsTo
    {
        return $this->belongsTo(Brand::class);
    }

    /**
     * Get the customer
     */
    public function customer(): BelongsTo
    {
        return $this->belongsTo(Customer::class);
    }

    /**
     * Get the inters (many-to-many)
     */
    public function inters(): BelongsToMany
    {
        return $this->belongsToMany(Admin::class, 'quote_request_inters', 'quote_request_id', 'admin_id')
            ->withTimestamps();
    }

    /**
     * Get the quote request details
     */
    public function details(): HasMany
    {
        return $this->hasMany(QuoteRequestDetail::class);
    }

    /**
     * Get the selected inter admin
     */
    public function selectedInter(): BelongsTo
    {
        return $this->belongsTo(Admin::class, 'selected_inter_id');
    }
}