Skip to content

Commit 8e5eecd

Browse files
Update dependencies
1 parent d3f4317 commit 8e5eecd

File tree

6 files changed

+205
-72
lines changed

6 files changed

+205
-72
lines changed

app/Filament/App/Resources/ContentBlockResource.php

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
namespace App\Filament\App\Resources;
44

5+
use Filament\Forms\Components\RichEditor;
6+
use Filament\Forms\Components\KeyValue;
7+
use Filament\Tables\Filters\SelectFilter;
8+
use Filament\Tables\Filters\Filter;
9+
use Filament\Actions\ActionGroup;
10+
use Filament\Actions\ViewAction;
11+
use Filament\Actions\EditAction;
12+
use Filament\Actions\Action;
13+
use Filament\Actions\DeleteAction;
14+
use Filament\Actions\BulkActionGroup;
15+
use Filament\Actions\DeleteBulkAction;
16+
use Filament\Actions\BulkAction;
17+
use App\Filament\App\Resources\ContentBlockResource\Pages\ListContentBlocks;
18+
use App\Filament\App\Resources\ContentBlockResource\Pages\CreateContentBlock;
19+
use App\Filament\App\Resources\ContentBlockResource\Pages\EditContentBlock;
520
use App\Models\ContentBlock;
621
use Filament\Forms;
722
use Filament\Schemas\Schema;
@@ -55,11 +70,11 @@ public static function form(Schema $schema): Schema
5570
Textarea::make('description')
5671
->rows(3),
5772

58-
Forms\Components\RichEditor::make('content')
73+
RichEditor::make('content')
5974
->label('Block Content')
6075
->columnSpanFull(),
6176

