Skip to content

Commit

Permalink
Add shipping date to orders with migration and resource updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tobifra committed Nov 5, 2024
1 parent 07d1c47 commit 2f7fa8b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/app/Filament/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public static function form(Form $form): Form
->label('Zu bezahlen')
->required()
->numeric(),
Forms\Components\DatePicker::make('shipping_date')
->label('Versanddatum'),
]);
}

Expand Down Expand Up @@ -113,6 +115,10 @@ public static function table(Table $table): Table
->numeric()
->sortable()
->formatStateUsing(fn ($state) => 'CHF ' . $state),
Tables\Columns\TextColumn::make('shipping_date')
->label('Versanddatum')
->date('d.m.Y')
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
Expand Down
1 change: 1 addition & 0 deletions api/app/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ class Order extends Model
'delivery_town',
'amount',
'quantity',
'shipping_date',
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('orders', function (Blueprint $table) {
$table->date('shipping_date')->nullable()->after('amount');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn('shipping_date');
});
}
};

0 comments on commit 2f7fa8b

Please sign in to comment.