90 lines
1.9 KiB
PHP
90 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Modules\AssetExchange\Models;
|
|
|
|
use App\Business;
|
|
use App\Contact;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Deal extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'aex_deals';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'listing_id',
|
|
'appraisal_id',
|
|
'deal_code',
|
|
'deal_type',
|
|
'buyer_contact_id',
|
|
'status',
|
|
'agreed_price',
|
|
'commission_percent',
|
|
'commission_amount',
|
|
'transaction_purchase_id',
|
|
'transaction_sell_id',
|
|
'project_id',
|
|
'maintenance_rebuild_id',
|
|
'renovation_quote_id',
|
|
'maintenance_equipment_id',
|
|
'notes',
|
|
'created_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'agreed_price' => 'integer',
|
|
'commission_percent' => 'decimal:2',
|
|
'commission_amount' => 'integer',
|
|
];
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function listing()
|
|
{
|
|
return $this->belongsTo(Listing::class, 'listing_id');
|
|
}
|
|
|
|
public function appraisal()
|
|
{
|
|
return $this->belongsTo(Appraisal::class, 'appraisal_id');
|
|
}
|
|
|
|
public function buyer()
|
|
{
|
|
return $this->belongsTo(Contact::class, 'buyer_contact_id');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function offers()
|
|
{
|
|
return $this->hasMany(Offer::class, 'deal_id');
|
|
}
|
|
|
|
public function commissions()
|
|
{
|
|
return $this->hasMany(Commission::class, 'deal_id');
|
|
}
|
|
|
|
public function pipelineLinks()
|
|
{
|
|
return $this->hasMany(PipelineLink::class, 'deal_id');
|
|
}
|
|
|
|
public function pipelineEvents()
|
|
{
|
|
return $this->hasMany(PipelineEvent::class, 'entity_id')
|
|
->where('entity_type', self::class);
|
|
}
|
|
}
|