62-
Forms\Components\KeyValue::make('settings')
77+
KeyValue::make('settings')
6378
->label('Block Settings')
6479
->keyLabel('Setting Name')
6580
->valueLabel('Setting Value'),
@@ -112,10 +127,10 @@ public static function table(Table $table): Table
112127
->toggleable(isToggledHiddenByDefault: true),
113128
])
114129
->filters([
115-
Tables\Filters\SelectFilter::make('type')
130+
SelectFilter::make('type')
116131
->options(array_map(fn($type) => $type['name'], ContentBlock::getAvailableTypes())),
117132

118-
Tables\Filters\SelectFilter::make('category')
133+
SelectFilter::make('category')
119134
->options([
120135
'content' => 'Content',
121136
'media' => 'Media',
@@ -124,33 +139,33 @@ public static function table(Table $table): Table
124139
'advanced' => 'Advanced',
125140
]),
126141

127-
Tables\Filters\Filter::make('is_active')
142+
Filter::make('is_active')
128143
->query(fn (Builder $query): Builder => $query->where('is_active', true))
129144
->label('Active Only'),
130145
])
131-
->actions([
132-
Tables\Actions\ActionGroup::make([
133-
Tables\Actions\ViewAction::make(),
134-
Tables\Actions\EditAction::make(),
135-
Tables\Actions\Action::make('duplicate')
146+
->recordActions([
147+
ActionGroup::make([
148+
ViewAction::make(),
149+
EditAction::make(),
150+
Action::make('duplicate')
136151
->icon('heroicon-o-document-duplicate')
137152
->action(fn (ContentBlock $record) => $record->duplicate()),
138-
Tables\Actions\Action::make('toggle_active')
153+
Action::make('toggle_active')
139154
->icon('heroicon-o-power')
140155
->action(fn (ContentBlock $record) => $record->update(['is_active' => !$record->is_active]))
141156
->color(fn (ContentBlock $record) => $record->is_active ? 'danger' : 'success')
142157
->label(fn (ContentBlock $record) => $record->is_active ? 'Deactivate' : 'Activate'),
143-
Tables\Actions\DeleteAction::make(),
158+
DeleteAction::make(),
144159
]),
145160
])
146-
->bulkActions([
147-
Tables\Actions\BulkActionGroup::make([
148-
Tables\Actions\DeleteBulkAction::make(),
149-
Tables\Actions\BulkAction::make('activate')
161+
->toolbarActions([
162+
BulkActionGroup::make([
163+
DeleteBulkAction::make(),
164+
BulkAction::make('activate')
150165
->icon('heroicon-o-check')
151166
->action(fn (Collection $records) => $records->each->update(['is_active' => true]))
152167
->deselectRecordsAfterCompletion(),
153-
Tables\Actions\BulkAction::make('deactivate')
168+
BulkAction::make('deactivate')
154169
->icon('heroicon-o-x-mark')
155170
->action(fn (Collection $records) => $records->each->update(['is_active' => false]))
156171
->deselectRecordsAfterCompletion(),
@@ -161,9 +176,9 @@ public static function table(Table $table): Table
161176
public static function getPages(): array
162177
{
163178
return [
164-
'index' => Pages\ListContentBlocks::route('/'),
165-
'create' => Pages\CreateContentBlock::route('/create'),
166-
'edit' => Pages\EditContentBlock::route('/{record}/edit'),
179+
'index' => ListContentBlocks::route('/'),
180+
'create' => CreateContentBlock::route('/create'),
181+
'edit' => EditContentBlock::route('/{record}/edit'),
167182
];
168183
}
169184
}

app/Filament/App/Resources/ContentResource.php

Lines changed: 50 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
namespace App\Filament\App\Resources;
44

5+
use Filament\Schemas\Components\Tabs;
6+
use Filament\Schemas\Components\Tabs\Tab;
7+
use Str;
8+
use Filament\Forms\Components\Toggle;
9+
use Filament\Forms\Components\TagsInput;
10+
use Filament\Forms\Components\Repeater;
11+
use Filament\Tables\Columns\IconColumn;
12+
use Filament\Tables\Filters\SelectFilter;
13+
use Filament\Tables\Filters\Filter;
14+
use Filament\Actions\ActionGroup;
15+
use Filament\Actions\ViewAction;
16+
use Filament\Actions\Action;
17+
use Filament\Actions\DeleteAction;
18+
use Filament\Actions\BulkAction;
519
use Filament\Actions\EditAction;
620
use Filament\Actions\BulkActionGroup;
721
use Filament\Actions\DeleteBulkAction;
@@ -24,7 +38,6 @@
2438
use Filament\Forms\Components\DateTimePicker;
2539
use Filament\Forms\Components\FileUpload;
2640
use Filament\Forms\Components\Section;
27-
use Filament\Forms\Components\Tabs;
2841
use Illuminate\Database\Eloquent\Builder;
2942
use Illuminate\Database\Eloquent\SoftDeletingScope;
3043
use App\Filament\App\Resources\ContentResource\Pages;
@@ -42,14 +55,14 @@ public static function form(Schema $schema): Schema
4255
->components([
4356
Tabs::make('Content')
4457
->tabs([
45-
Tabs\Tab::make('Content')
58+
Tab::make('Content')
4659
->schema([
4760
TextInput::make('title')
4861
->required()
4962
->maxLength(255)
5063
->live(onBlur: true)
5164
->afterStateUpdated(fn (string $context, $state, callable $set) =>
52-
$context === 'create' ? $set('slug', \Str::slug($state)) : null
65+
$context === 'create' ? $set('slug', Str::slug($state)) : null
5366
),
5467

5568
TextInput::make('slug')
@@ -89,7 +102,7 @@ public static function form(Schema $schema): Schema
89102
->directory('featured-images'),
90103
]),
91104

92-
Tabs\Tab::make('SEO')
105+
Tab::make('SEO')
93106
->schema([
94107
TextInput::make('seo_title')
95108
->label('SEO Title')
@@ -111,7 +124,7 @@ public static function form(Schema $schema): Schema
111124
->url(),
112125
]),
113126

114-
Tabs\Tab::make('Settings')
127+
Tab::make('Settings')
115128
->schema([
116129
Select::make('workflow_status')
117130
->options([
@@ -147,17 +160,17 @@ public static function form(Schema $schema): Schema
147160
])
148161
->default('default'),
149162

150-
Forms\Components\Toggle::make('is_featured')
163+
Toggle::make('is_featured')
151164
->label('Featured Content'),
152165

153-
Forms\Components\Toggle::make('is_sticky')
166+
Toggle::make('is_sticky')
154167
->label('Sticky Post'),
155168

156-
Forms\Components\Toggle::make('allow_comments')
169+
Toggle::make('allow_comments')
157170
->label('Allow Comments')
158171
->default(true),
159172

160-
Forms\Components\Toggle::make('password_protected')
173+
Toggle::make('password_protected')
161174
->label('Password Protected')
162175
->reactive(),
163176

@@ -167,18 +180,18 @@ public static function form(Schema $schema): Schema
167180
->visible(fn (callable $get) => $get('password_protected')),
168181
]),
169182

170-
Tabs\Tab::make('Advanced')
183+
Tab::make('Advanced')
171184
->schema([
172185
Textarea::make('excerpt')
173186
->label('Custom Excerpt')
174187
->rows(3)
175188
->helperText('Leave empty to auto-generate from content'),
176189

177-
Forms\Components\TagsInput::make('tags')
190+
TagsInput::make('tags')
178191
->label('Tags')
179192
->separator(','),
180193

181-
Forms\Components\Repeater::make('custom_fields')
194+
Repeater::make('custom_fields')
182195
->label('Custom Fields')
183196
->schema([
184197
TextInput::make('key')
@@ -253,10 +266,10 @@ public static function table(Table $table): Table
253266
->label('Score')
254267
->formatStateUsing(fn ($state) => $state ? round($state) . '%' : 'N/A')
255268
->color(fn ($state) => $state >= 80 ? 'success' : ($state >= 60 ? 'warning' : 'danger')),
256-
Tables\Columns\IconColumn::make('is_featured')
269+
IconColumn::make('is_featured')
257270
->boolean()
258271
->label('Featured'),
259-
Tables\Columns\IconColumn::make('is_sticky')
272+
IconColumn::make('is_sticky')
260273
->boolean()
261274
->label('Sticky'),
262275
TextColumn::make('published_at')
@@ -269,7 +282,7 @@ public static function table(Table $table): Table
269282
->toggleable(isToggledHiddenByDefault: true),
270283
])
271284
->filters([
272-
Tables\Filters\SelectFilter::make('workflow_status')
285+
SelectFilter::make('workflow_status')
273286
->options([
274287
'draft' => 'Draft',
275288
'review' => 'In Review',
@@ -278,45 +291,45 @@ public static function table(Table $table): Table
278291
'scheduled' => 'Scheduled',
279292
'rejected' => 'Rejected',
280293
]),
281-
Tables\Filters\SelectFilter::make('type')
294+
SelectFilter::make('type')
282295
->options([
283296
'post' => 'Post',
284297
'page' => 'Page',
285298
'news' => 'News',
286299
'blog' => 'Blog',
287300
]),
288-
Tables\Filters\SelectFilter::make('author')
301+
SelectFilter::make('author')
289302
->relationship('author', 'name'),
290-
Tables\Filters\SelectFilter::make('category')
303+
SelectFilter::make('category')
291304
->relationship('category', 'name'),
292-
Tables\Filters\Filter::make('is_featured')
305+
Filter::make('is_featured')
293306
->query(fn (Builder $query): Builder => $query->where('is_featured', true))
294307
->label('Featured Only'),
295-
Tables\Filters\Filter::make('is_sticky')
308+
Filter::make('is_sticky')
296309
->query(fn (Builder $query): Builder => $query->where('is_sticky', true))
297310
->label('Sticky Only'),
298-
Tables\Filters\Filter::make('published_today')
311+
Filter::make('published_today')
299312
->query(fn (Builder $query): Builder => $query->whereDate('published_at', today()))
300313
->label('Published Today'),
301-
Tables\Filters\Filter::make('published_this_week')
314+
Filter::make('published_this_week')
302315
->query(fn (Builder $query): Builder => $query->whereBetween('published_at', [now()->startOfWeek(), now()->endOfWeek()]))
303316
->label('Published This Week'),
304317
])
305318
->recordActions([
306-
Tables\Actions\ActionGroup::make([
307-
Tables\Actions\ViewAction::make(),
308-
Tables\Actions\EditAction::make(),
309-
Tables\Actions\Action::make('publish')
319+
ActionGroup::make([
320+
ViewAction::make(),
321+
EditAction::make(),
322+
Action::make('publish')
310323
->icon('heroicon-o-eye')
311324
->color('success')
312325
->action(fn (Content $record) => $record->publish())
313326
->visible(fn (Content $record) => !$record->isPublished()),
314-
Tables\Actions\Action::make('feature')
327+
Action::make('feature')
315328
->icon('heroicon-o-star')
316329
->color('warning')
317330
->action(fn (Content $record) => $record->update(['is_featured' => !$record->is_featured]))
318331
->label(fn (Content $record) => $record->is_featured ? 'Unfeature' : 'Feature'),
319-
Tables\Actions\Action::make('duplicate')
332+
Action::make('duplicate')
320333
->icon('heroicon-o-document-duplicate')
321334
->action(function (Content $record) {
322335
$newContent = $record->replicate();
@@ -326,30 +339,30 @@ public static function table(Table $table): Table
326339
$newContent->published_at = null;
327340
$newContent->save();
328341
}),
329-
Tables\Actions\DeleteAction::make(),
342+
DeleteAction::make(),
330343
]),
331344
])
332-
->bulkActions([
333-
Tables\Actions\BulkActionGroup::make([
334-
Tables\Actions\DeleteBulkAction::make(),
335-
Tables\Actions\BulkAction::make('publish')
345+
->toolbarActions([
346+
BulkActionGroup::make([
347+
DeleteBulkAction::make(),
348+
BulkAction::make('publish')
336349
->icon('heroicon-o-eye')
337350
->color('success')
338351
->action(fn (Collection $records) => $records->each->publish())
339352
->deselectRecordsAfterCompletion(),
340-
Tables\Actions\BulkAction::make('feature')
353+
BulkAction::make('feature')
341354
->icon('heroicon-o-star')
342355
->color('warning')
343356
->action(fn (Collection $records) => Content::bulkFeature($records->pluck('id')->toArray(), true))
344357
->deselectRecordsAfterCompletion(),
345-
Tables\Actions\BulkAction::make('unfeature')
358+
BulkAction::make('unfeature')
346359
->icon('heroicon-o-star')
347360
->color('gray')
348361
->action(fn (Collection $records) => Content::bulkFeature($records->pluck('id')->toArray(), false))
349362
->deselectRecordsAfterCompletion(),
350-
Tables\Actions\BulkAction::make('change_status')
363+
BulkAction::make('change_status')
351364
->icon('heroicon-o-pencil-square')
352-
->form([
365+
->schema([
353366
Select::make('workflow_status')
354367
->options([
355368
'draft' => 'Draft',

app/Filament/App/Widgets/SocialLinksWidget.php

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,50 @@
55
use Override;
66
use Illuminate\Contracts\View\View;
77
use Filament\Widgets\Widget;
8+
use App\Settings\GeneralSettings;
89

910
class SocialLinksWidget extends Widget
1011
{
1112
protected string $view = 'filament.app.widgets.social-links-widget';
1213

13-
#[Override]
14-
public function render(): View
14+
#[Override]
15+
public function render(): View
1516
{
16-
return view($this->view, [
17-
'links' => [
17+
$settings = app(GeneralSettings::class);
18+
19+
$links = [];
20+
21+
if ($settings->github_url) {
22+
$links['GitHub'] = $settings->github_url;
23+
}
24+
25+
if ($settings->facebook_url) {
26+
$links['Facebook'] = $settings->facebook_url;
27+
}
28+
29+
if ($settings->twitter_url) {
30+
$links['Twitter'] = $settings->twitter_url;
31+
}
32+
33+
if ($settings->youtube_url) {
34+
$links['YouTube'] = $settings->youtube_url;
35+
}
36+
37+
// Keep the Facebook Groups as fallback
38+
if (empty($links)) {
39+
$links = [
1840
'GitHub' => 'https://www.github.com/liberu-genealogy',
1941
'Facebook Page' => 'https://www.facebook.com/familytree365',
2042
'Facebook Groups' => [
2143
'Family Tree 365' => 'https://www.facebook.com/groups/familytree365',
2244
'Genealogy Chat' => 'https://www.facebook.com/groups/genealogychat',
2345
'DNA 365' => 'https://www.facebook.com/groups/dna365',
2446
],
25-
],
47+
];
48+
}
49+
50+
return view($this->view, [
51+
'links' => $links,
2652
]);
2753
}
2854
}

0 commit comments

Comments
 (0)