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
168 lines
5.2 KiB
PHP
168 lines
5.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class LeadMail
|
|
*
|
|
* @property int $id
|
|
* @property int $lead_id
|
|
* @property int $customer_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 string $forward
|
|
* @property Carbon $sent_at
|
|
* @property Carbon $scheduled_at
|
|
* @property Carbon $delivered_at
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property Customer $customer
|
|
* @property Lead $lead
|
|
* @property CustomerMail $customer_mail
|
|
* @property Collection|LeadFile[] $lead_files
|
|
* @package App\Models
|
|
* @property-read int|null $lead_files_count
|
|
* @property-read LeadMail|null $lead_mail
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereBcc($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereCc($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereCustomerId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereDeliveredAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereDir($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereDraft($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereEmail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereError($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereFail($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereForward($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereImportant($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereIsAnswer($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereLeadId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereMessage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereRecipient($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereReplyId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereScheduledAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereSend($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereSentAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereSubdir($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereSubject($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|LeadMail whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class LeadMail extends Model
|
|
{
|
|
protected $table = 'lead_mails';
|
|
|
|
protected $casts = [
|
|
'lead_id' => 'int',
|
|
'customer_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',
|
|
'sent_at' => 'datetime',
|
|
'scheduled_at' => 'datetime',
|
|
'delivered_at' => 'datetime',
|
|
];
|
|
|
|
|
|
protected $fillable = [
|
|
'lead_id',
|
|
'customer_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'
|
|
];
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function lead()
|
|
{
|
|
return $this->belongsTo(Lead::class);
|
|
}
|
|
|
|
public function lead_mail()
|
|
{
|
|
return $this->belongsTo(LeadMail::class, 'reply_id');
|
|
}
|
|
|
|
public function lead_files()
|
|
{
|
|
return $this->hasMany(LeadFile::class);
|
|
}
|
|
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();
|
|
}
|
|
}
|
|
}
|