Orderstatus als Model, nicht Enum
This commit is contained in:
parent
20767d392f
commit
267872406d
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Orders\Schemas;
|
||||
|
||||
use App\Orderstatus;
|
||||
use App\Models\Orderstatus;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
@ -25,7 +25,7 @@ class OrderForm
|
||||
->required()
|
||||
->numeric()
|
||||
->default(1),
|
||||
Select::make("orderstatus")->options(Orderstatus::class)->visibleOn(["edit"]),
|
||||
Select::make("orderstatus_id")->relationship("orderstatus", "name")->visibleOn(["edit"]),
|
||||
DateTimePicker::make('orderdatetime')->visibleOn(["edit", "view"]),
|
||||
Select::make('user_id')
|
||||
->relationship("user", "name")
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Orders\Tables;
|
||||
|
||||
use App\Orderstatus;
|
||||
use App\Models\Orderstatus;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
@ -36,7 +36,7 @@ class OrdersTable
|
||||
TextColumn::make('count')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
SelectColumn::make('orderstatus')->options(Orderstatus::class)
|
||||
TextColumn::make('orderstatus.name')
|
||||
->searchable(),
|
||||
TextColumn::make('user.name')
|
||||
->numeric()
|
||||
|
||||
@ -6,11 +6,12 @@ use App\Observers\OrderObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use App\Models\Orderstatus;
|
||||
|
||||
#[ObservedBy([OrderObserver::class])]
|
||||
class Order extends Model
|
||||
{
|
||||
protected $fillable = ["name", "url", "count", "orderstatus", "orderdatetime", "user_id"];
|
||||
protected $fillable = ["name", "url", "count", "orderstatus_id", "orderdatetime", "user_id"];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
@ -22,4 +23,4 @@ class Order extends Model
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ use App\Mail\OrderRegistered;
|
||||
use App\Models\Order;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Models\Orderstatus;
|
||||
|
||||
class OrderObserver
|
||||
{
|
||||
@ -24,9 +25,9 @@ class OrderObserver
|
||||
*/
|
||||
public function updated(Order $order): void
|
||||
{
|
||||
$orderstatusArrived = Orderstatus::find("name", "angekommen")->first();
|
||||
if($order->orderstatus == $orderstatusArrived->id) {
|
||||
$user = $order->usery;
|
||||
$orderstatusArrived = Orderstatus::where("name", "angekommen")->first();
|
||||
if($order->orderstatus_id == $orderstatusArrived->id) {
|
||||
$user = User::find($order->user_id);
|
||||
Mail::to($user)->send(new OrderArrived($order));
|
||||
}
|
||||
}
|
||||
|
||||
120
config/filament.php
Normal file
120
config/filament.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcasting
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By uncommenting the Laravel Echo configuration, you may connect Filament
|
||||
| to any Pusher-compatible websockets server.
|
||||
|
|
||||
| This will allow your users to receive real-time notifications.
|
||||
|
|
||||
*/
|
||||
|
||||
'broadcasting' => [
|
||||
|
||||
// 'echo' => [
|
||||
// 'broadcaster' => 'pusher',
|
||||
// 'key' => env('VITE_PUSHER_APP_KEY'),
|
||||
// 'cluster' => env('VITE_PUSHER_APP_CLUSTER'),
|
||||
// 'wsHost' => env('VITE_PUSHER_HOST'),
|
||||
// 'wsPort' => env('VITE_PUSHER_PORT'),
|
||||
// 'wssPort' => env('VITE_PUSHER_PORT'),
|
||||
// 'authEndpoint' => '/broadcasting/auth',
|
||||
// 'disableStats' => true,
|
||||
// 'encrypted' => true,
|
||||
// 'forceTLS' => true,
|
||||
// ],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the storage disk Filament will use to store files. You may use
|
||||
| any of the disks defined in the `config/filesystems.php`.
|
||||
|
|
||||
*/
|
||||
|
||||
'default_filesystem_disk' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Assets Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the directory where Filament's assets will be published to. It
|
||||
| is relative to the `public` directory of your Laravel application.
|
||||
|
|
||||
| After changing the path, you should run `php artisan filament:assets`.
|
||||
|
|
||||
*/
|
||||
|
||||
'assets_path' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the directory that Filament will use to store cache files that
|
||||
| are used to optimize the registration of components.
|
||||
|
|
||||
| After changing the path, you should run `php artisan filament:cache-components`.
|
||||
|
|
||||
*/
|
||||
|
||||
'cache_path' => base_path('bootstrap/cache/filament'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Livewire Loading Delay
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This sets the delay before loading indicators appear.
|
||||
|
|
||||
| Setting this to 'none' makes indicators appear immediately, which can be
|
||||
| desirable for high-latency connections. Setting it to 'default' applies
|
||||
| Livewire's standard 200ms delay.
|
||||
|
|
||||
*/
|
||||
|
||||
'livewire_loading_delay' => 'default',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| File Generation
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Artisan commands that generate files can be configured here by setting
|
||||
| configuration flags that will impact their location or content.
|
||||
|
|
||||
| Often, this is useful to preserve file generation behavior from a
|
||||
| previous version of Filament, to ensure consistency between older and
|
||||
| newer generated files. These flags are often documented in the upgrade
|
||||
| guide for the version of Filament you are upgrading to.
|
||||
|
|
||||
*/
|
||||
|
||||
'file_generation' => [
|
||||
'flags' => [],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| System Route Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the prefix used for the system routes that Filament registers,
|
||||
| such as the routes for downloading exports and failed import rows.
|
||||
|
|
||||
*/
|
||||
|
||||
'system_route_prefix' => 'filament',
|
||||
|
||||
];
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Orderstatus;
|
||||
use App\Models\Orderstatus;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -13,14 +13,13 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$orderstatusRegistered = Orderstatus::find("name", "erfasst")->first();
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string("name");
|
||||
$table->string("url")->nullable();
|
||||
$table->integer("count")->nullable();
|
||||
$table->foreignidfor(Orderstatus::class)->default($orderstatusRegistered->id);
|
||||
$table->foreignidfor(Orderstatus::class)->default(1);
|
||||
$table->datetime("orderdatetime")->nullable();
|
||||
$table->foreignIdFor(User::class);
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user