Skip to content

Instantly share code, notes, and snippets.

@AAbosham
Last active March 15, 2024 03:06
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save AAbosham/c6be7f2fac17bd3662a21d9f5da19156 to your computer and use it in GitHub Desktop.
Save AAbosham/c6be7f2fac17bd3662a21d9f5da19156 to your computer and use it in GitHub Desktop.
Filament Card Table Layout
<?php
namespace App\Filament\Resources\Trip;
//...
class PlaceResource extends Resource
{
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\Layout\Split::make([
Tables\Columns\Layout\Grid::make()
->schema([
Tables\Columns\Layout\Grid::make()
->schema([
SpatieMediaLibraryImageColumn::make('image')
->collection('images')
->height('200px')
->extraAttributes([
'style' => app()->getLocale() == 'ar' ? 'margin:-12px -16px 0px -40px' : 'margin:-12px -40px 0px -16px',
])
->extraImgAttributes([
'class' => 'object-cover h-fit rounded-t-xl w-full',
]),
])
->columns(1),
Tables\Columns\Layout\Grid::make()
->schema([
Tables\Columns\TextColumn::make('name')
->searchable()
->extraAttributes([
'class' => 'text-gray-500 dark:text-gray-300 text-xs'
])
->columnSpan(2),
Tables\Columns\TextColumn::make('created_at')
->since()
->sortable()
->extraAttributes([
'class' => 'text-gray-500 dark:text-gray-300 text-xs'
])
->alignEnd(),
])
->extraAttributes([
'class' => 'mt-2 -mr-6 rtl:-ml-6 rtl:mr-0'
])
->columns(3),
Tables\Columns\Layout\Grid::make()
->schema([
Tables\Columns\TextColumn::make('created_by')
->default('Admin')
->extraAttributes([
'class' => 'text-gray-500 dark:text-gray-300 text-xs'
])
->alignEnd(),
])
->extraAttributes([
'class' => '-mr-6 rtl:-ml-6 rtl:mr-0'
])
->columns(1),
Tables\Columns\Layout\Grid::make()
->schema([
Tables\Columns\TextColumn::make('description')
->extraAttributes([
'class' => 'text-gray-700 dark:text-gray-300 text-xs'
])
->alignJustify(),
])
->columns(1)
->extraAttributes([
'class' => 'mb-3 -mr-6 rtl:-ml-6 rtl:mr-0'
]),
])
->columns(1),
]),
])
->defaultSort('created_by','desc')
->contentGrid([
'md' => 2,
'xl' => 4,
'2xl' => 5,
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment