08 2024
This commit is contained in:
parent
c1c613a4b9
commit
881fc84207
384 changed files with 50679 additions and 990 deletions
134
app/Models/BookingDocument.php
Normal file
134
app/Models/BookingDocument.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BookingDocument
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $booking_id
|
||||
* @property int|null $customer_id
|
||||
* @property int|null $lead_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 $date
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Booking|null $booking
|
||||
* @property Customer|null $customer
|
||||
* @property Lead|null $lead
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class BookingDocument extends Model
|
||||
{
|
||||
protected $table = 'booking_documents';
|
||||
|
||||
protected $casts = [
|
||||
'booking_id' => 'int',
|
||||
'customer_id' => 'int',
|
||||
'lead_id' => 'int',
|
||||
'size' => 'int',
|
||||
'data' => 'object',
|
||||
'status' => 'int',
|
||||
'booking_storno_id' => 'int',
|
||||
'coupon_id' => 'int',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'booking_id',
|
||||
'customer_id',
|
||||
'lead_id',
|
||||
'coupon_id',
|
||||
'booking_storno_id', //
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size',
|
||||
'date',
|
||||
'data',
|
||||
'status'
|
||||
];
|
||||
/* Je nach identifier können verschiebene stati gesetzt werden
|
||||
coupon 0 = nicht eingelöst 1 = eingelöst
|
||||
*/
|
||||
protected $status_type = [
|
||||
0 => 'offen',
|
||||
1 => 'erledigt',
|
||||
];
|
||||
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
public function lead()
|
||||
{
|
||||
return $this->belongsTo(Lead::class);
|
||||
}
|
||||
|
||||
public function coupon_id()
|
||||
{
|
||||
return $this->belongsTo(Coupon::class);
|
||||
}
|
||||
|
||||
public function booking_storno()
|
||||
{
|
||||
return $this->belongsTo(BookingStorno::class);
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'booking_document', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('public')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function deleteFile(){
|
||||
if(\Storage::disk('public')->exists($this->dir.$this->filename)){
|
||||
\Storage::disk('public')->delete($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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue