220 lines
7.6 KiB
PHP
220 lines
7.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class CustomerFewoMail
|
|
*
|
|
* @property int $id
|
|
* @property int $travel_user_booking_fewo_id
|
|
* @property int $travel_user_id
|
|
* @property bool $is_answer
|
|
* @property int $reply_id
|
|
* @property string $email
|
|
* @property string $recipient
|
|
* @property string $cc
|
|
* @property string $bcc
|
|
* @property string $subject
|
|
* @property string $message
|
|
* @property int $dir
|
|
* @property int $subdir
|
|
* @property bool $draft
|
|
* @property bool $important
|
|
* @property bool $send
|
|
* @property bool $fail
|
|
* @property string $error
|
|
* @property Carbon $sent_at
|
|
* @property Carbon $scheduled_at
|
|
* @property Carbon $delivered_at
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property CustomerFewoMail $customer_fewo_mail
|
|
* @property TravelUserBookingFewo $travel_user_booking_fewo
|
|
* @property TravelUser $travel_user
|
|
* @property Collection|CustomerFewoFile[] $customer_fewo_files
|
|
* @property Collection|CustomerFewoMail[] $customer_fewo_mails
|
|
* @package App\Models
|
|
* @property-read int|null $customer_fewo_files_count
|
|
* @property-read int|null $customer_fewo_mails_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereBcc($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereCc($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDeliveredAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDir($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDraft($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereEmail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereError($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereFail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereImportant($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereIsAnswer($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereMessage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereRecipient($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereReplyId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereScheduledAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSend($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSentAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSubdir($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSubject($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereTravelUserBookingFewoId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereTravelUserId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
* @property-read \App\Models\TravelUserBookingFewo $booking
|
|
* @property-read \App\Models\TravelUser $customer
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoFile[] $customer_files
|
|
* @property-read int|null $customer_files_count
|
|
* @property-read \App\Models\CustomerFewoMail|null $customer_mail
|
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail onlyTrashed()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDeletedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail withoutTrashed()
|
|
*/
|
|
class CustomerFewoMail extends Model
|
|
{
|
|
use \Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
protected $connection = 'mysql_stern';
|
|
|
|
protected $table = 'customer_fewo_mails';
|
|
|
|
protected $casts = [
|
|
'travel_user_booking_fewo_id' => 'int',
|
|
'travel_user_id' => 'int',
|
|
'is_answer' => 'bool',
|
|
'reply_id' => 'int',
|
|
'dir' => 'int',
|
|
'subdir' => 'int',
|
|
'draft' => 'bool',
|
|
'important' => 'bool',
|
|
'send' => 'bool',
|
|
'fail' => 'bool',
|
|
'recipient' => 'array',
|
|
'forward' => 'array',
|
|
'cc' => 'array',
|
|
'bcc' => 'array'
|
|
];
|
|
|
|
protected $dates = [
|
|
'sent_at',
|
|
'scheduled_at',
|
|
'delivered_at',
|
|
'deleted_at'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'travel_user_booking_fewo_id',
|
|
'travel_user_id',
|
|
'is_answer',
|
|
'reply_id',
|
|
'email',
|
|
'recipient',
|
|
'cc',
|
|
'bcc',
|
|
'subject',
|
|
'message',
|
|
'dir',
|
|
'subdir',
|
|
'draft',
|
|
'important',
|
|
'send',
|
|
'fail',
|
|
'error',
|
|
'forward',
|
|
'sent_at',
|
|
'scheduled_at',
|
|
'delivered_at'
|
|
];
|
|
|
|
protected static function boot() {
|
|
parent::boot();
|
|
static::deleting(function($model) {
|
|
foreach ($model->customer_fewo_files as $relation)
|
|
{
|
|
$relation->delete();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function customer_fewo_mail()
|
|
{
|
|
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');
|
|
}
|
|
|
|
public function customer_mail()
|
|
{
|
|
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');
|
|
}
|
|
|
|
public function travel_user_booking_fewo()
|
|
{
|
|
return $this->belongsTo(TravelUserBookingFewo::class);
|
|
}
|
|
|
|
public function booking()
|
|
{
|
|
return $this->belongsTo(TravelUserBookingFewo::class);
|
|
}
|
|
|
|
public function travel_user()
|
|
{
|
|
return $this->belongsTo(TravelUser::class);
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(TravelUser::class, 'travel_user_id');
|
|
}
|
|
|
|
public function customer_fewo_files()
|
|
{
|
|
return $this->hasMany(CustomerFewoFile::class);
|
|
}
|
|
|
|
public function customer_files()
|
|
{
|
|
return $this->hasMany(CustomerFewoFile::class, 'customer_fewo_mail_id');
|
|
}
|
|
|
|
public function customer_fewo_mails()
|
|
{
|
|
return $this->hasMany(CustomerFewoMail::class, 'reply_id');
|
|
}
|
|
|
|
public function getSentAtRaw(){
|
|
return $this->attributes['sent_at'];
|
|
}
|
|
|
|
public function getSentAtAttribute(){
|
|
if(!$this->attributes['sent_at']){ return ""; }
|
|
return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB());
|
|
}
|
|
|
|
public function getCreatedAtAttribute(){
|
|
if(!$this->attributes['created_at']){ return ""; }
|
|
return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB());
|
|
}
|
|
public function setForwardMessage($forward = [])
|
|
{
|
|
if($forward && is_array($forward)){
|
|
if(isset($this->forward) && $this->forward){
|
|
$this->forward = array_merge($this->forward , $forward);
|
|
}else{
|
|
$this->forward = $forward;
|
|
}
|
|
$this->save();
|
|
}
|
|
}
|
|
}
|