pint run
This commit is contained in:
parent
00bcaa2b93
commit
1559580ceb
@ -30,10 +30,10 @@ class OrderExporter extends Exporter
|
||||
|
||||
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.';
|
||||
$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.';
|
||||
$body .= ' '.Number::format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
|
||||
@ -5,9 +5,9 @@ namespace App\Filament\Resources\Belts;
|
||||
use App\Filament\Resources\Belts\Pages\CreateBelt;
|
||||
use App\Filament\Resources\Belts\Pages\EditBelt;
|
||||
use App\Filament\Resources\Belts\Pages\ListBelts;
|
||||
use App\Filament\Resources\Belts\RelationManagers\CoursesRelationManager;
|
||||
use App\Filament\Resources\Belts\Schemas\BeltForm;
|
||||
use App\Filament\Resources\Belts\Tables\BeltsTable;
|
||||
use App\Filament\Resources\Belts\RelationManagers\CoursesRelationManager;
|
||||
use App\Models\Belt;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
@ -21,15 +21,20 @@ class BeltResource extends Resource
|
||||
protected static ?string $model = Belt::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ArrowUpCircle;
|
||||
protected static string | UnitEnum | null $navigationGroup = 'Kurse und Kinder';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Kurse und Kinder';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $pluralLabel = 'Gürtel';
|
||||
|
||||
protected static ?string $label = 'Gürtel';
|
||||
protected static ?string $navigationLabel = "Gürtel";
|
||||
protected static ?string $pluralModelLabel = "Gürtel";
|
||||
protected static ?string $modelLabel = "Gürtel";
|
||||
|
||||
protected static ?string $navigationLabel = 'Gürtel';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Gürtel';
|
||||
|
||||
protected static ?string $modelLabel = 'Gürtel';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -44,7 +49,7 @@ class BeltResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
CoursesRelationManager::class
|
||||
CoursesRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -4,10 +4,8 @@ namespace App\Filament\Resources\Belts\RelationManagers;
|
||||
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DetachAction;
|
||||
use Filament\Actions\DetachBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources\Belts\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
|
||||
@ -22,15 +22,20 @@ class CourseResource extends Resource
|
||||
protected static ?string $model = Course::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ArchiveBox;
|
||||
protected static string | UnitEnum | null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $pluralLabel = 'Kurse';
|
||||
|
||||
protected static ?string $label = 'Kurs';
|
||||
protected static ?string $navigationLabel = "Kurse";
|
||||
protected static ?string $pluralModelLabel = "Kurse";
|
||||
protected static ?string $modelLabel = "Kurs";
|
||||
|
||||
protected static ?string $navigationLabel = 'Kurse';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kurse';
|
||||
|
||||
protected static ?string $modelLabel = 'Kurs';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -50,7 +55,7 @@ class CourseResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
KidsRelationManager::class
|
||||
KidsRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ class KidsRelationManager extends RelationManager
|
||||
->form(fn (AttachAction $action): array => [
|
||||
$action->getRecordSelect(),
|
||||
DatePicker::make('date')->required(),
|
||||
])->preloadRecordSelect()
|
||||
])->preloadRecordSelect(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
|
||||
@ -20,12 +20,16 @@ class GroupResource extends Resource
|
||||
protected static ?string $model = Group::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::UserGroup;
|
||||
protected static string | UnitEnum | null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $navigationLabel = "Gruppen";
|
||||
protected static ?string $pluralLabel = "Gruppen";
|
||||
protected static ?string $pluralModelLabel = "Gruppen";
|
||||
protected static ?string $modelLabel = "Gruppe";
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Gruppen';
|
||||
|
||||
protected static ?string $pluralLabel = 'Gruppen';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Gruppen';
|
||||
|
||||
protected static ?string $modelLabel = 'Gruppe';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
|
||||
@ -22,15 +22,20 @@ class KidResource extends Resource
|
||||
protected static ?string $model = Kid::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::UserCircle;
|
||||
protected static string | UnitEnum | null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?string $pluralLabel = 'Kinder';
|
||||
|
||||
protected static ?string $label = 'Kind';
|
||||
protected static ?string $navigationLabel = "Kinder";
|
||||
protected static ?string $pluralModelLabel = "Kinder";
|
||||
protected static ?string $modelLabel = "Kind";
|
||||
|
||||
protected static ?string $navigationLabel = 'Kinder';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kinder';
|
||||
|
||||
protected static ?string $modelLabel = 'Kind';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@ -50,7 +55,7 @@ class KidResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
CoursesRelationManager::class
|
||||
CoursesRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ namespace App\Filament\Resources\Kids\RelationManagers;
|
||||
|
||||
use Filament\Actions\AttachAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\DetachAction;
|
||||
@ -37,7 +36,7 @@ class CoursesRelationManager extends RelationManager
|
||||
TextInput::make('duration')
|
||||
->required()
|
||||
->numeric(),
|
||||
DatePicker::make('date')
|
||||
DatePicker::make('date'),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -86,7 +85,7 @@ class CoursesRelationManager extends RelationManager
|
||||
->schema(fn (AttachAction $action): array => [
|
||||
$action->getRecordSelect(),
|
||||
DatePicker::make('date')->required(),
|
||||
])->preloadRecordSelect()
|
||||
])->preloadRecordSelect(),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
|
||||
@ -20,10 +20,13 @@ class OrderResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ShoppingBag;
|
||||
|
||||
protected static ?string $navigationLabel = "Bestellungen";
|
||||
protected static ?string $pluralLabel = "Bestellungen";
|
||||
protected static ?string $pluralModelLabel = "Bestellungen";
|
||||
protected static ?string $modelLabel = "Bestellung";
|
||||
protected static ?string $navigationLabel = 'Bestellungen';
|
||||
|
||||
protected static ?string $pluralLabel = 'Bestellungen';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Bestellungen';
|
||||
|
||||
protected static ?string $modelLabel = 'Bestellung';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@ -18,27 +18,35 @@ class EditOrder extends EditRecord
|
||||
{
|
||||
return [
|
||||
Action::make('bestellt_single')
|
||||
->icon(Heroicon::ShoppingCart)->label("Bestellt")->action(function(Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();
|
||||
->icon(Heroicon::ShoppingCart)->label('Bestellt')->action(function (Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where('name', 'bestellt')->first();
|
||||
$record->orderstatus()->associate($orderstatusBestellt);
|
||||
$record->save();
|
||||
$this->refreshFormData(['orderstatus_id']);
|
||||
})->visible(function(Model $record) {return ($record->orderstatus->name == 'erfasst');}),
|
||||
})->visible(function (Model $record) {
|
||||
return $record->orderstatus->name == 'erfasst';
|
||||
}),
|
||||
Action::make('angekommen_single')
|
||||
->icon(Heroicon::BuildingOffice)->label("Angekommen")->action(function(Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();
|
||||
->icon(Heroicon::BuildingOffice)->label('Angekommen')->action(function (Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where('name', 'angekommen')->first();
|
||||
$record->orderstatus()->associate($orderstatusAngekommen);
|
||||
$record->save();
|
||||
$this->refreshFormData(['orderstatus_id']);
|
||||
})->visible(function(Model $record) {return ($record->orderstatus->name == 'bestellt');}),
|
||||
})->visible(function (Model $record) {
|
||||
return $record->orderstatus->name == 'bestellt';
|
||||
}),
|
||||
Action::make('genommen_single')
|
||||
->icon(Heroicon::Check)->label("Genommen")->action(function(Model $record) {
|
||||
$orderstatusGenommen = Orderstatus::where("name", "genommen")->first();
|
||||
->icon(Heroicon::Check)->label('Genommen')->action(function (Model $record) {
|
||||
$orderstatusGenommen = Orderstatus::where('name', 'genommen')->first();
|
||||
$record->orderstatus()->associate($orderstatusGenommen);
|
||||
$record->save();
|
||||
$this->refreshFormData(['orderstatus_id']);
|
||||
})->visible(function(Model $record) {return ($record->orderstatus->name == 'angekommen');}),
|
||||
Action::make("url_oeffnen")->icon(Heroicon::Link)->label("URL öffnen")->url(function (Model $record) { return $record->url;}, true),
|
||||
})->visible(function (Model $record) {
|
||||
return $record->orderstatus->name == 'angekommen';
|
||||
}),
|
||||
Action::make('url_oeffnen')->icon(Heroicon::Link)->label('URL öffnen')->url(function (Model $record) {
|
||||
return $record->url;
|
||||
}, true),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ class ListOrders extends ListRecords
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
ExportAction::make()->label('exportieren')->exporter(OrderExporter::class)->enableVisibleTableColumnsByDefault()
|
||||
ExportAction::make()->label('exportieren')->exporter(OrderExporter::class)->enableVisibleTableColumnsByDefault(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,40 +34,48 @@ class OrderForm
|
||||
->columnSpan(1),
|
||||
Select::make('user_id')
|
||||
->label('Bestellt von')->inlineLabel()
|
||||
->relationship("user", "name")
|
||||
->relationship('user', 'name')
|
||||
->required()
|
||||
->default(filament()->auth()->user()->id),
|
||||
Select::make("orderstatus_id")
|
||||
Select::make('orderstatus_id')
|
||||
->label('Bestellstatus')->inlineLabel()
|
||||
->relationship("orderstatus", "name")
|
||||
->visibleOn(["edit"])
|
||||
->prefixActions([
|
||||
Action::make('bestellt_single')
|
||||
->icon(Heroicon::ShoppingCart)->label("Bestellt")->action(function(Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();
|
||||
$record->orderstatus_id = $orderstatusBestellt->id;
|
||||
$record->save();
|
||||
redirect(OrderResource::getUrl('edit', ['record' => $record->id,]));
|
||||
})->visible(function(Model $record) {return ($record->orderstatus->name == 'erfasst');}),
|
||||
Action::make('angekommen_single')
|
||||
->icon(Heroicon::BuildingOffice)->label("Angekommen")->action(function(Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();
|
||||
$record->orderstatus_id = $orderstatusAngekommen->id;
|
||||
$record->save();
|
||||
redirect(OrderResource::getUrl('edit', ['record' => $record->id,]));
|
||||
})->visible(function(Model $record) {return ($record->orderstatus->name == 'bestellt');}),
|
||||
Action::make('genommen_single')
|
||||
->icon(Heroicon::Check)->label("Genommen")->action(function(Model $record) {
|
||||
$orderstatusGenommen = Orderstatus::where("name", "genommen")->first();
|
||||
$record->orderstatus_id = $orderstatusGenommen->id;
|
||||
$record->save();
|
||||
redirect(OrderResource::getUrl('edit', ['record' => $record->id,]));
|
||||
})->visible(function(Model $record) {return ($record->orderstatus->name == 'angekommen');}),
|
||||
Action::make("url_oeffnen")->icon(Heroicon::Link)->label("URL öffnen")->url(function (Model $record) { return $record->url;}, true),
|
||||
]),
|
||||
->relationship('orderstatus', 'name')
|
||||
->visibleOn(['edit'])
|
||||
->prefixActions([
|
||||
Action::make('bestellt_single')
|
||||
->icon(Heroicon::ShoppingCart)->label('Bestellt')->action(function (Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where('name', 'bestellt')->first();
|
||||
$record->orderstatus_id = $orderstatusBestellt->id;
|
||||
$record->save();
|
||||
redirect(OrderResource::getUrl('edit', ['record' => $record->id]));
|
||||
})->visible(function (Model $record) {
|
||||
return $record->orderstatus->name == 'erfasst';
|
||||
}),
|
||||
Action::make('angekommen_single')
|
||||
->icon(Heroicon::BuildingOffice)->label('Angekommen')->action(function (Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where('name', 'angekommen')->first();
|
||||
$record->orderstatus_id = $orderstatusAngekommen->id;
|
||||
$record->save();
|
||||
redirect(OrderResource::getUrl('edit', ['record' => $record->id]));
|
||||
})->visible(function (Model $record) {
|
||||
return $record->orderstatus->name == 'bestellt';
|
||||
}),
|
||||
Action::make('genommen_single')
|
||||
->icon(Heroicon::Check)->label('Genommen')->action(function (Model $record) {
|
||||
$orderstatusGenommen = Orderstatus::where('name', 'genommen')->first();
|
||||
$record->orderstatus_id = $orderstatusGenommen->id;
|
||||
$record->save();
|
||||
redirect(OrderResource::getUrl('edit', ['record' => $record->id]));
|
||||
})->visible(function (Model $record) {
|
||||
return $record->orderstatus->name == 'angekommen';
|
||||
}),
|
||||
Action::make('url_oeffnen')->icon(Heroicon::Link)->label('URL öffnen')->url(function (Model $record) {
|
||||
return $record->url;
|
||||
}, true),
|
||||
]),
|
||||
DateTimePicker::make('orderdatetime')
|
||||
->label('Bestellzeitpunkt')->inlineLabel()
|
||||
->visibleOn(["edit", "view"])
|
||||
->visibleOn(['edit', 'view'])
|
||||
->disabled(),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
@ -2,22 +2,21 @@
|
||||
|
||||
namespace App\Filament\Resources\Orders\Tables;
|
||||
|
||||
use App\Models\Order;
|
||||
use App\Models\Orderstatus;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\RecordActionsPosition;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Grouping\Group;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrdersTable
|
||||
@ -65,42 +64,58 @@ class OrdersTable
|
||||
Group::make('user.name')->label('Bestellt von'),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('orderstatus_id')->relationship('orderstatus', 'name')->label("Bestellstatus")->multiple(),
|
||||
Filter::make('mine')->label("meine")
|
||||
SelectFilter::make('orderstatus_id')->relationship('orderstatus', 'name')->label('Bestellstatus')->multiple(),
|
||||
Filter::make('mine')->label('meine')
|
||||
->default()
|
||||
->query(function (Builder $query) {
|
||||
$query->where('user_id', filament()->auth()->user()->id);
|
||||
|
||||
return $query;
|
||||
}),
|
||||
Filter::make('alleoffenen')
|
||||
->default()
|
||||
->label("alle offenen")
|
||||
->label('alle offenen')
|
||||
->query(function (Builder $query) {
|
||||
$orderstatusGenommen = Orderstatus::where("name", "genommen")->first();
|
||||
$orderstatusGenommen = Orderstatus::where('name', 'genommen')->first();
|
||||
$query->where('orderstatus_id', '!=', $orderstatusGenommen->id);
|
||||
|
||||
return $query;
|
||||
}),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('bestellt_single')
|
||||
->icon(Heroicon::ShoppingCart)->iconButton()->label("Bestellt")->action(function(Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();
|
||||
->icon(Heroicon::ShoppingCart)->iconButton()->label('Bestellt')->action(function (Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where('name', 'bestellt')->first();
|
||||
$record->orderstatus_id = $orderstatusBestellt->id;
|
||||
$record->save();
|
||||
})->visible(function(Model $record) {$orderstatusErfasst = Orderstatus::where("name", "erfasst")->first();return ($orderstatusErfasst->id == $record->orderstatus_id);}),
|
||||
})->visible(function (Model $record) {
|
||||
$orderstatusErfasst = Orderstatus::where('name', 'erfasst')->first();
|
||||
|
||||
return $orderstatusErfasst->id == $record->orderstatus_id;
|
||||
}),
|
||||
Action::make('angekommen_single')
|
||||
->icon(Heroicon::BuildingOffice)->iconButton()->label("Angekommen")->action(function(Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();
|
||||
->icon(Heroicon::BuildingOffice)->iconButton()->label('Angekommen')->action(function (Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where('name', 'angekommen')->first();
|
||||
$record->orderstatus_id = $orderstatusAngekommen->id;
|
||||
$record->save();
|
||||
})->visible(function(Model $record) {$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();return ($orderstatusBestellt->id == $record->orderstatus_id);}),
|
||||
})->visible(function (Model $record) {
|
||||
$orderstatusBestellt = Orderstatus::where('name', 'bestellt')->first();
|
||||
|
||||
return $orderstatusBestellt->id == $record->orderstatus_id;
|
||||
}),
|
||||
Action::make('genommen_single')
|
||||
->icon(Heroicon::Check)->iconButton()->label("Genommen")->action(function(Model $record) {
|
||||
$orderstatusGenommen = Orderstatus::where("name", "genommen")->first();
|
||||
->icon(Heroicon::Check)->iconButton()->label('Genommen')->action(function (Model $record) {
|
||||
$orderstatusGenommen = Orderstatus::where('name', 'genommen')->first();
|
||||
$record->orderstatus_id = $orderstatusGenommen->id;
|
||||
$record->save();
|
||||
})->visible(function(Model $record) {$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();return ($orderstatusAngekommen->id == $record->orderstatus_id);}),
|
||||
Action::make("url_oeffnen")->icon(Heroicon::Link)->iconButton()->label("URL öffnen")->url(function (Model $record) { return $record->url;}, true),
|
||||
})->visible(function (Model $record) {
|
||||
$orderstatusAngekommen = Orderstatus::where('name', 'angekommen')->first();
|
||||
|
||||
return $orderstatusAngekommen->id == $record->orderstatus_id;
|
||||
}),
|
||||
Action::make('url_oeffnen')->icon(Heroicon::Link)->iconButton()->label('URL öffnen')->url(function (Model $record) {
|
||||
return $record->url;
|
||||
}, true),
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
], position: RecordActionsPosition::BeforeColumns)
|
||||
@ -108,24 +123,24 @@ class OrdersTable
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
Action::make('bestellt_bulk')
|
||||
->label("Ausgewählte bestellt")
|
||||
->label('Ausgewählte bestellt')
|
||||
->accessSelectedRecords()
|
||||
->action(function (Collection $selectedRecords) {
|
||||
$orderstatusBestellt = Orderstatus::where("name", "bestellt")->first();
|
||||
$orderstatusBestellt = Orderstatus::where('name', 'bestellt')->first();
|
||||
$selectedRecords->each(
|
||||
fn (Model $selectedRecord) => $selectedRecord->update([
|
||||
'orderstatus_id' => $orderstatusBestellt->id
|
||||
'orderstatus_id' => $orderstatusBestellt->id,
|
||||
]),
|
||||
);
|
||||
})->requiresConfirmation()->icon(Heroicon::ShoppingCart),
|
||||
Action::make('angekommen_bulk')
|
||||
->label("Ausgewählte angekommen")
|
||||
->label('Ausgewählte angekommen')
|
||||
->accessSelectedRecords()
|
||||
->action(function (Collection $selectedRecords) {
|
||||
$orderstatusAngekommen = Orderstatus::where("name", "angekommen")->first();
|
||||
$orderstatusAngekommen = Orderstatus::where('name', 'angekommen')->first();
|
||||
$selectedRecords->each(
|
||||
fn (Model $selectedRecord) => $selectedRecord->update([
|
||||
'orderstatus_id' => $orderstatusAngekommen->id
|
||||
'orderstatus_id' => $orderstatusAngekommen->id,
|
||||
]),
|
||||
);
|
||||
})->requiresConfirmation()->icon(Heroicon::BuildingOffice),
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use App\Filament\Resources\Groups\GroupResource;
|
||||
use App\Filament\Resources\Groups\Schemas\GroupForm;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@ -36,7 +34,7 @@ class UserForm
|
||||
->relationship('groups', 'name')
|
||||
->label('Gruppen')
|
||||
->preload()
|
||||
->createOptionForm(function(Schema $schema) {
|
||||
->createOptionForm(function (Schema $schema) {
|
||||
return GroupForm::configure($schema);
|
||||
})
|
||||
->multiple(),
|
||||
|
||||
@ -24,10 +24,10 @@ class UsersTable
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('roles.title')
|
||||
->label("Rollen")
|
||||
->label('Rollen')
|
||||
->toggleable(),
|
||||
TextColumn::make('groups.name')
|
||||
->label("Gruppen")
|
||||
->label('Gruppen')
|
||||
->toggleable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
|
||||
@ -15,19 +15,22 @@ use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
use Override;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::User;
|
||||
protected static string | UnitEnum | null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $navigationLabel = "Benutzer";
|
||||
protected static ?string $pluralLabel = "Benutzer";
|
||||
protected static ?string $pluralModelLabel = "Benutzer";
|
||||
protected static ?string $modelLabel = "Benutzer";
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Benutzer';
|
||||
|
||||
protected static ?string $pluralLabel = 'Benutzer';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Benutzer';
|
||||
|
||||
protected static ?string $modelLabel = 'Benutzer';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@ -11,21 +11,26 @@ class OrderController extends Controller
|
||||
public function ordered($uuid)
|
||||
{
|
||||
$order = Order::where('public_uuid', $uuid)->firstOrFail();
|
||||
$orderstatus = Orderstatus::where("name", "bestellt")->firstOrFail();
|
||||
if($order->orderstatus_id >= $orderstatus->id) return redirect(OrderResource::getUrl('edit', ['record' => $order->id]));
|
||||
$orderstatus = Orderstatus::where('name', 'bestellt')->firstOrFail();
|
||||
if ($order->orderstatus_id >= $orderstatus->id) {
|
||||
return redirect(OrderResource::getUrl('edit', ['record' => $order->id]));
|
||||
}
|
||||
$order->orderstatus_id = $orderstatus->id;
|
||||
$order->save();
|
||||
return view('OrderOrdered', ['url' => OrderResource::getUrl('edit', ['record' => $order->id,])]);
|
||||
|
||||
return view('OrderOrdered', ['url' => OrderResource::getUrl('edit', ['record' => $order->id])]);
|
||||
}
|
||||
|
||||
public function taken($uuid)
|
||||
{
|
||||
$order = Order::where('public_uuid', $uuid)->firstOrFail();
|
||||
$orderstatus = Orderstatus::where("name", "genommen")->firstOrFail();
|
||||
if($order->orderstatus_id >= $orderstatus->id) return redirect(OrderResource::getUrl('edit', ['record' => $order->id]));
|
||||
$orderstatus = Orderstatus::where('name', 'genommen')->firstOrFail();
|
||||
if ($order->orderstatus_id >= $orderstatus->id) {
|
||||
return redirect(OrderResource::getUrl('edit', ['record' => $order->id]));
|
||||
}
|
||||
$order->orderstatus_id = $orderstatus->id;
|
||||
$order->save();
|
||||
return view('OrderTaken', ['url' => OrderResource::getUrl('edit', ['record' => $order->id,])]);
|
||||
|
||||
return view('OrderTaken', ['url' => OrderResource::getUrl('edit', ['record' => $order->id])]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ use App\Filament\Resources\Orders\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
@ -20,8 +21,7 @@ class OrderArrived extends Mailable
|
||||
*/
|
||||
public function __construct(
|
||||
public Order $order,
|
||||
)
|
||||
{
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class OrderArrived extends Mailable
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
* @return array<int, Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
|
||||
@ -6,6 +6,7 @@ use App\Filament\Resources\Orders\OrderResource;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Attachment;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
@ -20,8 +21,7 @@ class OrderRegistered extends Mailable
|
||||
*/
|
||||
public function __construct(
|
||||
public Order $order,
|
||||
)
|
||||
{
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class OrderRegistered extends Mailable
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
* @return array<int, Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
|
||||
@ -7,11 +7,10 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Belt extends Model
|
||||
{
|
||||
protected $fillable = ["name"];
|
||||
protected $fillable = ['name'];
|
||||
|
||||
public function courses(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Course::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,22 +2,20 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Kid;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Course extends Model
|
||||
{
|
||||
protected $fillable = ["name", "duration"];
|
||||
protected $fillable = ['name', 'duration'];
|
||||
|
||||
public function kids(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Kid::class)->withPivot("date");
|
||||
return $this->belongsToMany(Kid::class)->withPivot('date');
|
||||
}
|
||||
|
||||
public function belts(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Belt::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,5 +13,4 @@ class Group extends Model
|
||||
{
|
||||
return $this->belongsToMany(User::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,10 +7,10 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Kid extends Model
|
||||
{
|
||||
protected $fillable = ["name", "email"];
|
||||
protected $fillable = ['name', 'email'];
|
||||
|
||||
public function courses(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Course::class)->withPivot("date");
|
||||
return $this->belongsToMany(Course::class)->withPivot('date');
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,21 +6,19 @@ 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_id", "orderdatetime", "user_id"];
|
||||
protected $fillable = ['name', 'url', 'count', 'orderstatus_id', 'orderdatetime', 'user_id'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function orderstatus(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Orderstatus::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,5 +13,4 @@ class Role extends Model
|
||||
{
|
||||
return $this->belongsToMany(User::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@ namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
|
||||
use Database\Factories\UserFactory;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
@ -19,7 +19,7 @@ class OrderObserver
|
||||
{
|
||||
$order->public_uuid = (string) Str::uuid();
|
||||
$order->save();
|
||||
$users = Role::where("name", "ordermanager")->users()->get();
|
||||
$users = Role::where('name', 'ordermanager')->users()->get();
|
||||
foreach ($users as $user) {
|
||||
Mail::to($user)->send(new OrderRegistered($order));
|
||||
}
|
||||
@ -31,12 +31,12 @@ class OrderObserver
|
||||
public function updated(Order $order): void
|
||||
{
|
||||
$hasChanged = $order->getChanges();
|
||||
if($hasChanged && isset($hasChanged['orderstatus_id'])) {
|
||||
if($order->orderstatus->name == "bestellt") {
|
||||
if ($hasChanged && isset($hasChanged['orderstatus_id'])) {
|
||||
if ($order->orderstatus->name == 'bestellt') {
|
||||
$order->orderdatetime = $order->updated_at;
|
||||
$order->saveQuietly();
|
||||
}
|
||||
if($order->orderstatus->name == "angekommen") {
|
||||
if ($order->orderstatus->name == 'angekommen') {
|
||||
$user = User::find($order->user_id);
|
||||
Mail::to($user)->send(new OrderArrived($order));
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ use Filament\Pages\Dashboard;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Filament\Widgets\FilamentInfoWidget;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Orderstatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -16,11 +16,11 @@ return new class extends Migration
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string("name");
|
||||
$table->string("url")->nullable();
|
||||
$table->integer("count")->nullable();
|
||||
$table->string('name');
|
||||
$table->string('url')->nullable();
|
||||
$table->integer('count')->nullable();
|
||||
$table->foreignidfor(Orderstatus::class)->default(1);
|
||||
$table->datetime("orderdatetime")->nullable();
|
||||
$table->datetime('orderdatetime')->nullable();
|
||||
$table->foreignIdFor(User::class);
|
||||
});
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ return new class extends Migration
|
||||
Schema::create('orderstatuses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string("name");
|
||||
$table->string('name');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean("ordermanager")->default(false);
|
||||
$table->boolean('ordermanager')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ return new class extends Migration
|
||||
Schema::create('kids', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string("name");
|
||||
$table->string("email")->nullable();
|
||||
$table->string('name');
|
||||
$table->string('email')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ return new class extends Migration
|
||||
Schema::create('courses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string("name");
|
||||
$table->integer("duration");
|
||||
$table->string('name');
|
||||
$table->integer('duration');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ return new class extends Migration
|
||||
$table->timestamps();
|
||||
$table->foreignIdFor(Kid::class);
|
||||
$table->foreignIdFor(Course::class);
|
||||
$table->date("date")->nullable();
|
||||
$table->date('date')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ return new class extends Migration
|
||||
Schema::create('belts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string("name");
|
||||
$table->string('name');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -13,10 +13,12 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$ordermanager = Role::firstOrCreate(["name" => "ordermanager", 'title' => 'Ordermanager', 'description' => 'Verwaltet Bestellungen'])->save();
|
||||
$ordermanager = Role::firstOrCreate(['name' => 'ordermanager', 'title' => 'Ordermanager', 'description' => 'Verwaltet Bestellungen'])->save();
|
||||
$users = User::all();
|
||||
foreach($users as $user) {
|
||||
if($user->ordermanager) $user->roles()->attach($ordermanager);
|
||||
foreach ($users as $user) {
|
||||
if ($user->ordermanager) {
|
||||
$user->roles()->attach($ordermanager);
|
||||
}
|
||||
}
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('ordermanager');
|
||||
@ -30,11 +32,11 @@ return new class extends Migration
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean("ordermanager")->default(false);
|
||||
$table->boolean('ordermanager')->default(false);
|
||||
});
|
||||
$users = User::all();
|
||||
foreach($users as $user) {
|
||||
if($user->hasRole("ordermanager")) {
|
||||
foreach ($users as $user) {
|
||||
if ($user->hasRole('ordermanager')) {
|
||||
$user->ordermanager = 1;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user