Refactor the pricing calculation service and shipping rate import logic to improve consistency and reliability. This includes updating direction naming conventions, enhancing model casting, and adding comprehensive test suites. - Update `ShippingRatesImport` to use 'outbound' and 'inbound' instead of 'export' and 'import' - Refactor `PriceCalculatorService` to use a more modular calculation structure - Update `ShippingRate` model to use explicit property casting for zones - Add `HasFactory` trait to `Country` and `ShippingRate` models - Add new database factories for `Country` and `ShippingRate` - Implement new feature tests for API endpoints and service logic - Add new service tests for `PriceCalculatorService`
42 lines
808 B
PHP
42 lines
808 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ShippingRate extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'direction',
|
|
'type',
|
|
'weight',
|
|
'zone_1',
|
|
'zone_2',
|
|
'zone_3',
|
|
'zone_4',
|
|
'zone_5',
|
|
'zone_6',
|
|
'zone_7',
|
|
'zone_8',
|
|
'zone_9',
|
|
'zone_10',
|
|
];
|
|
|
|
protected $casts = [
|
|
'weight' => 'float',
|
|
'zone_1' => 'float',
|
|
'zone_2' => 'float',
|
|
'zone_3' => 'float',
|
|
'zone_4' => 'float',
|
|
'zone_5' => 'float',
|
|
'zone_6' => 'float',
|
|
'zone_7' => 'float',
|
|
'zone_8' => 'float',
|
|
'zone_9' => 'float',
|
|
'zone_10' => 'float',
|
|
];
|
|
}
|