export für Bestellungen, Skript für Queue
This commit is contained in:
parent
b13e5e66ce
commit
abaf17eb0a
41
app/Filament/Exports/OrderExporter.php
Normal file
41
app/Filament/Exports/OrderExporter.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
|
use App\Models\Order;
|
||||||
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
|
use Filament\Actions\Exports\Exporter;
|
||||||
|
use Filament\Actions\Exports\Models\Export;
|
||||||
|
use Illuminate\Support\Number;
|
||||||
|
|
||||||
|
class OrderExporter extends Exporter
|
||||||
|
{
|
||||||
|
protected static ?string $model = Order::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ExportColumn::make('id')
|
||||||
|
->label('ID'),
|
||||||
|
ExportColumn::make('created_at')->label('Erstallungsdatum'),
|
||||||
|
ExportColumn::make('updated_at')->label('Letzte Veränderung'),
|
||||||
|
ExportColumn::make('name')->label('Name'),
|
||||||
|
ExportColumn::make('url')->label('URL'),
|
||||||
|
ExportColumn::make('count')->label('Anzahl'),
|
||||||
|
ExportColumn::make('orderstatus.name')->label('Bestellstatus'),
|
||||||
|
ExportColumn::make('orderdatetime')->label('Bestelldatum'),
|
||||||
|
ExportColumn::make('user.name')->label('Bestellt von'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
|
{
|
||||||
|
$body = 'Your order export has completed and ' . Number::format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . Number::format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Orders\Pages;
|
namespace App\Filament\Resources\Orders\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Exports\OrderExporter;
|
||||||
use App\Filament\Resources\Orders\OrderResource;
|
use App\Filament\Resources\Orders\OrderResource;
|
||||||
use Filament\Actions\CreateAction;
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Actions\ExportAction;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListOrders extends ListRecords
|
class ListOrders extends ListRecords
|
||||||
@ -14,6 +16,7 @@ class ListOrders extends ListRecords
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
CreateAction::make(),
|
CreateAction::make(),
|
||||||
|
ExportAction::make()->label('exportieren')->exporter(OrderExporter::class)->enableVisibleTableColumnsByDefault()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
->login()
|
->login()
|
||||||
->spa()
|
->spa()
|
||||||
->unsavedChangesAlerts()
|
->unsavedChangesAlerts()
|
||||||
|
->databaseNotifications()
|
||||||
->profile()
|
->profile()
|
||||||
->passwordReset()
|
->passwordReset()
|
||||||
->colors([
|
->colors([
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?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::create('notifications', function (Blueprint $table) {
|
||||||
|
$table->uuid('id')->primary();
|
||||||
|
$table->string('type');
|
||||||
|
$table->morphs('notifiable');
|
||||||
|
$table->text('data');
|
||||||
|
$table->timestamp('read_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('notifications');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
<?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::create('imports', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('completed_at')->nullable();
|
||||||
|
$table->string('file_name');
|
||||||
|
$table->string('file_path');
|
||||||
|
$table->string('importer');
|
||||||
|
$table->unsignedInteger('processed_rows')->default(0);
|
||||||
|
$table->unsignedInteger('total_rows');
|
||||||
|
$table->unsignedInteger('successful_rows')->default(0);
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('imports');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
<?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::create('exports', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('completed_at')->nullable();
|
||||||
|
$table->string('file_disk');
|
||||||
|
$table->string('file_name')->nullable();
|
||||||
|
$table->string('exporter');
|
||||||
|
$table->unsignedInteger('processed_rows')->default(0);
|
||||||
|
$table->unsignedInteger('total_rows');
|
||||||
|
$table->unsignedInteger('successful_rows')->default(0);
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('exports');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?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::create('failed_import_rows', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->json('data');
|
||||||
|
$table->foreignId('import_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->text('validation_error')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('failed_import_rows');
|
||||||
|
}
|
||||||
|
};
|
||||||
2
run_queue.sh
Executable file
2
run_queue.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#//bin/sh
|
||||||
|
/usr/bin/php artisan queue:work --stop-when-empty --silent
|
||||||
Loading…
Reference in New Issue
Block a user