Feature: Creating Shipment migration and model

This commit is contained in:
2026-07-16 17:14:23 +03:00
parent 4c00369005
commit e18b2fa44c
2 changed files with 53 additions and 0 deletions
@@ -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');
}
};
+24
View File
@@ -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);
}
}