feat: Update Order/CustomOrder models and controllers with event integration
- Add integration fields to Order model: packing_*, courier_*, trello_card_id, qr_token
- Add integration fields to CustomOrder model: packing_*, proof_approved_*, courier_*, trello_card_id, qr_token
- Update Order model fillable array and add relationships (packedBy)
- Update CustomOrder model fillable array, casts, and add relationships (packedBy)
- Add isCustomOrder() method to both models for type checking
- Update OrderController to emit OrderCreated and DepositPaid events on successful payment
- For standard orders: full payment -> prep status, emit events
- For custom orders: deposit -> design status, balance -> printing status, emit respective events
- Add approveProof() method to CustomOrderController (POST /custom-orders/{id}/approve-proof)
- Add requestChanges() method to CustomOrderController (POST /custom-orders/{id}/request-changes)
- Add markBalancePaid() method to CustomOrderController (POST /custom-orders/{id}/pay-balance)
- All new methods emit appropriate events (ProofApproved, ProofRevisionRequested, BalancePaid)
- Add database migration for proof_approved and proof_approved_at fields on custom_orders
- Add routes for new custom order endpoints with UUID binding
- Import all required event classes in both controllers
This commit is contained in:
+26
-1
@@ -31,6 +31,19 @@ class Order extends Model
|
||||
'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',
|
||||
];
|
||||
|
||||
public function user()
|
||||
@@ -42,4 +55,16 @@ class Order extends Model
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user