Initial commit
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'order_number',
|
||||
'customer_name',
|
||||
'customer_email',
|
||||
'customer_phone',
|
||||
'shipping_street',
|
||||
'shipping_number',
|
||||
'shipping_postal_code',
|
||||
'shipping_city',
|
||||
'shipping_country',
|
||||
'notes',
|
||||
'status',
|
||||
'subtotal',
|
||||
'shipping_cost',
|
||||
'total',
|
||||
'payment_status',
|
||||
'payment_method',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'subtotal' => 'float',
|
||||
'shipping_cost' => 'float',
|
||||
'total' => 'float',
|
||||
];
|
||||
|
||||
public function items(): HasMany
|
||||
{
|
||||
return $this->hasMany(OrderItem::class);
|
||||
}
|
||||
|
||||
public function getFormattedTotalAttribute(): string
|
||||
{
|
||||
return '€ ' . number_format($this->total, 2, ',', '.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user