Proje dosyaları eklendi
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projects\Pages;
|
||||
|
||||
use App\Filament\Resources\Projects\ProjectResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProjects extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProjectResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projects\Pages;
|
||||
|
||||
use App\Filament\Resources\Projects\ProjectResource;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProject extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProjectResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projects;
|
||||
|
||||
use App\Filament\Resources\Projects\Pages\ListProjects;
|
||||
use App\Filament\Resources\Projects\Pages\ViewProject;
|
||||
use App\Filament\Resources\Projects\Schemas\ProjectInfolist;
|
||||
use App\Filament\Resources\Projects\Tables\ProjectsTable;
|
||||
use App\Models\Project;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProjectResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Project::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedGlobeAlt;
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('ui.projects');
|
||||
}
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('resources.project');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('ui.projects');
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return ProjectInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ProjectsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return ['index' => ListProjects::route('/'), 'view' => ViewProject::route('/{record}')];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projects\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProjectInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
TextEntry::make('name')->label(__('admin.project')),
|
||||
TextEntry::make('domain')->label(__('admin.domain')),
|
||||
TextEntry::make('url')->label(__('admin.root_url'))->url(fn ($record) => $record->url)->openUrlInNewTab(),
|
||||
TextEntry::make('user.name')->label(__('admin.customer')),
|
||||
TextEntry::make('user.email')->label(__('admin.email')),
|
||||
TextEntry::make('status')->label(__('admin.status'))->badge()->formatStateUsing(fn ($state) => $state->label()),
|
||||
TextEntry::make('ulid')->label(__('admin.project_id')),
|
||||
TextEntry::make('created_at')->label(__('admin.created_at'))->dateTime('d.m.Y H:i'),
|
||||
TextEntry::make('updated_at')->label(__('admin.updated_at'))->dateTime('d.m.Y H:i'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Projects\Tables;
|
||||
|
||||
use App\Enums\ProjectStatus;
|
||||
use App\Models\Project;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProjectsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')->label(__('admin.project'))->searchable()->sortable(),
|
||||
TextColumn::make('domain')->label(__('admin.domain'))->searchable()->sortable(),
|
||||
TextColumn::make('user.name')->label(__('admin.customer'))->searchable()->sortable(),
|
||||
TextColumn::make('user.email')->label(__('admin.email'))->searchable(),
|
||||
TextColumn::make('status')->label(__('admin.status'))->badge()->formatStateUsing(fn ($state) => $state->label()),
|
||||
TextColumn::make('created_at')->label(__('admin.created_at'))->dateTime('d.m.Y H:i')->sortable(),
|
||||
TextColumn::make('updated_at')->label(__('admin.updated_at'))->dateTime('d.m.Y H:i')->sortable(),
|
||||
])
|
||||
->filters([SelectFilter::make('status')->label(__('admin.status'))->options(['active' => __('states.active'), 'archived' => __('states.archived')])])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
Action::make('archive')->label(__('admin.archive'))->requiresConfirmation()
|
||||
->visible(fn (Project $record): bool => $record->status === ProjectStatus::Active && auth()->user()->can('archive', $record))
|
||||
->action(fn (Project $record) => $record->archive()),
|
||||
Action::make('restore')->label(__('admin.restore'))
|
||||
->visible(fn (Project $record): bool => $record->status === ProjectStatus::Archived && auth()->user()->can('restore', $record))
|
||||
->action(fn (Project $record) => $record->restoreProject()),
|
||||
])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user