Enth\u00e4lt gemischt: Laravel-10-Upgrade + Phase 1 (Contacts-Modul, Duplicats-Commands, Soft-Delete+Merge-Fields) + Phase 2 Code-Umstellungen (inquiry_id, $table='contacts'/'inquiries') + Offers-Modul (Migrationen, Models, offer_id in Booking, offer-Disk in filesystems.php). Phase 2 + Offers werden im folgenden Commit nach dev/backups/phase2-offers-2026-04-17/ verschoben, damit der Workspace auf Phase-1-only (= Test-System-Stand) reduziert ist und direkt auf Live deploybar wird. Tarball-Backup zus\u00e4tzlich unter: ../backups-safety/workspace-pre-phase1-rollback-2026-04-17.tar.gz Made-with: Cursor
212 lines
6.8 KiB
PHP
212 lines
6.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class CustomerMail
|
|
*
|
|
* @property int $id
|
|
* @property int $booking_id
|
|
* @property int $customer_id
|
|
* @property int $lead_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 $travel_country_id
|
|
* @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 Booking $booking
|
|
* @property Customer $customer
|
|
* @property CustomerMail $customer_mail
|
|
* @property TravelCountry $travel_country
|
|
* @property Lead $lead
|
|
* @property Collection|CustomerFile[] $customer_files
|
|
* @property Collection|CustomerMail[] $customer_mails
|
|
* @package App\Models
|
|
* @property-read int|null $customer_files_count
|
|
* @property-read int|null $customer_mails_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereBcc($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereBookingId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCc($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCustomerId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereDeliveredAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereDir($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereDraft($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereEmail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereError($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereFail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereImportant($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereIsAnswer($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereLeadId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereMessage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereRecipient($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereReplyId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereScheduledAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSend($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSentAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubject($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereTravelCountryId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereUpdatedAt($value)
|
|
* @property int|null $subdir
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubdir($value)
|
|
* @property array|null $forward
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereForward($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class CustomerMail extends Model
|
|
{
|
|
protected $table = 'customer_mails';
|
|
|
|
public $dir_types = [
|
|
0 => 'Reisender',
|
|
1 => 'Agentur',
|
|
2 => 'Flug',
|
|
3 => 'Versicherung',
|
|
11 => 'Entwurf',
|
|
12 => 'Papierkorb',
|
|
];
|
|
|
|
protected $casts = [
|
|
'booking_id' => 'int',
|
|
'customer_id' => 'int',
|
|
'lead_id' => 'int',
|
|
'is_answer' => 'bool',
|
|
'reply_id' => 'int',
|
|
'dir' => 'int',
|
|
'subdir' => 'int',
|
|
'travel_country_id' => 'int',
|
|
'draft' => 'bool',
|
|
'important' => 'bool',
|
|
'send' => 'bool',
|
|
'fail' => 'bool',
|
|
'recipient' => 'array',
|
|
'forward' => 'array',
|
|
'cc' => 'array',
|
|
'bcc' => 'array',
|
|
'sent_at' => 'datetime',
|
|
'scheduled_at' => 'datetime',
|
|
'delivered_at' => 'datetime',
|
|
];
|
|
|
|
|
|
protected $fillable = [
|
|
'booking_id',
|
|
'customer_id',
|
|
'lead_id',
|
|
'is_answer',
|
|
'reply_id',
|
|
'email',
|
|
'recipient',
|
|
'cc',
|
|
'bcc',
|
|
'subject',
|
|
'message',
|
|
'dir',
|
|
'subdir',
|
|
'travel_country_id',
|
|
'draft',
|
|
'important',
|
|
'send',
|
|
'fail',
|
|
'error',
|
|
'forward',
|
|
'sent_at',
|
|
'scheduled_at',
|
|
'delivered_at'
|
|
];
|
|
|
|
public function booking()
|
|
{
|
|
return $this->belongsTo(Booking::class);
|
|
}
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function customer_mail()
|
|
{
|
|
return $this->belongsTo(CustomerMail::class, 'reply_id');
|
|
}
|
|
|
|
public function travel_country()
|
|
{
|
|
return $this->belongsTo(TravelCountry::class);
|
|
}
|
|
|
|
public function lead()
|
|
{
|
|
return $this->belongsTo(Lead::class);
|
|
}
|
|
|
|
public function customer_files()
|
|
{
|
|
return $this->hasMany(CustomerFile::class);
|
|
}
|
|
|
|
public function customer_mails()
|
|
{
|
|
return $this->hasMany(CustomerMail::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 customer_mail_deep($deep = 0){
|
|
|
|
if($this->customer_mail){
|
|
$deep = $this->customer_mail->customer_mail_deep(++$deep);
|
|
}
|
|
return $deep;
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
}
|