Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cklei-carly committed Sep 4, 2024
1 parent d74e1bc commit a57e9fc
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,38 @@ class NewsResource extends Resource
{
return $table
->columns([
Tables\Columns\Layout\Panel::make([
Tables\Columns\TextColumn::make('data')
->getStateUsing(fn ($record) => $record->setVisible(['title', 'short_desc', 'description'])->toJson()),
]),

Tables\Columns\ColumnGroup::make('Data')
->columns([
Tables\Columns\TextColumn::make('title')
->getStateUsing(fn ($record) => new HtmlString(collect($record->title)
->map(fn ($state, $locale) => <<<Html
<div class="flex gap-2">
<div class="text-sm text-gray-500">$locale</div>
<div>$state</div>
</div>
Html)
->implode(''))),
Tables\Columns\TextColumn::make('short_desc')
->getStateUsing(fn ($record) => new HtmlString(collect($record->short_desc)
->map(fn ($state, $locale) => <<<Html
<div class="flex gap-2">
<div class="text-sm text-gray-500">$locale</div>
<div>$state</div>
</div>
Html)
->implode(''))),
Tables\Columns\TextColumn::make('description')
->getStateUsing(fn ($record) => new HtmlString(collect($record->description)
->map(fn ($state, $locale) => <<<Html
<div class="flex gap-2">
<div class="text-sm text-gray-500">$locale</div>
<div>$state</div>
</div>
Html)
->implode(''))),
]),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Expand All @@ -407,6 +435,12 @@ class News extends Model

public $translatable = ['title', 'short_desc', 'description'];

public $casts = [
'title' => 'json',
'short_desc' => 'json',
'description' => 'json',
];

// ...
}
```
Expand Down

0 comments on commit a57e9fc

Please sign in to comment.