projekt wip bofore relations
This commit is contained in:
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
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
CreateAction::make(),
|
CreateAction::make()->createAnother(false),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ class ListGutachters extends ListRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
CreateAction::make(),
|
CreateAction::make()->createAnother(false),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,13 @@ class ListProjektes extends ListRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
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\Schemas\Schema;
|
||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
class ProjekteResource extends Resource
|
class ProjekteResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -53,12 +54,17 @@ class ProjekteResource extends Resource
|
|||||||
return [
|
return [
|
||||||
'index' => ListProjektes::route('/'),
|
'index' => ListProjektes::route('/'),
|
||||||
// 'create' => CreateProjekte::route('/create'),
|
// '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
|
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 App\Enums\ProjektStatus;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\Radio;
|
use Filament\Forms\Components\Radio;
|
||||||
|
use Filament\Forms\Components\RichEditor;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
class ProjekteForm
|
class ProjekteForm
|
||||||
@@ -16,13 +17,25 @@ class ProjekteForm
|
|||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
Select::make('auftraggeber_id')->relationship(name: 'auftraggeber', titleAttribute: 'name'),
|
Section::make('Benennung')
|
||||||
Select::make('gutachter_id')->relationship(name: 'gutachter', titleAttribute: 'name'),
|
->schema([
|
||||||
Radio::make('status')->options(ProjektStatus::class),
|
TextInput::make('interner_name')->columns(1)->label('Interner Name')->required(),
|
||||||
TextInput::make('interner_name'),
|
TextInput::make('offizieller_name')->columns(1)->label('Offizieller Name')->required(),
|
||||||
TextInput::make('ofizieller_name'),
|
DatePicker::make('erstellung')->helperText('Datum am Gutachten')->required(),
|
||||||
Textarea::make('beschreibung'),
|
]),
|
||||||
DatePicker::make('erstellung')->helperText('Datum am Gutachten'),
|
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;
|
namespace App\Filament\Resources\Projektes\Tables;
|
||||||
|
|
||||||
use Filament\Actions\BulkActionGroup;
|
use App\Enums\ProjektStatus;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\SelectColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
class ProjektesTable
|
class ProjektesTable
|
||||||
@@ -13,18 +15,30 @@ class ProjektesTable
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->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([
|
->filters([
|
||||||
//
|
SelectFilter::make('status')
|
||||||
|
->options(ProjektStatus::class),
|
||||||
|
SelectFilter::make('gutachter')
|
||||||
|
->relationship('gutachter', 'company'),
|
||||||
|
SelectFilter::make('auftraggeber')
|
||||||
|
->relationship('auftraggeber', 'company'),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
EditAction::make()->iconButton()->color('gray'),
|
||||||
])
|
|
||||||
->toolbarActions([
|
|
||||||
BulkActionGroup::make([
|
|
||||||
DeleteBulkAction::make(),
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Scopes\KontoScope;
|
||||||
use Database\Factories\AuftraggeberFactory;
|
use Database\Factories\AuftraggeberFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
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
|
protected static function newFactory(): Factory
|
||||||
{
|
{
|
||||||
return AuftraggeberFactory::new();
|
return AuftraggeberFactory::new();
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,17 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class Projekte extends Model
|
class Projekte extends Model
|
||||||
{
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'konto_id',
|
||||||
|
'auftraggeber_id',
|
||||||
|
'gutachter_id',
|
||||||
|
'offizieller_name',
|
||||||
|
'interner_name',
|
||||||
|
'beschreibung',
|
||||||
|
'erstellung',
|
||||||
|
'status',
|
||||||
|
];
|
||||||
|
|
||||||
public function auftraggeber()
|
public function auftraggeber()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Auftraggeber::class);
|
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('auftraggeber_id')->constrained();
|
||||||
$table->foreignId('gutachter_id')->constrained();
|
$table->foreignId('gutachter_id')->constrained();
|
||||||
$table->string('interner_name');
|
$table->string('interner_name');
|
||||||
$table->string('ofizieller_name');
|
$table->string('offizieller_name');
|
||||||
$table->text('beschreibung')->nullable();
|
$table->text('beschreibung')->nullable();
|
||||||
$table->string('erstellung')->nullable();
|
$table->string('erstellung')->nullable();
|
||||||
$table->string('status')->default('entwurf');
|
$table->string('status')->default('entwurf');
|
||||||
|
|||||||
Reference in new issue
Block a user