File: //var/www/html/owlcrm/app/Models/Lead.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 Lead extends Model implements HasMedia
{
use InteractsWithMedia;
use SoftDeletes;
protected $table = 'leads';
use HasFactory;
protected $fillable = [
'title',
'lead_source',
'assigned_to',
'customer_id',
'salutation',
'first_name',
'last_name',
'gender',
'property_interest_type',
'is_organization',
'organization_name',
'tags',
'designation',
'budget',
'email_address',
'website',
'phone',
'mobile_number',
'description',
'last_contacted',
'next_followup',
'address_line_1',
'address_line_2',
'country',
'state',
'city',
'postal_code',
'status',
'type',
'user_id',
];
const post_status = [
0 => '--Select--',
'documentation' => 'Documentation',
'payment-processing' => 'PaymentProcessing',
'handover-preparation' => 'HandoverPreparation',
'final-handover' => 'FinalHandover',
];
const lead_status = [
0 => '--Select--',
'new-lead' => 'NewLead',
'hot-lead' => 'HotLead',
'cold-lead' => 'ColdLead',
'documentation' => 'Documentation',
];
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',
];
const NewLead = 'new-lead';
const HotLead = 'hot-lead';
const ColdLead = 'cold-lead';
const Documentation= 'documentation';
const FinalHandover = 'final-handover';
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 get_customer()
{
return $this->belongsTo(Customer::class, 'customer_id', 'id');
}
public function registerMediaCollections(): void
{
$this->addMediaCollection('leads');
}
}