243 lines
7.8 KiB
PHP
243 lines
7.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Reliese\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class Lead
|
|
*
|
|
* @property int $id
|
|
* @property int $customer_id
|
|
* @property Carbon $request_date
|
|
* @property Carbon $travelperiod_start
|
|
* @property Carbon $travelperiod_end
|
|
* @property int $travelperiod_length
|
|
* @property int $travelcountry_id
|
|
* @property int $travelagenda_id
|
|
* @property string $remarks
|
|
* @property int $sf_guard_user_id
|
|
* @property bool $is_closed
|
|
* @property int $initialcontacttype_id
|
|
* @property int $searchengine_id
|
|
* @property string $searchengine_keywords
|
|
* @property int $status_id
|
|
* @property Carbon $next_due_date
|
|
* @property int $website_id
|
|
* @property int $travelcategory_id
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property float $price
|
|
* @property int $pax
|
|
* @property string $participant_name
|
|
* @property string $participant_firstname
|
|
* @property Carbon $participant_birthdate
|
|
* @property int $participant_salutation_id
|
|
* @property Customer $customer
|
|
* @property InitialContactType $initial_contact_type
|
|
* @property Salutation $salutation
|
|
* @property Searchengine $searchengine
|
|
* @property SfGuardUser $sf_guard_user
|
|
* @property Status $status
|
|
* @property TravelAgenda $travel_agenda
|
|
* @property TravelCategory $travel_category
|
|
* @property TravelCountry $travel_country
|
|
* @property Website $website
|
|
* @property Collection|Booking[] $bookings
|
|
* @property Collection|Inquiry[] $inquiries
|
|
* @property Collection|LeadParticipant[] $lead_participants
|
|
* @property Collection|Offer[] $offers
|
|
* @property Collection|StatusHistory[] $status_histories
|
|
* @package App\Models
|
|
* @property-read int|null $bookings_count
|
|
* @property-read int|null $inquiries_count
|
|
* @property-read int|null $lead_participants_count
|
|
* @property-read int|null $offers_count
|
|
* @property-read int|null $status_histories_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereCustomerId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereInitialcontacttypeId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereIsClosed($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereNextDueDate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereParticipantBirthdate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereParticipantFirstname($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereParticipantName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereParticipantSalutationId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead wherePax($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead wherePrice($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereRemarks($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereRequestDate($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereSearchengineId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereSearchengineKeywords($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereSfGuardUserId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereStatusId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereTravelagendaId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereTravelcategoryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereTravelcountryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereTravelperiodEnd($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereTravelperiodLength($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereTravelperiodStart($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Lead whereWebsiteId($value)
|
|
* @mixin \Eloquent
|
|
* @property-read \App\Models\Sym\TravelCountry|null $travel_country_crm
|
|
*/
|
|
class Lead extends Model
|
|
{
|
|
protected $connection = 'mysql';
|
|
|
|
protected $table = 'lead';
|
|
|
|
protected $casts = [
|
|
'customer_id' => 'int',
|
|
'travelperiod_length' => 'int',
|
|
'travelcountry_id' => 'int',
|
|
'travelagenda_id' => 'int',
|
|
'sf_guard_user_id' => 'int',
|
|
'is_closed' => 'bool',
|
|
'initialcontacttype_id' => 'int',
|
|
'searchengine_id' => 'int',
|
|
'status_id' => 'int',
|
|
'website_id' => 'int',
|
|
'travelcategory_id' => 'int',
|
|
'price' => 'float',
|
|
'pax' => 'int',
|
|
'participant_salutation_id' => 'int'
|
|
];
|
|
|
|
protected $dates = [
|
|
'request_date',
|
|
'travelperiod_start',
|
|
'travelperiod_end',
|
|
'next_due_date',
|
|
'participant_birthdate'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'customer_id',
|
|
'request_date',
|
|
'travelperiod_start',
|
|
'travelperiod_end',
|
|
'travelperiod_length',
|
|
'travelcountry_id',
|
|
'travelagenda_id',
|
|
'remarks',
|
|
'sf_guard_user_id',
|
|
'is_closed',
|
|
'initialcontacttype_id',
|
|
'searchengine_id',
|
|
'searchengine_keywords',
|
|
'status_id',
|
|
'next_due_date',
|
|
'website_id',
|
|
'travelcategory_id',
|
|
'price',
|
|
'pax',
|
|
'participant_name',
|
|
'participant_firstname',
|
|
'participant_birthdate',
|
|
'participant_salutation_id'
|
|
];
|
|
|
|
public function updateNextDueDate($date = false){
|
|
|
|
if(!$date){
|
|
$carbon = Carbon::now();
|
|
$this->next_due_date = $carbon->modify('+ '.$this->status->handling_days.' days')->format("Y-m-d");
|
|
$this->save();
|
|
}
|
|
}
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function initial_contact_type()
|
|
{
|
|
return $this->belongsTo(InitialContactType::class, 'initialcontacttype_id');
|
|
}
|
|
|
|
public function salutation()
|
|
{
|
|
return $this->belongsTo(Salutation::class, 'participant_salutation_id');
|
|
}
|
|
|
|
public function searchengine()
|
|
{
|
|
return $this->belongsTo(Searchengine::class);
|
|
}
|
|
|
|
public function sf_guard_user()
|
|
{
|
|
return $this->belongsTo(SfGuardUser::class);
|
|
}
|
|
|
|
public function status()
|
|
{
|
|
return $this->belongsTo(Status::class);
|
|
}
|
|
|
|
public function travel_agenda()
|
|
{
|
|
return $this->belongsTo(TravelAgenda::class, 'travelagenda_id');
|
|
}
|
|
|
|
public function travel_category()
|
|
{
|
|
return $this->belongsTo(TravelCategory::class, 'travelcategory_id');
|
|
}
|
|
|
|
//on crm
|
|
public function travel_country_crm()
|
|
{
|
|
return $this->belongsTo('App\Models\Sym\TravelCountry', 'travelcountry_id', 'id');
|
|
}
|
|
|
|
|
|
//on stern other DB
|
|
public function travel_country()
|
|
{
|
|
return $this->belongsTo('App\Models\TravelCountry', 'travelcountry_id', 'crm_id');
|
|
}
|
|
|
|
|
|
public function website()
|
|
{
|
|
return $this->belongsTo(Website::class);
|
|
}
|
|
|
|
public function bookings()
|
|
{
|
|
return $this->hasMany(Booking::class);
|
|
}
|
|
|
|
public function inquiries()
|
|
{
|
|
return $this->hasMany(Inquiry::class);
|
|
}
|
|
|
|
public function lead_participants()
|
|
{
|
|
return $this->hasMany(LeadParticipant::class);
|
|
}
|
|
|
|
public function offers()
|
|
{
|
|
return $this->hasMany(Offer::class);
|
|
}
|
|
|
|
public function status_histories()
|
|
{
|
|
return $this->hasMany(StatusHistory::class);
|
|
}
|
|
}
|