konto wip
This commit is contained in:
1 parent
e379bb5c94
commit
47edd31030
22 files changed
+219
-138
No files matched your search
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Filament\Resources\Kontos;
|
||||
|
||||
use App\Filament\Resources\Kontos\Pages\CreateKonto;
|
||||
use App\Filament\Resources\Kontos\Pages\EditKonto;
|
||||
use App\Filament\Resources\Kontos\Pages\ListKontos;
|
||||
use App\Filament\Resources\Kontos\Schemas\KontoForm;
|
||||
use App\Filament\Resources\Kontos\Tables\KontosTable;
|
||||
@@ -12,6 +10,7 @@ use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class KontoResource extends Resource
|
||||
{
|
||||
@@ -23,7 +22,7 @@ class KontoResource extends Resource
|
||||
|
||||
protected static ?string $modelLabel = 'Konto';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kontos';
|
||||
protected static ?string $pluralModelLabel = 'Konto';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -46,13 +45,16 @@ class KontoResource extends Resource
|
||||
{
|
||||
return [
|
||||
'index' => ListKontos::route('/'),
|
||||
'create' => CreateKonto::route('/create'),
|
||||
'edit' => EditKonto::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->where('id', auth()->user()->konto_id);
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
return parent::getEloquentQuery()->where('id', auth()->user()->konto_id)->count();
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,9 @@
|
||||
namespace App\Filament\Resources\Kontos\Pages;
|
||||
|
||||
use App\Filament\Resources\Kontos\KontoResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListKontos extends ListRecords
|
||||
{
|
||||
protected static string $resource = KontoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
namespace App\Filament\Resources\Kontos\Schemas;
|
||||
|
||||
use App\Models\Konto;
|
||||
use Danielebarbaro\LaravelVatEuValidator\Rules\VatNumber;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Ysfkaya\FilamentPhoneInput\Forms\PhoneInput;
|
||||
|
||||
class KontoForm
|
||||
{
|
||||
@@ -10,7 +15,50 @@ class KontoForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
TextInput::make('konto_company')
|
||||
->label('Firma')
|
||||
->required(),
|
||||
TextInput::make('konto_email')
|
||||
->label('E-Mail')
|
||||
->unique(table: Konto::class)
|
||||
->required(),
|
||||
TextInput::make('konto_address')
|
||||
->label('Adresse')
|
||||
->required(),
|
||||
TextInput::make('konto_location')
|
||||
->label('Ort')
|
||||
->required(),
|
||||
TextInput::make('konto_plz')
|
||||
->label('Postleitzahl')
|
||||
->required(),
|
||||
PhoneInput::make('konto_phone')
|
||||
->label('Telefon')
|
||||
->defaultCountry('AT'),
|
||||
TextInput::make('konto_country')
|
||||
->label('Land')
|
||||
->default('Österreich')
|
||||
->required(),
|
||||
TextInput::make('konto_uid_number')
|
||||
->label('UID Nummer')
|
||||
->rules([new VatNumber])
|
||||
->required(),
|
||||
TextInput::make('konto_title')
|
||||
->label('Title')
|
||||
->required(),
|
||||
Select::make('konto_gender')
|
||||
->label('Geschlecht')
|
||||
->options([
|
||||
'Herr' => 'Herr',
|
||||
'Frau' => 'Frau',
|
||||
'Non-binary' => 'Non-binary',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('konto_first_name')
|
||||
->label('Vorname')
|
||||
->required(),
|
||||
TextInput::make('konto_last_name')
|
||||
->label('Nachname')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\Kontos\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Ysfkaya\FilamentPhoneInput\PhoneInputNumberType;
|
||||
@@ -18,24 +18,27 @@ class KontosTable
|
||||
->columns([
|
||||
// TextColumn::make('id'),
|
||||
TextColumn::make('konto_gender')->label('Geschlecht'),
|
||||
TextColumn::make('konto_title')->label('Title'),
|
||||
TextColumn::make('konto_first_name')->label('Vorname'),
|
||||
TextColumn::make('konto_last_name')->label('Nachname'),
|
||||
// TextColumn::make('konto_title')->label('Title'),
|
||||
// TextColumn::make('konto_first_name')->label('Vorname'),
|
||||
// TextColumn::make('konto_last_name')->label('Nachname'),
|
||||
TextColumn::make('konto_company')->label('Firma'),
|
||||
IconColumn::make('konto_agb_akzeptiert')
|
||||
->label('AGB')
|
||||
->boolean()
|
||||
->trueIcon(Heroicon::OutlinedCheckBadge)
|
||||
->falseIcon(Heroicon::OutlinedXMark),
|
||||
|
||||
PhoneColumn::make('konto_phone')
|
||||
->label('Telefon')
|
||||
->displayFormat(PhoneInputNumberType::INTERNATIONAL),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
TextColumn::make('konto_email')
|
||||
->copyable()
|
||||
->copyMessage('E-Mail wurde kopiert')
|
||||
->copyMessageDuration(1500)
|
||||
->label('E-mail'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,5 @@ class Gutachter extends Model
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new KontoScope);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,14 +25,14 @@ class Konto extends Model
|
||||
'konto_country',
|
||||
'konto_phone',
|
||||
'konto_uid_number',
|
||||
'konto_agb_akzeptiert',
|
||||
];
|
||||
|
||||
// protected static function booted(): void
|
||||
// {
|
||||
// static::addGlobalScope('konto', function (Builder $query) {
|
||||
// if (auth()->hasUser()) {
|
||||
// $query->where('konto_id', auth()->user()->konto_id);
|
||||
// // or with a `team` relationship defined:
|
||||
// // $query->whereBelongsTo(auth()->user()->team);
|
||||
// $query->where('id', auth()->user()->konto_id);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
Reference in new issue
Block a user