71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Estimate\Models;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Customer\Models\Customer;
|
|
|
|
class Estimate extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $table = "tbl_estimates";
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'title',
|
|
'estimate_no',
|
|
'date',
|
|
'customer_id',
|
|
'fiscal_year_id',
|
|
'validity',
|
|
'conditions',
|
|
'approval_status',
|
|
'approval_by',
|
|
'approval_remarks',
|
|
'approval_on',
|
|
'description',
|
|
'createdBy',
|
|
'updatedBy',
|
|
'status',
|
|
];
|
|
|
|
protected $casts = [
|
|
'date' => 'datetime',
|
|
'validity' => 'datetime',
|
|
'approval_on' => 'datetime',
|
|
'estimate_no' => 'integer',
|
|
];
|
|
|
|
const APPROVAL_STATUS = [
|
|
1 => 'Pending',
|
|
2 => 'Approved',
|
|
3 => 'Rejected',
|
|
];
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class, 'customer_id');
|
|
}
|
|
|
|
public function approver()
|
|
{
|
|
return $this->belongsTo(Customer::class, 'approval_by');
|
|
}
|
|
|
|
public function estimateDetails()
|
|
{
|
|
return $this->hasMany(EstimateDetail::class, 'estimate_id');
|
|
}
|
|
|
|
public static function getFillableFields()
|
|
{
|
|
return (new self())->fillable;
|
|
}
|
|
}
|