Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gheorghelupu17 authored Oct 14, 2024
2 parents 6149ff8 + 045dfe0 commit d9fbb36
Show file tree
Hide file tree
Showing 54 changed files with 2,243 additions and 2,998 deletions.
1 change: 1 addition & 0 deletions app/Concerns/Enums/Comparable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ trait Comparable
*/
public function is(mixed $enum): bool
{

if ($enum instanceof static) {
return $this->value === $enum->value;
}
Expand Down
24 changes: 24 additions & 0 deletions app/Enums/GalaProjectStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Enums;

use App\Concerns\Enums\Arrayable;
use App\Concerns\Enums\Comparable;
use App\Concerns\Enums\HasLabel;

enum GalaProjectStatus: string
{
use Arrayable;
use Comparable;
use HasLabel;

case draft = 'draft';
case publish = 'published';

protected function labelKeyPrefix(): ?string
{
return 'project.gala_project_status_ar';
}
}
1 change: 0 additions & 1 deletion app/Enums/ProjectArea.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ enum ProjectArea: string

case LOCAL = 'local';
case REGIONAL = 'regional';
case NATIONAL = 'national';

public function labelKeyPrefix(): string
{
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/EditionsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static function table(Table $table): Table
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('categories')
Tables\Columns\TextColumn::make('editionCategories.name')
->label(__('edition.labels.categories'))
->searchable()
->sortable(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace App\Filament\Resources\EditionsResource\RelationManagers;

use App\Models\EditionCategories;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;

class PrizesRelationManager extends RelationManager
{
Expand All @@ -20,22 +20,19 @@ class PrizesRelationManager extends RelationManager
public static function form(Form $form): Form
{
return $form
->columns(1)
->schema([
Forms\Components\TextInput::make('name')
->required()
->label(__('edition.labels.prize_name'))
->maxLength(255)
->label(__('edition.labels.prize_name')),
->required(),

Forms\Components\Select::make('edition_categories_id')
->options(
fn (RelationManager $livewire) => EditionCategories::query()
->whereBelongsTo($livewire->ownerRecord)
->get()
->pluck('name', 'id')
)
->label(__('edition.labels.category'))
->columnSpanFull()
->required()
->relationship('editionCategories', 'name', function (Builder $query, self $livewire) {
$query->whereBelongsTo($livewire->ownerRecord);
})
->searchable()
->preload(),
]);
}
Expand All @@ -49,11 +46,8 @@ public static function table(Table $table): Table
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('edition_categories_id')
Tables\Columns\TextColumn::make('editionCategories.name')
->label(__('edition.labels.category'))
->formatStateUsing(
fn ($state, $record) => $record->editionCategories()->getParent()->name
)
->searchable()
->sortable(),
])
Expand Down
78 changes: 53 additions & 25 deletions app/Filament/Resources/GalaProjectResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

namespace App\Filament\Resources;

use App\Enums\GalaProjectStatus;
use App\Enums\OrganizationType;
use App\Enums\ProjectArea;
use App\Filament\Forms\Components\Value;
use App\Filament\Resources\GalaProjectResource\Pages;
use App\Models\Edition;
use App\Filament\Resources\GalaProjectResource\RelationManagers\PrizesRelationManager;
use App\Forms\Components\Link;
use App\Models\GalaProject;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
Expand Down Expand Up @@ -44,15 +48,26 @@ public static function getPluralLabel(): string
return __('edition.project.label.plural');
}

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->with(['gala']);
}
// public static function getEloquentQuery(): Builder
// {
// return parent::getEloquentQuery()->with(['gala']);
// }

