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/app/Modules/Invoices/Models/ |
<?php
namespace App\Modules\Invoices\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Payment extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table="invoices_payments";
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = ['id'];
protected $dates = ['created_at', 'updated_at', 'payment_date'];
/**
* The User Account that belong to the invoice.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('App\User');
}
/**
* Filter: start with date
* @param $query
* @param null $search
* @return mixed
*/
public function scopeOfDateStart($query,$search=null)
{
if (!$search) return $query;
$search = Carbon::createFromFormat('d-m-Y',$search)->format('Y-m-d');
return $query->where('payment_date', '>=', $search);
}
/**
* Filter: end with date
* @param $query
* @param null $search
* @return mixed
*/
public function scopeOfDateEnd($query,$search=null)
{
if (!$search) return $query;
$search = Carbon::createFromFormat('d-m-Y',$search)->format('Y-m-d');
return $query->where('payment_date', '<=', $search);
}
}