This commit is contained in:
salam committed 2025-08-22 06:23:28 +02:00
1 parent e493c4ed42
commit 399b9d43a7
27 files changed
+605 -169

No files matched your search

@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Resources\Clients;
use App\Filament\Clusters\Maintenance\MaintenanceCluster;
use App\Filament\Resources\Clients\Pages\ListClients;
use App\Filament\Resources\Clients\Schemas\ClientForm;
use App\Filament\Resources\Clients\Tables\ClientsTable;
use App\Models\Client;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use UnitEnum;
class ClientResource extends Resource
{
protected static ?string $model = Client::class;
protected static ?int $navigationSort = 30;
protected static string|BackedEnum|null $navigationIcon = 'lucide-square-user';
protected static ?string $recordTitleAttribute = 'name';
protected static string|UnitEnum|null $navigationGroup = 'User Management';
protected static ?string $cluster = MaintenanceCluster::class;
public static function form(Schema $schema): Schema
{
return ClientForm::configure($schema);
}
public static function table(Table $table): Table
{
return ClientsTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListClients::route('/'),
];
}
public static function getNavigationBadge(): ?string
{
return parent::getEloquentQuery()->count();
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Clients\Pages;
use App\Filament\Resources\Clients\ClientResource;
use Filament\Resources\Pages\CreateRecord;
class CreateClient extends CreateRecord
{
protected static string $resource = ClientResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Clients\Pages;
use App\Filament\Resources\Clients\ClientResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditClient extends EditRecord
{
protected static string $resource = ClientResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Clients\Pages;
use App\Filament\Resources\Clients\ClientResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListClients extends ListRecords
{
protected static string $resource = ClientResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Filament\Resources\Clients\Schemas;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
class ClientForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('name')
->required(),
TextInput::make('icon'),
Select::make('bookmaker')
->relationship('bookmaker', 'name')
->multiple()
->preload()
->searchable(),
]);
}
}
@@ -0,0 +1,30 @@
<?php
namespace App\Filament\Resources\Clients\Tables;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Table;
class ClientsTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}
@@ -3,7 +3,7 @@
namespace App\Filament\Resources\Users\Schemas;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
@@ -23,11 +23,11 @@ class UserForm
TextInput::make('password')
->password()
->required(),
Textarea::make('custom_fields')
->default(null)
->columnSpanFull(),
TextInput::make('avatar_url')
->default(null),
Select::make('roles')
->relationship('roles', 'name')
->multiple()
->preload()
->searchable(),
]);
}
}
@@ -19,6 +19,8 @@ class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?int $navigationSort = 31;
protected static string|BackedEnum|null $navigationIcon = 'lucide-user';
protected static ?string $cluster = MaintenanceCluster::class;
+10
View File
@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Bookmaker extends Model
{
//
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Client extends Model
{
protected $fillable = [
'name',
'email',
'homepage',
];
public function client_sports()
{
return $this->hasMany(ClientSports::class);
}
public function client_bookmaker()
{
return $this->hasMany(ClientBookmaker::class);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ClientBookmaker extends Model
{
protected $fillable = [
'client_id',
'bookmaker_id',
'is_active',
];
public function customer()
{
return $this->belongsTo(Client::class);
}
public function bookmaker()
{
return $this->belongsTo(Bookmaker::class);
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Client;
use Illuminate\Auth\Access\HandlesAuthorization;
class ClientPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_clients::client');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Client $client): bool
{
return $user->can('view_clients::client');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_clients::client');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Client $client): bool
{
return $user->can('update_clients::client');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Client $client): bool
{
return $user->can('delete_clients::client');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_clients::client');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Client $client): bool
{
return $user->can('force_delete_clients::client');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_clients::client');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Client $client): bool
{
return $user->can('restore_clients::client');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_clients::client');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Client $client): bool
{
return $user->can('replicate_clients::client');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_clients::client');
}
}
+144
View File
@@ -0,0 +1,144 @@
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return bool
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_users::user');
}
/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function view(User $user): bool
{
return $user->can('view_users::user');
}
/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return bool
*/
public function create(User $user): bool
{
return $user->can('create_users::user');
}
/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function update(User $user): bool
{
return $user->can('update_users::user');
}
/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function delete(User $user): bool
{
return $user->can('delete_users::user');
}
/**
* Determine whether the user can bulk delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_users::user');
}
/**
* Determine whether the user can permanently delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function forceDelete(User $user): bool
{
return $user->can('force_delete_users::user');
}
/**
* Determine whether the user can permanently bulk delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_users::user');
}
/**
* Determine whether the user can restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function restore(User $user): bool
{
return $user->can('restore_users::user');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_users::user');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function replicate(User $user): bool
{
return $user->can('replicate_users::user');
}
/**
* Determine whether the user can reorder.
*
* @param \App\Models\User $user
* @return bool
*/
public function reorder(User $user): bool
{
return $user->can('reorder_users::user');
}
}