124ab46507
- Create migration to add shipping_street_address, shipping_local_area, shipping_city, shipping_zone, shipping_country, shipping_postcode, shipping_type - Update Order model fillable array with new address component fields - Remove address parsing logic from CourierService - Use individual address fields directly in ShipLogic API payload - Fields match ShipLogic API requirements (street_address, local_area, city, zone, code, country, type) - Note: Custom orders address collection can be implemented later
88 lines
2.0 KiB
PHP
88 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
|
|
class Order extends Model
|
|
{
|
|
use HasUuids;
|
|
|
|
protected $primaryKey = 'uuid';
|
|
protected $keyType = 'string';
|
|
public $incrementing = false;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'order_number',
|
|
'total',
|
|
'shipping_fee',
|
|
'invoice_path',
|
|
'status',
|
|
'payment_method',
|
|
'payment_status',
|
|
'customer_name',
|
|
'customer_email',
|
|
'customer_phone',
|
|
'shipping_address',
|
|
'shipping_street_address',
|
|
'shipping_local_area',
|
|
'shipping_city',
|
|
'shipping_zone',
|
|
'shipping_country',
|
|
'shipping_postcode',
|
|
'shipping_type',
|
|
'notes',
|
|
'yoco_checkout_id',
|
|
'yoco_redirect_url',
|
|
'yoco_checkout_response',
|
|
'yoco_payment_id',
|
|
'packing_width',
|
|
'packing_length',
|
|
'packing_weight',
|
|
'packing_completed_at',
|
|
'packed_by',
|
|
'courier_waybill_id',
|
|
'courier_tracking_number',
|
|
'courier_status',
|
|
'delivered_at',
|
|
'delivery_failure_reason',
|
|
'trello_card_id',
|
|
'qr_token',
|
|
'qr_generated_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'packing_completed_at' => 'datetime',
|
|
'delivered_at' => 'datetime',
|
|
'qr_generated_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany(OrderItem::class, 'order_id', 'uuid');
|
|
}
|
|
|
|
public function packedBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'packed_by');
|
|
}
|
|
|
|
/**
|
|
* Check if this is a custom order
|
|
*/
|
|
public function isCustomOrder(): bool
|
|
{
|
|
return false; // Standard orders are not custom
|
|
}} |