seeder wip
This commit is contained in:
1 parent
1d16946f20
commit
005924ef8a
34 files changed
+286
-325
No files matched your search
@@ -15,12 +15,11 @@ use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
|
||||
|
||||
class Register extends BaseRegister
|
||||
{
|
||||
public User $user;
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
@@ -30,7 +29,14 @@ class Register extends BaseRegister
|
||||
->icon('lucide-user-plus')
|
||||
->description('Benutzer anlegen.')
|
||||
->schema([
|
||||
$this->getGenderFormComponent(),
|
||||
Select::make('gender')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
$this->getNameFormComponent(),
|
||||
$this->getEmailFormComponent(),
|
||||
$this->getPasswordFormComponent(),
|
||||
@@ -41,46 +47,83 @@ class Register extends BaseRegister
|
||||
->icon('lucide-key-square')
|
||||
->description('Mit einem Konto verbinden.')
|
||||
->schema([
|
||||
$this->getKontoModusFormComponent(),
|
||||
/** BESTEHENDES KONTO */
|
||||
$this->getKontoFormComponent(),
|
||||
/** BESTEHENDES / NEU */
|
||||
Select::make('register-modus')
|
||||
->columnSpan(4)
|
||||
->label('Registriermodus')
|
||||
->prefixIcon('lucide-key-square')
|
||||
->prefixIconColor('primary')
|
||||
->aboveLabel([
|
||||
'Bitte wählen Sie ein bestehendes Konto oder erstellen Sie ein neues. Eine Registrierung bei einem bestehenden Konto muß vom Kontoinhaber bestätigt werden.',
|
||||
])
|
||||
->options([
|
||||
'old' => 'Mit einem bestehenden Konto verbinden',
|
||||
'new' => 'Ein neues Konto erstellen',
|
||||
])
|
||||
->live()
|
||||
->required(),
|
||||
/** BESTEHEND */
|
||||
Select::make('konto_id')
|
||||
->columnSpan(4)
|
||||
->label('Konto auswählen')
|
||||
->belowLabel([
|
||||
'Um das erstellte Profil zu aktivieren muß der Kontoinhaber die Anmeldung im Programm freischalten',
|
||||
])
|
||||
->visible(fn (Get $get): bool => $get('register-modus') == 'old')
|
||||
->options(Konto::query()->pluck('company', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
/** NEU */
|
||||
Fieldset::make('Rechnungsdaten')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->visible(fn (Get $get): bool => $get('register-modus') == 'new')
|
||||
->schema([
|
||||
TextInput::make('company')
|
||||
TextInput::make('kontos.company')
|
||||
->label('Firma')
|
||||
->required(),
|
||||
TextInput::make('uid_number')
|
||||
TextInput::make('kontos.uid_number')
|
||||
->label('UID Nummer')
|
||||
->rules([new VatNumber])
|
||||
->required(),
|
||||
Textarea::make('address')
|
||||
Textarea::make('kontos.address')
|
||||
->label('Adresse')
|
||||
->required(),
|
||||
TextInput::make('country')
|
||||
TextInput::make('kontos.country')
|
||||
->label('Land')
|
||||
->default('Österreich')
|
||||
->required(),
|
||||
])->columnSpan(4),
|
||||
Fieldset::make('Kontaktperson')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->visible(fn (Get $get): bool => $get('register-modus') == 'new')
|
||||
->schema([
|
||||
// $this->getKontoGenderFormComponent(),
|
||||
// $this->getTitleFormComponent(),
|
||||
// $this->getNameFormComponent(),
|
||||
// $this->getKontoEmailFormComponent(),
|
||||
// $this->getPhoneFormComponent(),
|
||||
Select::make('kontos.gender')
|
||||
->columnSpan(2)
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('kontos.title')
|
||||
->label('Titel')
|
||||
->required(),
|
||||
TextInput::make('kontos.name')
|
||||
->required(),
|
||||
TextInput::make('kontos.email')
|
||||
->label('E-Mail')
|
||||
->unique(table: Konto::class)
|
||||
->required(),
|
||||
PhoneInput::make('kontos.phone')
|
||||
->label('Telefon')
|
||||
->defaultCountry('AT'),
|
||||
])->columnSpan(4),
|
||||
|
||||
]),
|
||||
Wizard\Step::make('AGB')
|
||||
->icon('lucide-receipt-text')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->description(' Allgemein Geschäftsbedignugen')
|
||||
->schema([
|
||||
Fieldset::make('Bitte lesen und akzeptieren Sie die allgemeinen Geschäftsbedignungen um die Registrierung abzuschließen.')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->schema([
|
||||
Checkbox::make('agb_akzeptiert')
|
||||
->label('ABG akzeptieren')
|
||||
@@ -94,106 +137,17 @@ class Register extends BaseRegister
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* MODUS
|
||||
*/
|
||||
protected function getKontoModusFormComponent(): Select
|
||||
public function handleRegistration(array $data): Model
|
||||
{
|
||||
return Select::make('konto')
|
||||
->columnSpan(4)
|
||||
->label('Registriermodus')
|
||||
->prefixIcon('lucide-key-square')
|
||||
->prefixIconColor('primary')
|
||||
->aboveLabel([
|
||||
'Bitte wählen Sie ein bestehendes Konto oder erstellen Sie ein neues. Eine Registrierung bei einem bestehenden Konto muß vom Kontoinhaber bestätigt werden.',
|
||||
])
|
||||
->options([
|
||||
'old' => 'Mit einem bestehenden Konto verbinden',
|
||||
'new' => 'Ein neues Konto erstellen',
|
||||
])
|
||||
->live()
|
||||
->required();
|
||||
}
|
||||
if (isset($data['kontos'])) {
|
||||
$konto = new Konto($data['kontos']);
|
||||
$konto->save();
|
||||
$data['konto_id'] = $konto->id;
|
||||
}
|
||||
unset($data['kontos']);
|
||||
|
||||
/**
|
||||
* USER
|
||||
*/
|
||||
protected function getGenderFormComponent(): Select
|
||||
{
|
||||
return Select::make('gender')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required();
|
||||
}
|
||||
$user = parent::handleRegistration($data);
|
||||
|
||||
/**
|
||||
* KONTO WÄHLEN
|
||||
*/
|
||||
protected function getKontoFormComponent(): Select
|
||||
{
|
||||
return Select::make('konto_id')
|
||||
->columnSpan(4)
|
||||
->label('Konto auswählen')
|
||||
->belowLabel([
|
||||
'Um das erstellte Profil zu aktivieren muß der Kontoinhaber die Anmeldung im Programm freischalten',
|
||||
])
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'old')
|
||||
->options(Konto::query()->pluck('company', 'id'))
|
||||
->searchable()
|
||||
->required();
|
||||
}
|
||||
|
||||
/**
|
||||
* KONTO NEU
|
||||
*/
|
||||
protected function getTitleFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('title')
|
||||
->label('Title')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getKontoGenderFormComponent(): Select
|
||||
{
|
||||
return Select::make('gender')
|
||||
->columnSpan(2)
|
||||
->label('Geschlecht')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getCompanyFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('konto.company')
|
||||
->label('Firma')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getKontoEmailFormComponent(): TextInput
|
||||
{
|
||||
return TextInput::make('email')
|
||||
->label('E-Mail')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->unique(table: Konto::class)
|
||||
->required();
|
||||
}
|
||||
|
||||
protected function getPhoneFormComponent(): PhoneInput
|
||||
{
|
||||
return PhoneInput::make('phone')
|
||||
->label('Telefon')
|
||||
->visible(fn (Get $get): bool => $get('konto') == 'new')
|
||||
->defaultCountry('AT');
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class AuftraggeberResource extends Resource
|
||||
{
|
||||
@@ -58,8 +59,13 @@ class AuftraggeberResource extends Resource
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources\Auftraggebers\Tables;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AuftraggebersTable
|
||||
@@ -13,7 +14,8 @@ class AuftraggebersTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('email')->copyable()->label('E-Mail'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
|
||||
@@ -68,8 +68,13 @@ class GutachterResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ class GutachtersTable
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('email')->copyable()->label('E-Mail'),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make(),
|
||||
|
||||
@@ -9,7 +9,6 @@ use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -26,11 +25,6 @@ class KontosTable
|
||||
// TextColumn::make('gender')->label('Geschlecht'),
|
||||
// TextColumn::make('title')->label('Title'),
|
||||
// TextColumn::make('first_name')->label('Vorname'),
|
||||
// IconColumn::make('agb_akzeptiert')
|
||||
// ->label('AGB')
|
||||
// ->boolean()
|
||||
// ->trueIcon(Heroicon::OutlinedCheckBadge)
|
||||
// ->falseIcon(Heroicon::OutlinedXMark),
|
||||
|
||||
// PhoneColumn::make('phone')
|
||||
// ->label('Telefon')
|
||||
@@ -42,14 +36,14 @@ class KontosTable
|
||||
// ->label('E-mail'),
|
||||
|
||||
TextColumn::make('company')->label('Firma')
|
||||
->description(fn ($record): string => $record->address.', '.$record->location),
|
||||
->description(fn ($record): string => $record->address),
|
||||
|
||||
TextColumn::make('plan.name')
|
||||
->icon(Heroicon::CurrencyEuro)
|
||||
// ->iconColor('success')
|
||||
// ->badge()
|
||||
->label('Plan')
|
||||
->description(fn ($record): string => $record->plan->description)
|
||||
->description(fn ($record): string => $record->plan->payment)
|
||||
->wrap(),
|
||||
|
||||
TextColumn::make('guthaben')
|
||||
|
||||
@@ -7,6 +7,8 @@ use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ForceDeleteBulkAction;
|
||||
use Filament\Actions\RestoreBulkAction;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\TrashedFilter;
|
||||
use Filament\Tables\Table;
|
||||
@@ -21,7 +23,11 @@ class UsersTable
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('konto.company')->badge(),
|
||||
TextColumn::make('email')->copyable()->label('E-Mail'),
|
||||
//
|
||||
IconColumn::make('agb_akzeptiert')
|
||||
->label('AGB')
|
||||
->boolean()
|
||||
->trueIcon(Heroicon::OutlinedCheckBadge)
|
||||
->falseIcon(Heroicon::OutlinedXMark),
|
||||
])
|
||||
->filters([
|
||||
TrashedFilter::make()->visible(fn () => auth()->user()->hasRole('super_admin')),
|
||||
|
||||
@@ -66,8 +66,13 @@ class UserResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
return parent::getEloquentQuery()->where('konto_id', auth()->user()->konto_id)->count();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user