Compare commits
2 Commits
v0.3.0
...
08135c4c8f
| Author | SHA1 | Date | |
|---|---|---|---|
| 08135c4c8f | |||
| e18b2fa44c |
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('shipments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('order_id')->constrained(config('lunar.database.table_prefix').'orders');
|
||||
$table->string('carrier');
|
||||
$table->string('tracking_reference')->unique();
|
||||
$table->string('parent_reference')->nullable();
|
||||
$table->timestamp('label_printed_at')->nullable();
|
||||
$table->string('manifest_reference')->nullable();
|
||||
$table->timestamp('cancelled_at')->nullable();
|
||||
$table->json('meta')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shipments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Shipping\Contracts;
|
||||
|
||||
use Lunar\Models\Order;
|
||||
use Modules\Core\Shipping\Models\Shipment;
|
||||
|
||||
interface CarrierFulfillmentInterface
|
||||
{
|
||||
/**
|
||||
* Create a shipment with the carrier for the given order.
|
||||
*/
|
||||
public function createShipment(Order $order, array $overrides = []): Shipment;
|
||||
|
||||
/**
|
||||
* Fetch the printable label for a shipment (raw file bytes).
|
||||
*/
|
||||
public function printLabel(Shipment $shipment): string;
|
||||
|
||||
/**
|
||||
* Cancel a shipment with the carrier.
|
||||
*/
|
||||
public function cancelShipment(Shipment $shipment): void;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Shipping\Contracts;
|
||||
|
||||
/**
|
||||
* Marker for a Lunar\Shipping\Interfaces\ShippingRateInterface driver that
|
||||
* calculates its price from a live carrier API rather than the manually
|
||||
* configured ShippingRate price/price-breaks. Admin UI uses this to hide
|
||||
* the manual pricing fields for such drivers — carriers without a pricing
|
||||
* API simply don't implement it, and manual pricing remains required.
|
||||
*/
|
||||
interface SupportsLivePricing {}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Shipping\Contracts;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Modules\Core\Shipping\DataTransferObjects\ManifestResult;
|
||||
|
||||
/**
|
||||
* Optional capability for carriers that batch shipments into a manifest
|
||||
* before courier pickup (e.g. ACS's end-of-day pickup list). Carriers
|
||||
* without this concept simply don't implement it.
|
||||
*/
|
||||
interface SupportsManifestBatching
|
||||
{
|
||||
/**
|
||||
* Shipments created but not yet included in an issued manifest.
|
||||
*/
|
||||
public function pendingForManifest(): Collection;
|
||||
|
||||
/**
|
||||
* Finalize the given shipments into a manifest with the carrier.
|
||||
*/
|
||||
public function issueManifest(Collection $shipments): ManifestResult;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Shipping\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Lunar\Models\Order;
|
||||
|
||||
class Shipment extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'meta' => AsArrayObject::class,
|
||||
'label_printed_at' => 'datetime',
|
||||
'cancelled_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user