firstcommit
This commit is contained in:
0
Modules/Estimate/app/Models/.gitkeep
Normal file
0
Modules/Estimate/app/Models/.gitkeep
Normal file
70
Modules/Estimate/app/Models/Estimate.php
Normal file
70
Modules/Estimate/app/Models/Estimate.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
48
Modules/Estimate/app/Models/EstimateDetail.php
Normal file
48
Modules/Estimate/app/Models/EstimateDetail.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Estimate\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Modules\Billing\Models\BillingComponent;
|
||||
use Modules\Estimate\Database\Factories\EstimateDetailFactory;
|
||||
|
||||
class EstimateDetail extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = "tbl_estimate_details";
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'estimate_id',
|
||||
'billing_component_id',
|
||||
'fiscal_year_id',
|
||||
'price',
|
||||
'qty',
|
||||
'tax_amount',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'remarks',
|
||||
'status',
|
||||
];
|
||||
|
||||
|
||||
public function estimate()
|
||||
{
|
||||
return $this->belongsTo(Estimate::class, 'estimate_id')->withDefault();
|
||||
}
|
||||
|
||||
public function billingComponent()
|
||||
{
|
||||
return $this->belongsTo(BillingComponent::class, 'billing_component_id')->withDefault();
|
||||
}
|
||||
|
||||
public function getFillableFields()
|
||||
{
|
||||
return (new self())->fillable;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user