93 lines
2.2 KiB
PHP
93 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\AssetExchange\Models;
|
|
|
|
use App\Business;
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Appraisal extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'aex_appraisals';
|
|
|
|
protected $fillable = [
|
|
'business_id',
|
|
'listing_id',
|
|
'appraisal_number',
|
|
'status',
|
|
'methodology',
|
|
'appraiser_user_id',
|
|
'field_visit_date',
|
|
'report_summary',
|
|
'as_is_value',
|
|
'renovation_cost_estimate',
|
|
'post_renovation_value',
|
|
'recommended_buy_price',
|
|
'recommended_sell_price',
|
|
'appraisal_fee',
|
|
'approved_by',
|
|
'approved_at',
|
|
'valid_until',
|
|
'ie_cost_scenario_id',
|
|
'report_pdf_path',
|
|
];
|
|
|
|
protected $casts = [
|
|
'field_visit_date' => 'date',
|
|
'as_is_value' => 'integer',
|
|
'renovation_cost_estimate' => 'integer',
|
|
'post_renovation_value' => 'integer',
|
|
'recommended_buy_price' => 'integer',
|
|
'recommended_sell_price' => 'integer',
|
|
'appraisal_fee' => 'integer',
|
|
'approved_at' => 'datetime',
|
|
'valid_until' => 'date',
|
|
];
|
|
|
|
public function business()
|
|
{
|
|
return $this->belongsTo(Business::class);
|
|
}
|
|
|
|
public function listing()
|
|
{
|
|
return $this->belongsTo(Listing::class, 'listing_id');
|
|
}
|
|
|
|
public function appraiser()
|
|
{
|
|
return $this->belongsTo(User::class, 'appraiser_user_id');
|
|
}
|
|
|
|
public function approvedByUser()
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_by');
|
|
}
|
|
|
|
public function lines()
|
|
{
|
|
return $this->hasMany(AppraisalLine::class, 'appraisal_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function rootLines()
|
|
{
|
|
return $this->hasMany(AppraisalLine::class, 'appraisal_id')
|
|
->whereNull('parent_line_id')
|
|
->orderBy('sort_order');
|
|
}
|
|
|
|
public function deals()
|
|
{
|
|
return $this->hasMany(Deal::class, 'appraisal_id');
|
|
}
|
|
|
|
public function pipelineEvents()
|
|
{
|
|
return $this->hasMany(PipelineEvent::class, 'entity_id')
|
|
->where('entity_type', self::class);
|
|
}
|
|
}
|