Files
Additional/app/Models/Order.php
T
twotalesanimation 2a10f9af38 feat: Complete Shiplogic integration with mobile-optimized ops workflow
**Shiplogic API Integration:**
- Fixed API base URL configuration (removed /api suffix)
- Implemented comprehensive request/response logging for rates and shipments endpoints
- Fixed PDF fetching: API returns S3 URLs, now downloads actual PDFs from S3
- Added tests and mock API responses for local development (routes/shiplogic-mock.php)

**Courier Service Enhancements:**
- Added redownloadShipmentPdfs() public method for re-downloading corrupted PDFs
- Enhanced error logging with full request/response bodies for debugging
- Proper binary PDF storage using Laravel Storage facade
- URL and S3 download handling for Shiplogic API responses

**Workflow & Operations:**
- Changed to manual "Ready for Collection" button instead of automatic move
- Operators now: scan QR → apply labels → click "Ready for Collection" → moves to Awaiting Collection
- Removed duplicate PDF attachments to Trello (was adding twice from two listeners)
- Fixed NotifySlackOnShipmentCreated to only handle Slack notifications

**Mobile-Optimized Ops Page:**
- Removed QR code display from order detail page
- Implemented responsive single-column layout for mobile phones
- Large touch-friendly buttons (full width, increased padding)
- Bold typography for better readability on small screens
- Larger input fields and tracking number displays
- Clear step-by-step instructions for warehouse operators
- Re-download PDF button for damaged/corrupted labels

**New Features:**
- POST /ops/orders/{uuid}/ready-for-collection endpoint
- Re-download PDFs functionality accessible from awaiting_collection and in_transit states
- Full audit logging for all operations via ops interface
- Proper error handling and user feedback

**Testing:**
- Added ShipmentCreationTest with mock HTTP client
- Created comprehensive testing guide (SHIPLOGIC_TESTING.md)
- Mock API routes for local development without hitting live API
2026-01-03 16:13:20 +02:00

99 lines
2.4 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_unit_number',
'shipping_local_area',
'shipping_city',
'shipping_zone',
'shipping_country',
'shipping_postcode',
'shipping_type',
'business_name',
'notes',
'yoco_checkout_id',
'yoco_redirect_url',
'yoco_checkout_response',
'yoco_payment_id',
'packing_width',
'packing_length',
'packing_height',
'packing_weight',
'packing_completed_at',
'packed_by',
'courier_shipment_id',
'courier_waybill_id',
'courier_tracking_number',
'courier_status',
'courier_rate',
'courier_service_level_code',
'courier_service_level_id',
'courier_collection_min_date',
'courier_delivery_min_date',
'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',
'courier_collection_min_date' => 'datetime',
'courier_delivery_min_date' => '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
}}