'int', 'customer_id' => 'int', 'lead_id' => 'int', 'size' => 'int', 'data' => 'object', 'status' => 'int', 'booking_storno_id' => 'int', 'coupon_id' => 'int', 'date' => 'datetime', ]; 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; } } }