44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SalesPhase extends Model
|
|
{
|
|
use HasUuids, HasFactory;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'discount_policy' => 'array',
|
|
'start_date' => 'date',
|
|
'end_date' => 'date',
|
|
];
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function paymentTemplate()
|
|
{
|
|
return $this->belongsTo(PaymentTemplate::class);
|
|
}
|
|
|
|
public function phaseProducts()
|
|
{
|
|
return $this->hasMany(SalesPhaseProduct::class);
|
|
}
|
|
|
|
public function products()
|
|
{
|
|
return $this->belongsToMany(Product::class, 'sales_phase_products')
|
|
->using(SalesPhaseProduct::class)
|
|
->withPivot('id', 'sale_price', 'land_value', 'foundation_value', 'discount_details', 'status')
|
|
->withTimestamps();
|
|
}
|
|
}
|