projekt wip bofore relations

This commit is contained in:
salam committed 2025-10-03 10:55:01 +02:00
1 parent aa301f1197
commit 69d4efcd9d
11 files changed
+80 -89

No files matched your search

@@ -13,7 +13,7 @@ class ListAuftraggebers extends ListRecords
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
CreateAction::make()->createAnother(false),
];
}
}
@@ -13,7 +13,7 @@ class ListGutachters extends ListRecords
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
CreateAction::make()->createAnother(false),
];
}
}
@@ -13,7 +13,13 @@ class ListProjektes extends ListRecords
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
CreateAction::make()
->createAnother(false)
->mutateDataUsing(function (array $data): array {
$data['konto_id'] = auth()->user()->konto_id;
return $data;
}),
];
}
}
@@ -14,6 +14,7 @@ use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class ProjekteResource extends Resource
{
@@ -53,12 +54,17 @@ class ProjekteResource extends Resource
return [
'index' => ListProjektes::route('/'),
// 'create' => CreateProjekte::route('/create'),
// 'edit' => EditProjekte::route('/{record}/edit'),
'edit' => EditProjekte::route('/{record}/edit'),
];
}
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,9 +5,10 @@ namespace App\Filament\Resources\Projektes\Schemas;
use App\Enums\ProjektStatus;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class ProjekteForm
@@ -16,13 +17,25 @@ class ProjekteForm
{
return $schema
->components([
Select::make('auftraggeber_id')->relationship(name: 'auftraggeber', titleAttribute: 'name'),
Select::make('gutachter_id')->relationship(name: 'gutachter', titleAttribute: 'name'),
Radio::make('status')->options(ProjektStatus::class),
TextInput::make('interner_name'),
TextInput::make('ofizieller_name'),
Textarea::make('beschreibung'),
DatePicker::make('erstellung')->helperText('Datum am Gutachten'),
Section::make('Benennung')
->schema([
TextInput::make('interner_name')->columns(1)->label('Interner Name')->required(),
TextInput::make('offizieller_name')->columns(1)->label('Offizieller Name')->required(),
DatePicker::make('erstellung')->helperText('Datum am Gutachten')->required(),
]),
Section::make('Zuordnung')
->schema([
Select::make('auftraggeber_id')->relationship(name: 'auftraggeber', titleAttribute: 'name')->required(),
Select::make('gutachter_id')->relationship(name: 'gutachter', titleAttribute: 'name')->required(),
Radio::make('status')->options(ProjektStatus::class)->required(),
]),
RichEditor::make('beschreibung')
->toolbarButtons([
['bold', 'italic', 'underline', 'strike', 'subscript', 'superscript', 'link'],
['h2', 'h3', 'alignStart', 'alignCenter', 'alignEnd'],
['bulletList', 'orderedList', 'table'],
['undo', 'redo'],
])->columnSpanFull(),
]);
}
}
@@ -2,9 +2,11 @@
namespace App\Filament\Resources\Projektes\Tables;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use App\Enums\ProjektStatus;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\SelectColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
class ProjektesTable
@@ -13,18 +15,30 @@ class ProjektesTable
{
return $table
->columns([
//
TextColumn::make('interner_name')
->label('Interner Name')
->badge()
->color('info')
->searchable(),
TextColumn::make('offizieller_name')
->searchable()
->label('Offizieller Name'),
TextColumn::make('gutachter.company'),
TextColumn::make('auftraggeber.company'),
TextColumn::make('erstellung'),
SelectColumn::make('status')->options(ProjektStatus::class),
])
->filters([
//
SelectFilter::make('status')
->options(ProjektStatus::class),
SelectFilter::make('gutachter')
->relationship('gutachter', 'company'),
SelectFilter::make('auftraggeber')
->relationship('auftraggeber', 'company'),
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
EditAction::make()->iconButton()->color('gray'),
]);
}
}
+6
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\Scopes\KontoScope;
use Database\Factories\AuftraggeberFactory;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -36,6 +37,11 @@ class Auftraggeber extends Model
];
}
protected static function booted(): void
{
static::addGlobalScope(new KontoScope);
}
protected static function newFactory(): Factory
{
return AuftraggeberFactory::new();
-29
View File
@@ -1,29 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Projekt extends Model
{
protected $fillable = [
'konto_id',
'auftraggeber_id',
'gutachter_id',
'gutachter_id',
'ofizieller_name',
'beschreibung',
'erstellung',
'status',
];
public function auftraggeber()
{
return $this->belongsTo(Auftraggeber::class);
}
public function gutachter()
{
return $this->belongsTo(Gutachter::class);
}
}
+11
View File
@@ -6,6 +6,17 @@ use Illuminate\Database\Eloquent\Model;
class Projekte extends Model
{
protected $fillable = [
'konto_id',
'auftraggeber_id',
'gutachter_id',
'offizieller_name',
'interner_name',
'beschreibung',
'erstellung',
'status',
];
public function auftraggeber()
{
return $this->belongsTo(Auftraggeber::class);
@@ -1,36 +0,0 @@
<?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('projektes', function (Blueprint $table) {
$table->id();
$table->foreignId('konto_id')->constrained();
$table->foreignId('auftraggeber_id')->constrained();
$table->foreignId('gutachter_id')->constrained();
$table->string('interner_name');
$table->string('ofizieller_name');
$table->text('beschreibung')->nullable();
$table->string('erstellung')->nullable();
$table->string('status')->default('entwurf');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('projektes');
}
};
@@ -17,7 +17,7 @@ return new class extends Migration
$table->foreignId('auftraggeber_id')->constrained();
$table->foreignId('gutachter_id')->constrained();
$table->string('interner_name');
$table->string('ofizieller_name');
$table->string('offizieller_name');
$table->text('beschreibung')->nullable();
$table->string('erstellung')->nullable();
$table->string('status')->default('entwurf');