-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
- Loading branch information
Showing
44 changed files
with
410 additions
and
589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\ChallengeResource\Pages; | ||
use App\Models\Challenge; | ||
use Filament\Forms; | ||
use Filament\Forms\Components\DateTimePicker; | ||
use Filament\Forms\Components\FileUpload; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Columns\ImageColumn; | ||
use Filament\Tables\Table; | ||
|
||
class ChallengeResource extends Resource | ||
{ | ||
protected static ?string $model = Challenge::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-bolt'; | ||
|
||
protected static ?int $navigationSort = 2; | ||
|
||
protected static ?string $navigationLabel = 'Челленджи'; | ||
|
||
protected static ?string $modeLabel = 'Челленджи'; | ||
|
||
protected static ?string $pluralModelLabel = 'Челленджи'; | ||
|
||
protected static ?string $breadcrumb = 'Челленджи'; | ||
|
||
protected static ?string $label = 'Челлендж'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->label('Название') | ||
->required() | ||
->maxWidth('sm'), | ||
Forms\Components\Textarea::make('description') | ||
->label('Описание') | ||
->rows(5), | ||
Forms\Components\Section::make()->schema([ | ||
DateTimePicker::make('start_date') | ||
->label('Дата начала') | ||
->default(now()), | ||
DateTimePicker::make('end_date') | ||
->label('Дата окончания') | ||
->nullable(), | ||
])->columns(), | ||
Forms\Components\Textarea::make('result') | ||
->label('Результаты завершения челленджа') | ||
->rows(5), | ||
Forms\Components\Select::make('achievement_id') | ||
->label('Ачивка') | ||
->relationship('achievement', 'name') | ||
->nullable(), | ||
FileUpload::make('image') | ||
->rules(['image']) | ||
->nullable() | ||
->image() | ||
->imageCropAspectRatio('1:1') | ||
->disk('public') | ||
->directory('achievements') | ||
->visibility('public') | ||
->maxWidth('xs') | ||
->label('Изображение') | ||
])->columns(1); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->label('Название') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('description') | ||
->label('Описание') | ||
->limit(30), | ||
Tables\Columns\TextColumn::make('start_date') | ||
->dateTime('d F') | ||
->label('Дата начала'), | ||
Tables\Columns\TextColumn::make('end_date') | ||
->dateTime('d F') | ||
->label('Дата оконачания'), | ||
Tables\Columns\TextColumn::make('achievement.name') | ||
->label('Ачивка') | ||
->default('-') | ||
->url( | ||
fn ($record) => | ||
! is_null($record->achievement) | ||
? "/admin/achievements/{$record->achievement->id}/edit" | ||
: null, | ||
true | ||
), | ||
ImageColumn::make('image') | ||
->label('Изображение') | ||
->default('-'), | ||
|
||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListChallenges::route('/'), | ||
'create' => Pages\CreateChallenge::route('/create'), | ||
'edit' => Pages\EditChallenge::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Filament/Resources/ChallengeResource/Pages/CreateChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\ChallengeResource\Pages; | ||
|
||
use App\Filament\Resources\ChallengeResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateChallenge extends CreateRecord | ||
{ | ||
public function getHeading(): string | ||
{ | ||
return 'Создать челлендж'; | ||
} | ||
|
||
protected static string $resource = ChallengeResource::class; | ||
} |
24 changes: 24 additions & 0 deletions
24
app/Filament/Resources/ChallengeResource/Pages/EditChallenge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\ChallengeResource\Pages; | ||
|
||
use App\Filament\Resources\ChallengeResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditChallenge extends EditRecord | ||
{ | ||
public function getHeading(): string | ||
{ | ||
return 'Изменить челлендж'; | ||
} | ||
|
||
protected static string $resource = ChallengeResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/ChallengeResource/Pages/ListChallenges.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\ChallengeResource\Pages; | ||
|
||
use App\Filament\Resources\ChallengeResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListChallenges extends ListRecords | ||
{ | ||
protected static string $resource = ChallengeResource::class; | ||
|
||
protected function getHeaderActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\TeamResource\Pages; | ||
use App\Models\Team; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
|
||
class TeamResource extends Resource | ||
{ | ||
protected static ?string $model = Team::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-user-group'; | ||
|
||
protected static ?int $navigationSort = 4; | ||
|
||
protected static ?string $navigationLabel = 'Команды'; | ||
|
||
protected static ?string $modeLabel = 'Команды'; | ||
|
||
protected static ?string $pluralModelLabel = 'Команды'; | ||
|
||
protected static ?string $breadcrumb = 'Команды'; | ||
|
||
protected static ?string $label = 'Команда'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->label('Название') | ||
->required() | ||
->maxWidth('sm'), | ||
Forms\Components\Textarea::make('description') | ||
->label('Описание') | ||
->rows(5), | ||
Forms\Components\Section::make() | ||
->schema([ | ||
Forms\Components\Select::make('users') | ||
->label('Участники') | ||
->relationship('users', 'name') | ||
->multiple(), | ||
Forms\Components\Select::make('achievements') | ||
->label('Достижения') | ||
->relationship('achievements', 'name') | ||
->multiple(), | ||
])->columns(2) | ||
])->columns(1); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->label('Название') | ||
->searchable(), | ||
Tables\Columns\TextColumn::make('description') | ||
->label('Описание') | ||
->limit(40), | ||
Tables\Columns\TextColumn::make('users_count') | ||
->counts('users') | ||
->badge() | ||
->color( | ||
fn($record) => $record->users->count() > 0 | ||
? 'success' : 'danger' | ||
) | ||
->label('Участников'), | ||
Tables\Columns\TextColumn::make('achievements_count') | ||
->counts('achievements') | ||
->badge() | ||
->color( | ||
fn($record) => $record->achievements->count() > 0 | ||
? 'success' : 'danger' | ||
) | ||
->label('Достижений') | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListTeams::route('/'), | ||
'create' => Pages\CreateTeam::route('/create'), | ||
'edit' => Pages\EditTeam::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\TeamResource\Pages; | ||
|
||
use App\Filament\Resources\TeamResource; | ||
use Filament\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateTeam extends CreateRecord | ||
{ | ||
public function getHeading(): string | ||
{ | ||
return 'Создать команду'; | ||
} | ||
|
||
protected static string $resource = TeamResource::class; | ||
} |
Oops, something went wrong.