public static function form(Form $form): Form
{
return $form
->schema([
Value::make('created_at')
->label(__('edition.labels.created_at'))
->inlineLabel()
->withTime(),

Link::make('organizatii')
->type('organization')
->label(__('organization.label.singular'))
->inlineLabel()
->columnSpanFull(),

Select::make('gala')
->label(__('edition.labels.gala'))
->relationship(
Expand Down Expand Up @@ -113,6 +128,15 @@ function (Builder $query, GalaProject $record) {
->inlineLabel()
->required(),

SpatieMediaLibraryFileUpload::make('regionalProjectFiles')
->label(__('project.labels.gallery'))
->collection('regionalProjectFiles')
->inlineLabel()
->disk(config('filesystems.default_public'))
->image()
->multiple()
->maxFiles(20),

Toggle::make('youth')
->label(__('edition.labels.youth_project'))
->inlineLabel()
Expand Down Expand Up @@ -198,33 +222,33 @@ function (Builder $query, GalaProject $record) {

public static function table(Table $table): Table
{
$editions = Edition::all();

return $table
->columns([
Tables\Columns\TextColumn::make('title')
Tables\Columns\TextColumn::make('id')
->label(__('edition.labels.id'))
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('name')
->label(__('edition.project.label.plural'))
->searchable()
->wrap()
->sortable(),

Tables\Columns\TextColumn::make('categories.name')
->label(__('edition.labels.category'))
->searchable()
->sortable(),
->wrap(),

Tables\Columns\TextColumn::make('youth')
->label(__('edition.labels.youth'))
->formatStateUsing(fn ($state) => $state ? __('field.boolean.true') : __('field.boolean.false'))
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('gala.edition.title')
->label(__('edition.label.singular'))
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('gala.title')
->label(__('edition.labels.gala'))
->description(fn ($record) => $record->gala->edition->title)
->searchable()
->sortable(),

Expand All @@ -233,6 +257,11 @@ public static function table(Table $table): Table
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('created_at')
->label(__('edition.labels.created_at'))
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('eligible')
->label(__('edition.labels.eligible'))
->formatStateUsing(fn ($state) => ! isset($state) ? '-' : ($state ? __('field.boolean.true') : __('field.boolean.false')))
Expand All @@ -248,12 +277,7 @@ public static function table(Table $table): Table
->filters([
SelectFilter::make('edition_id')
->label(__('edition.label.singular'))
->options($editions->pluck('title', 'id')->toArray())
// ->query(
// function ($query, $values) {
// dd($values);
// }
// )
->relationship('edition', 'title')
->multiple(),

SelectFilter::make('galas')
Expand All @@ -280,23 +304,27 @@ public static function table(Table $table): Table
]),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
//
])
->defaultSort('id', 'desc');
}

public static function getRelations(): array
{
return [
//
PrizesRelationManager::class,
];
}

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->where('status', GalaProjectStatus::publish);
}

public static function getPages(): array
{
return [
'index' => Pages\ListGalaProjects::route('/'),
'create' => Pages\CreateGalaProject::route('/create'),
'edit' => Pages\EditGalaProject::route('/{record}/edit'),
'view' => Pages\ViewGalaProject::route('/{record}'),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Filament\Resources\GalaProjectResource\Actions\Page;

use App\Models\GalaProject;
use Filament\Pages\Actions\Action;

class AddToShortListAction extends Action
Expand All @@ -19,8 +20,16 @@ protected function setUp(): void

$this->label(__('edition.actions.add-to-short-list'));

$this->action(function () {
$this->getRecord()->addToShortList();
$this->color('success');

$this->icon('heroicon-s-plus-circle');

$this->outlined();

$this->action(function (GalaProject $record) {
$record->addToShortList();
});

$this->hidden(fn (GalaProject $record) => $record->short_list === true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Filament\Resources\GalaProjectResource\Actions\Page;

use App\Models\GalaProject;
use Filament\Pages\Actions\Action;

class MarkAsEligibleAction extends Action
Expand All @@ -19,8 +20,14 @@ protected function setUp(): void

$this->label(__('edition.actions.mark-as-eligible'));

$this->action(function () {
$this->getRecord()->markAsEligible();
$this->color('success');

$this->icon('heroicon-o-check-circle');

$this->action(function (GalaProject $record) {
$record->markAsEligible();
});

$this->hidden(fn (GalaProject $record) => $record->eligible === true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Filament\Resources\GalaProjectResource\Actions\Page;

use App\Models\GalaProject;
use Filament\Pages\Actions\Action;

class MarkAsIneligibleAction extends Action
Expand All @@ -19,8 +20,14 @@ protected function setUp(): void

$this->label(__('edition.actions.mark-as-ineligible'));

$this->action(function () {
$this->getRecord()->markAsIneligible();
$this->color('danger');

$this->icon('heroicon-o-x-circle');

$this->action(function (GalaProject $record) {
$record->markAsIneligible();
});

$this->hidden(fn (GalaProject $record) => $record->eligible === false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Filament\Resources\GalaProjectResource\Actions\Page;

use App\Models\GalaProject;
use Filament\Pages\Actions\Action;

class RemoveFromShortListAction extends Action
Expand All @@ -19,8 +20,16 @@ protected function setUp(): void

$this->label(__('edition.actions.remove-from-short-list'));

$this->action(function () {
$this->getRecord()->removeFromShortList();
$this->color('danger');

$this->icon('heroicon-s-minus-circle');

$this->outlined();

$this->action(function (GalaProject $record) {
$record->removeFromShortList();
});

$this->hidden(fn (GalaProject $record) => $record->short_list === false);
}
}

This file was deleted.

Loading

0 comments on commit d9fbb36

Please sign in to comment.