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
125 lines
4.2 KiB
PHP
125 lines
4.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class CustomerFewoFile
|
|
*
|
|
* @property int $id
|
|
* @property int $travel_user_id
|
|
* @property int $customer_fewo_mail_id
|
|
* @property string $identifier
|
|
* @property string $filename
|
|
* @property string $dir
|
|
* @property string $original_name
|
|
* @property string $ext
|
|
* @property string $mine
|
|
* @property int $size
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property CustomerFewoMail $customer_fewo_mail
|
|
* @property TravelUser $travel_user
|
|
* @package App\Models
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereCustomerFewoMailId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereDir($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereExt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereFilename($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereIdentifier($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereMine($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereOriginalName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereSize($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereTravelUserId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereUpdatedAt($value)
|
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoFile onlyTrashed()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereDeletedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoFile withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoFile withoutTrashed()
|
|
* @mixin \Eloquent
|
|
*/
|
|
class CustomerFewoFile extends Model
|
|
{
|
|
use \Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
protected $connection = 'mysql_stern';
|
|
|
|
protected $table = 'customer_fewo_files';
|
|
|
|
protected $casts = [
|
|
'travel_user_id' => 'int',
|
|
'customer_fewo_mail_id' => 'int',
|
|
'size' => 'int',
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
'travel_user_id',
|
|
'customer_fewo_mail_id',
|
|
'identifier',
|
|
'filename',
|
|
'dir',
|
|
'original_name',
|
|
'ext',
|
|
'mine',
|
|
'size'
|
|
];
|
|
|
|
public static $icon_ext = [
|
|
'default' => 'fa fa-file',
|
|
'pdf'=> 'fa fa-file-pdf',
|
|
'jpg'=> 'fa fa-file-image',
|
|
'png'=> 'fa fa-file-image',
|
|
];
|
|
|
|
public function customer_fewo_mail()
|
|
{
|
|
return $this->belongsTo(CustomerFewoMail::class);
|
|
}
|
|
|
|
public function travel_user()
|
|
{
|
|
return $this->belongsTo(TravelUser::class);
|
|
}
|
|
|
|
public function getIconExt(){
|
|
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
|
}
|
|
|
|
public function getURL($do=false){
|
|
return route('storage_file', [$this->id, 'travel_user', $do]);
|
|
}
|
|
|
|
public function getPath(){
|
|
return \Storage::disk('travel_user')->path($this->dir.$this->filename);
|
|
|
|
}
|
|
|
|
public function formatBytes($precision = 2)
|
|
{
|
|
$size = $this->size;
|
|
|
|
if ($size > 0) {
|
|
$size = (int) $size;
|
|
$base = log($size) / log(1024);
|
|
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
|
|
|
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
|
} else {
|
|
return $size;
|
|
}
|
|
}
|
|
}
|