-
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.
style: update stylesheet for filament app + realistionResource et tes…
…timonialresource
- Loading branch information
frederic moras
committed
Dec 26, 2024
1 parent
e39c356
commit 2203054
Showing
20 changed files
with
952 additions
and
575 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\RealisationResource\Pages; | ||
use App\Models\Realisation; | ||
use Filament\Forms; | ||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables\Columns\BooleanColumn; | ||
use Filament\Tables\Columns\ImageColumn; | ||
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Filters\Filter; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Components\Textarea; | ||
use Filament\Forms\Components\DatePicker; | ||
use Filament\Forms\Components\FileUpload; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Tables\Table; | ||
|
||
class RealisationResource extends Resource | ||
{ | ||
protected static ?string $model = Realisation::class; | ||
|
||
// protected static ?string $navigationIcon = 'heroicon-o-collection'; | ||
protected static ?string $pluralLabel = 'Realisations'; | ||
protected static ?string $navigationGroup = 'Content Management'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('title') | ||
->required() | ||
->maxLength(255), | ||
|
||
Textarea::make('description'), | ||
|
||
TextInput::make('category') | ||
->required(), | ||
|
||
TextInput::make('place'), | ||
|
||
DatePicker::make('date'), | ||
|
||
TextInput::make('customer'), | ||
|
||
SpatieMediaLibraryFileUpload::make('illustration') | ||
->responsiveImages() | ||
->collection( 'illustration'), | ||
|
||
SpatieMediaLibraryFileUpload::make('gallery') | ||
->responsiveImages() | ||
->multiple() | ||
->collection( 'gallery'), | ||
|
||
Select::make('published') | ||
->label('Published') | ||
->options([0 => 'No', 1 => 'Yes']) | ||
->default(0), | ||
|
||
Select::make('favorite') | ||
->label('Favorite') | ||
->options([0 => 'No', 1 => 'Yes']) | ||
->default(0), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
SpatieMediaLibraryImageColumn::make('illustration')->collection( 'illustration'), | ||
|
||
TextColumn::make('title')->sortable()->searchable(), | ||
TextColumn::make('category')->sortable()->searchable(), | ||
TextColumn::make('place')->sortable(), | ||
TextColumn::make('date')->date(), | ||
BooleanColumn::make('published'), | ||
BooleanColumn::make('favorite'), | ||
ImageColumn::make('illustration')->label('Illustration'), | ||
]) | ||
->filters([ | ||
Filter::make('published')->query(fn ($query) => $query->where('published', true)), | ||
Filter::make('favorite')->query(fn ($query) => $query->where('favorite', true)), | ||
]); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListRealisations::route( '/' ), | ||
'create' => Pages\CreateRealisation::route( '/create' ), | ||
'edit' => Pages\EditRealisation::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,82 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\TestimonialResource\Pages; | ||
use App\Models\Testimonial; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables\Columns\BooleanColumn; | ||
use Filament\Tables\Columns\TextColumn; | ||
|
||
use Filament\Tables\Filters\SelectFilter; | ||
use Filament\Tables\Table; | ||
|
||
|
||
class TestimonialResource extends Resource | ||
{ | ||
protected static ?string $model = Testimonial::class; | ||
|
||
// protected static ?string $navigationIcon = 'heroicon-o-annotation'; | ||
|
||
protected static ?string $navigationGroup = 'Content Management'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('author') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\Textarea::make('content') | ||
->required(), | ||
Forms\Components\TextInput::make('city') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\Toggle::make('published') | ||
->label('Published') | ||
->default(false), | ||
Forms\Components\DateTimePicker::make('created_at') | ||
->label('Created At'), | ||
|
||
Forms\Components\Select::make('realisation_id') | ||
->relationship('realisation', 'title') | ||
->nullable(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
TextColumn::make('author')->sortable()->searchable(), | ||
TextColumn::make('content') | ||
->limit(50) | ||
->sortable(), | ||
TextColumn::make('city')->sortable()->searchable(), | ||
BooleanColumn::make('published') | ||
->label('Published'), | ||
TextColumn::make('created_at') | ||
->dateTime() | ||
->label('Created At'), | ||
]) | ||
->filters([ | ||
SelectFilter::make('published') | ||
->options([ | ||
1 => 'Published', | ||
0 => 'Unpublished', | ||
]), | ||
]) | ||
->defaultSort('created_at', 'desc'); | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListTestimonials::route('/'), | ||
'create' => Pages\CreateTestimonial::route('/create'), | ||
'edit' => Pages\EditTestimonial::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Resources/TestimonialResource/Pages/CreateTestimonial.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,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\TestimonialResource\Pages; | ||
|
||
use App\Filament\Resources\TestimonialResource; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateTestimonial extends CreateRecord | ||
{ | ||
protected static string $resource = TestimonialResource::class; | ||
} |
11 changes: 11 additions & 0 deletions
11
app/Filament/Resources/TestimonialResource/Pages/EditTestimonial.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,11 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\TestimonialResource\Pages; | ||
|
||
use App\Filament\Resources\TestimonialResource; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditTestimonial extends EditRecord | ||
{ | ||
protected static string $resource = TestimonialResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/TestimonialResource/Pages/ListTestimonials.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\TestimonialResource\Pages; | ||
|
||
use App\Filament\Resources\TestimonialResource; | ||
use Filament\Pages\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListTestimonials extends ListRecords | ||
{ | ||
protected static string $resource = TestimonialResource::class; | ||
|
||
protected function getActions(): 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
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
Oops, something went wrong.