Skip to content

Commit

Permalink
style: update stylesheet for filament app + realistionResource et tes…
Browse files Browse the repository at this point in the history
…timonialresource
  • Loading branch information
frederic moras committed Dec 26, 2024
1 parent e39c356 commit 2203054
Show file tree
Hide file tree
Showing 20 changed files with 952 additions and 575 deletions.
99 changes: 99 additions & 0 deletions app/Filament/Resources/RealisationResource.php
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' ),
];
}
}
82 changes: 82 additions & 0 deletions app/Filament/Resources/TestimonialResource.php
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'),
];
}
}
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;
}
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;
}
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(),
];
}
}
25 changes: 25 additions & 0 deletions app/Models/Partner.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

/**
*
*
* @property int $id
* @property string $name
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read mixed $image
* @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection<int, \App\Models\CustomMedia> $media
* @property-read int|null $media_count
* @method static \Database\Factories\PartnerFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner newQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner query()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner withTrashed()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Partner withoutTrashed()
* @mixin \Eloquent
*/
class Partner extends Model implements HasMedia
{
use HasFactory, SoftDeletes, InteractsWithMedia;
Expand Down
5 changes: 4 additions & 1 deletion app/Models/Testimonial.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Spatie\MediaLibrary\MediaCollections\Models\Media;

/**
*
*
*
* @property-read mixed $image
* @property-read \Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection<int, \App\Models\CustomMedia> $media
Expand All @@ -37,6 +37,9 @@
* @method static \Illuminate\Database\Eloquent\Builder|Testimonial whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|Testimonial wherePublished($value)
* @method static \Illuminate\Database\Eloquent\Builder|Testimonial whereUpdatedAt($value)
* @property int|null $realisation_id
* @property-read \App\Models\Realisation|null $realisation
* @method static \Illuminate\Database\Eloquent\Builder<static>|Testimonial whereRealisationId($value)
* @mixin \Eloquent
*/
class Testimonial extends Model implements HasMedia
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"php": "^8.2",
"arcanedev/log-viewer": "^11.0",
"filament/filament": "^3.2",
"filament/spatie-laravel-media-library-plugin": "^3.2",
"laravel/framework": "^11.0",
"laravel/tinker": "^2.9",
"league/csv": "^9.18",
Expand Down Expand Up @@ -40,10 +41,10 @@
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi",
"@if DEV php artisan ide-helper:generate",
"@if DEV php artisan ide-helper:meta",
"@if DEV php artisan ide-helper:models",
"@if DEV php artisan filament:upgrade"
"@php artisan ide-helper:generate",
"@php artisan ide-helper:meta",
"@php artisan ide-helper:models",
"@php artisan filament:upgrade"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
Expand Down
Loading

0 comments on commit 2203054

Please sign in to comment.