'int', 'month' => 'int', 'year' => 'int', 'number' => 'int', 'paid' => 'bool', 'cancellation' => 'bool', 'cancellation_id' => 'int', 'status' => 'int', 'infos' => 'array', ]; protected $dates = [ 'date', 'paid_date', 'cancellation_date' ]; protected $fillable = [ 'shopping_order_id', 'month', 'year', 'date', 'full_number', 'number', 'filename', 'dir', 'delivery_filename', 'delivery_dir', 'disk', 'infos', 'paid', 'paid_date', 'cancellation', 'cancellation_id', 'cancellation_date', 'status' ]; public static $monthNames = [ 1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember' ]; public static $statusTypes = [ 0 => '-', 1 => 'Bestellung', 2 => 'Shop', 11 => 'storniert B.', 12 => 'storniert Shop', ]; public static $statusColors = [ 0 => 'warning', 1 => 'success', 2 => 'secondary', 11 => 'danger', 12 => 'danger', ]; public function shopping_order(){ return $this->belongsTo(ShoppingOrder::class); } public function getDateAttribute($value){ return $this->attributes['date'] ? Carbon::parse($this->attributes['date'])->format(\Util::formatDateDB()) : ''; } public function setDateAttribute( $value ) { $this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL; } public function getDateRaw(){ return isset($this->attributes['date']) ? $this->attributes['date'] : NULL; } public function getPaidDateAttribute($value){ return $this->attributes['paid_date'] ? Carbon::parse($this->attributes['paid_date'])->format(\Util::formatDateDB()) : ''; } public function setPaidDateAttribute( $value ) { $this->attributes['paid_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL; } public function getPaidDateRaw(){ return isset($this->attributes['paid_date']) ? $this->attributes['paid_date'] : NULL; } public function getCancellationDateAttribute($value){ return $this->attributes['cancellation_date'] ? Carbon::parse($this->attributes['cancellation_date'])->format(\Util::formatDateDB()) : ''; } public function setCancellationDateAttribute( $value ) { $this->attributes['cancellation_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL; } public function getCancellationDateRaw(){ return isset($this->attributes['cancellation_date']) ? $this->attributes['cancellation_date'] : NULL; } public static function getMonthName($month) { return isset(self::$monthNames[$month]) ? self::$monthNames[$month] : $month; } public function getStatusType(){ return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : ""; } public function getStatusColor(){ return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default"; } public function getDownloadPath($full = false){ if(!$full){ return $this->dir.$this->filename; } return \Storage::disk($this->disk)->path($this->dir.$this->filename); } public function getDownloadPathDelivery($full = false){ if(!$full){ return $this->delivery_dir.$this->delivery_filename; } return \Storage::disk($this->disk)->path($this->delivery_dir.$this->delivery_filename); } }