Sh3ll
OdayForums


Server : Apache
System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64
User : tradze ( 1001)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /home/tradze/public_html/test.tradze.com/Backup25feb2025/app/Modules/Invoices/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/tradze/public_html/test.tradze.com/Backup25feb2025/app/Modules/Invoices/Models/Invoice.php
<?php
namespace App\Modules\Invoices\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class Invoice extends Model
{
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table="invoices";

    /**
     * The attributes that aren't mass assignable.
     *
     * @var array
     */
    protected $guarded = ['id'];

    protected $dates = ['created_at', 'updated_at', 'inv_date', 'inv_duedate'];


    /**
     * The BookingOrder that belong to the invoice.
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function account()
    {
        return $this->belongsTo('App\Modules\Accounts\Models\Account','account_id');
    }

    /**
     * The BookingOrder that belong to the invoice.
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function booking()
    {
        return $this->belongsTo('App\Modules\Schedules\Models\BookingOrder','booking_id');
    }

    /**
     * The User Account that belong to the invoice.
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo('App\User');
    }

    /**
     * The services that belong to the invoice.
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function items()
    {
        return $this->hasMany('App\Modules\Invoices\Models\Invoice_item','invoice_id');
    }

    /**
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function invoiceable()
    {
        return $this->morphTo();
    }

    /**
     * The payments that belong to the invoice.
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function payments()
    {
        return $this->hasMany('App\Modules\Invoices\Models\Payment');
    }


    /**
     * Scope a query to only include invoice for account
     *
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeOfAccount($query,$search=null)
    {
        if (!$search) return $query;
        return $query->where('account_id', $search);
    }

    /**
     * Scope a query to only include invoice with number
     *
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeOfNumber($query,$search=null)
    {
        if (!$search) return $query;
        return $query->where('number', $search);
    }

    /**
     * Scope a query to only include invoice with series
     *
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeOfSeries($query,$search=null)
    {
        if (!$search) return $query;
        return $query->where('prefix', $search);
    }

    /**
     * Scope a query to only include invoices with starting date.
     *
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeOfDateFrom($query,$search=null)
    {
        if (!$search) return $query;

        $search = Carbon::createFromFormat('Y-m-d',$search)->format('Y-m-d');
        return $query->where('inv_date', '>=', $search);
    }

    /**
     * Scope a query to only include invoices until date.
     *
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeOfDateTo($query,$search=null)
    {
        if (!$search) return $query;

        $search = Carbon::createFromFormat('Y-m-d',$search)->format('Y-m-d');
        return $query->where('inv_date', '<=', $search);
    }

}

ZeroDay Forums Mini