Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mcoil.corals.io/app/Shop/Quotations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/app/Shop/Quotations/Quotation.php
<?php

namespace App\Shop\Quotations;

use App\Shop\Customers\Customer;
use App\Shop\Businesses\Business;
use Illuminate\Database\Eloquent\Model;
use App\Shop\QuotationItems\QuotationItem;
use Nicolaslopezj\Searchable\SearchableTrait;
use App\Shop\QuotationStatuses\QuotationStatus;

class Quotation extends Model
{
    use SearchableTrait;

    public const STATUS = [
        1 => 'Archived',
        2 => 'Lost',
        3 => 'Not set',
        4 => 'Open',
        5 => 'Won'
    ];

    protected $dates = ['availabledate'];

    protected $casts = [
        'contacts' => 'array',
        'groups' => 'array',
    ];

    protected $fillable = [
        'customer_id',
        'business_id',
        'title',
        'availability',
        'availabledate',
        'rrp',
        'currency',
        'quantity',
        'sell_price_delivery', 'cost_delivery', 'profit_delivery', 'gp_delivery',
        'sell_price_installation', 'cost_installation', 'profit_installation', 'gp_installation',
        'sell_price_quotation', 'cost_quotation', 'profit_quotation', 'gp_quotation',
        'final_discount',
        'price', 'sellprice', 'cost', 'profit', 'gp',
        'contacts', 'groups',
        'final_notes', 'code',
        'quotation_status_id',
        'status',
    ];

    /**
     * Searchable rules.
     *
     * @var array
     */
    protected $searchable = [
        'columns' => [
            'quotations.title' => 10,
            'customers.first_name' => 10 ,
            'customers.last_name' => 10 ,
            'businesses.title' => 10,
        ],

        'joins' => [
            'customers' => ['customers.id', 'quotations.customer_id'],
            'businesses' => ['businesses.id', 'customers.business_id'],
        ],

        'groupBy' => ['quotations.id']
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function status()
    {
        return $this->belongsTo(QuotationStatus::class);
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function business()
    {
        return $this->belongsTo(Business::class);
    }

    public function items()
    {
        return $this->hasMany(QuotationItem::class);
    }

    /**
     * @param $term
     *
     * @return mixed
     */
    public function searchQuotations($term)
    {
        return self::search($term);
    }

    public function getArrayGroupsAttribute()
    {
        $groups = [];
        if(is_array($this->groups)) {
            foreach($this->groups as $group) {
                if( !is_null($group['name']) ) {
                    $groups[$group['id']] = $group['name'];
                }
            }
        }
        return $groups;
    }
}

Spamworldpro Mini