Skip to content

Commit

Permalink
Add Filament clusters for Settings and Networking; implement resource…
Browse files Browse the repository at this point in the history
… pages for Phone, Comment, and Newsletter
  • Loading branch information
abdessamadbettal committed Dec 6, 2024
1 parent efc9326 commit 9ea50c0
Show file tree
Hide file tree
Showing 38 changed files with 959 additions and 147 deletions.
121 changes: 121 additions & 0 deletions .phpstorm.meta.php

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions app/Filament/Clusters/Networking.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Filament\Clusters;

use Filament\Clusters\Cluster;

class Networking extends Cluster
{
protected static ?string $navigationIcon = 'heroicon-o-share';
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace App\Filament\Resources;
namespace App\Filament\Clusters\Networking\Resources;

use App\Filament\Resources\CommentResource\Pages;
use App\Filament\Resources\CommentResource\RelationManagers;
use App\Filament\Clusters\Networking;
use App\Filament\Clusters\Networking\Resources\CommentResource\Pages;
use App\Filament\Clusters\Networking\Resources\CommentResource\RelationManagers;
use App\Models\Comment;
use Filament\Forms;
use Filament\Forms\Form;
Expand All @@ -19,6 +20,8 @@ class CommentResource extends Resource

protected static ?string $navigationIcon = 'heroicon-o-chat-bubble-left-ellipsis';

protected static ?string $cluster = Networking::class;

public static function form(Form $form): Form
{
return $form
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\CommentResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\CommentResource\Pages;

use App\Filament\Resources\CommentResource;
use App\Filament\Clusters\Networking\Resources\CommentResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\CommentResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\CommentResource\Pages;

use App\Filament\Resources\CommentResource;
use App\Filament\Clusters\Networking\Resources\CommentResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\CommentResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\CommentResource\Pages;

use App\Filament\Resources\CommentResource;
use App\Filament\Clusters\Networking\Resources\CommentResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\CommentResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\CommentResource\Pages;

use App\Filament\Resources\CommentResource;
use App\Filament\Clusters\Networking\Resources\CommentResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;

Expand Down
97 changes: 97 additions & 0 deletions app/Filament/Clusters/Networking/Resources/NewsletterResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

namespace App\Filament\Clusters\Networking\Resources;

use App\Filament\Clusters\Networking;
use App\Filament\Clusters\Networking\Resources\NewsletterResource\Pages;
use App\Filament\Clusters\Networking\Resources\NewsletterResource\RelationManagers;
use App\Models\Newsletter;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class NewsletterResource extends Resource
{
protected static ?string $model = Newsletter::class;

protected static ?string $navigationIcon = 'heroicon-o-inbox-arrow-down';

protected static ?string $cluster = Networking::class;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('email')
->email()
->required()
->maxLength(255),
Forms\Components\Toggle::make('is_subscribed')
->required(),
Forms\Components\DateTimePicker::make('subscribed_at'),
Forms\Components\DateTimePicker::make('unsubscribed_at'),
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('email')
->searchable(),
Tables\Columns\IconColumn::make('is_subscribed')
->boolean(),
Tables\Columns\TextColumn::make('subscribed_at')
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('unsubscribed_at')
->dateTime()
->sortable(),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListNewsletters::route('/'),
'create' => Pages\CreateNewsletter::route('/create'),
'view' => Pages\ViewNewsletter::route('/{record}'),
'edit' => Pages\EditNewsletter::route('/{record}/edit'),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Clusters\Networking\Resources\NewsletterResource\Pages;

use App\Filament\Clusters\Networking\Resources\NewsletterResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateNewsletter extends CreateRecord
{
protected static string $resource = NewsletterResource::class;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Filament\Clusters\Networking\Resources\NewsletterResource\Pages;

use App\Filament\Clusters\Networking\Resources\NewsletterResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditNewsletter extends EditRecord
{
protected static string $resource = NewsletterResource::class;

protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Clusters\Networking\Resources\NewsletterResource\Pages;

use App\Filament\Clusters\Networking\Resources\NewsletterResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListNewsletters extends ListRecords
{
protected static string $resource = NewsletterResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Clusters\Networking\Resources\NewsletterResource\Pages;

use App\Filament\Clusters\Networking\Resources\NewsletterResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;

class ViewNewsletter extends ViewRecord
{
protected static string $resource = NewsletterResource::class;

protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace App\Filament\Resources;
namespace App\Filament\Clusters\Networking\Resources;

use App\Filament\Resources\PhoneResource\Pages;
use App\Filament\Resources\PhoneResource\RelationManagers;
use App\Filament\Clusters\Networking;
use App\Filament\Clusters\Networking\Resources\PhoneResource\Pages;
use App\Filament\Clusters\Networking\Resources\PhoneResource\RelationManagers;
use App\Models\Phone;
use Filament\Forms;
use Filament\Forms\Form;
Expand All @@ -19,6 +20,8 @@ class PhoneResource extends Resource

protected static ?string $navigationIcon = 'heroicon-o-phone';

protected static ?string $cluster = Networking::class;

public static function form(Form $form): Form
{
return $form
Expand Down Expand Up @@ -71,7 +74,7 @@ public static function table(Table $table): Table
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
//
])
->actions([
Tables\Actions\ViewAction::make(),
Expand All @@ -80,8 +83,6 @@ public static function table(Table $table): Table
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
Expand All @@ -102,12 +103,4 @@ public static function getPages(): array
'edit' => Pages\EditPhone::route('/{record}/edit'),
];
}

public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\PhoneResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\PhoneResource\Pages;

use App\Filament\Resources\PhoneResource;
use App\Filament\Clusters\Networking\Resources\PhoneResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\PhoneResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\PhoneResource\Pages;

use App\Filament\Resources\PhoneResource;
use App\Filament\Clusters\Networking\Resources\PhoneResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

Expand All @@ -15,8 +15,6 @@ protected function getHeaderActions(): array
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\PhoneResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\PhoneResource\Pages;

use App\Filament\Resources\PhoneResource;
use App\Filament\Clusters\Networking\Resources\PhoneResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Filament\Resources\PhoneResource\Pages;
namespace App\Filament\Clusters\Networking\Resources\PhoneResource\Pages;

use App\Filament\Resources\PhoneResource;
use App\Filament\Clusters\Networking\Resources\PhoneResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;

Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Clusters/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Filament\Clusters;

use Filament\Clusters\Cluster;

class Settings extends Cluster
{
protected static ?string $navigationIcon = 'heroicon-o-cog-8-tooth';
}
26 changes: 26 additions & 0 deletions app/Filament/Clusters/Settings/Pages/ManageAbout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Filament\Clusters\Settings\Pages;

use App\Filament\Clusters\Settings;
use App\Settings\AboutSettings;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\SettingsPage;

class ManageAbout extends SettingsPage
{
protected static ?string $navigationIcon = 'heroicon-o-light-bulb';

protected static string $settings = AboutSettings::class;

protected static ?string $cluster = Settings::class;

public function form(Form $form): Form
{
return $form
->schema([
// ...
]);
}
}
Loading

0 comments on commit 9ea50c0

Please sign in to comment.