Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskorbakov committed Oct 26, 2024
2 parents 1d72d25 + fb329f6 commit e820709
Show file tree
Hide file tree
Showing 44 changed files with 410 additions and 589 deletions.
12 changes: 9 additions & 3 deletions app/Filament/Resources/AchievementResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
class AchievementResource extends Resource
{
protected static ?string $model = Achievement::class;

protected static ?string $navigationIcon = 'heroicon-o-star';
protected static ?int $navigationSort = 1;

protected static ?int $navigationSort = 3;

protected static ?string $navigationLabel = 'Ачивки';

protected static ?string $modeLabel = 'Ачивки';

protected static ?string $pluralModelLabel = 'Ачивки';

protected static ?string $breadcrumb = 'Ачивки';

protected static ?string $label = 'Ачивку';
Expand Down Expand Up @@ -63,8 +69,8 @@ public static function table(Table $table): Table
->searchable(),
Tables\Columns\TextColumn::make('description')
->label('Описание')
->limit(20),
ImageColumn::make('image.path')
->limit(30),
ImageColumn::make('image')
->label('Изображение')
->default('-'),
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@

class CreateAchievement extends CreateRecord
{
public function getHeading(): string
{
return 'Создать ачивку';
}

protected static string $resource = AchievementResource::class;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

class EditAchievement extends EditRecord
{
public function getHeading(): string
{
return 'Изменить ачивку';
}

protected static string $resource = AchievementResource::class;

protected function getHeaderActions(): array
Expand Down
132 changes: 132 additions & 0 deletions app/Filament/Resources/ChallengeResource.php
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 app/Filament/Resources/ChallengeResource/Pages/CreateChallenge.php
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 app/Filament/Resources/ChallengeResource/Pages/EditChallenge.php
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 app/Filament/Resources/ChallengeResource/Pages/ListChallenges.php
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(),
];
}
}
111 changes: 111 additions & 0 deletions app/Filament/Resources/TeamResource.php
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'),
];
}
}
17 changes: 17 additions & 0 deletions app/Filament/Resources/TeamResource/Pages/CreateTeam.php
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;
}
Loading

0 comments on commit e820709

Please sign in to comment.