File: /var/www/html/owlcrm/app/Models/PostSale.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class PostSale extends Model implements HasMedia
{
use HasFactory, SoftDeletes, InteractsWithMedia;
protected $table = 'post_sales';
protected $fillable = [
'title',
'source',
'assigned_to',
'customer_id',
'salutation',
'first_name',
'last_name',
'gender',
'property_interest_type',
'is_organization',
'organization_name',
'designation',
'budget',
'email_address',
'website',
'phone',
'mobile_number',
'description',
'last_contacted',
'next_followup',
'address_line_1',
'address_line_2',
'city',
'state',
'postal_code',
'country',
'status',
];
// Constants
const postSales_status = [
0 => '--Select--',
'documentation' => 'Documentation',
'payment processing' => 'Payment Processing',
'handover preparation' => 'Handover Preparation',
'final handover' => 'Final Handover',
];
const LEAD_SALUTATION = [
'mr' => 'Mr',
'mrs' => 'Mrs',
'miss' => 'Miss',
];
const LEAD_GENDER = [
'male' => 'Male',
'female' => 'Female',
'other' => 'Other',
];
const PROPERTY_INTEREST_TYPE = [
'residential' => 'Residential',
'commercial' => 'Commercial',
'both' => 'Both',
];
// Relationships
public function city()
{
return $this->belongsTo(City::class, 'city', 'id');
}
public function state()
{
return $this->belongsTo(States::class, 'state', 'id');
}
public function country()
{
return $this->belongsTo(Country::class, 'country', 'id');
}
public function user()
{
return $this->belongsTo(User::class, 'assigned_to', 'id');
}
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id', 'id');
}
// Media Library
public function registerMediaCollections(): void
{
$this->addMediaCollection('leads');
}
}