Skip to content

Commit

Permalink
feat(filament): added recently plugin (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Sep 12, 2024
1 parent 3acac99 commit 84a0281
Show file tree
Hide file tree
Showing 19 changed files with 268 additions and 13 deletions.
2 changes: 2 additions & 0 deletions app/Filament/HeaderActions/Base/EditHeaderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\HeaderActions\Base;

use Filament\Actions\EditAction as DefaultEditAction;
use Filament\Support\Enums\IconSize;

/**
* Class EditHeaderAction.
Expand All @@ -21,5 +22,6 @@ protected function setUp(): void
parent::setUp();

$this->label(__('filament.actions.base.edit'));
$this->icon('heroicon-o-pencil-square');
}
}
12 changes: 0 additions & 12 deletions app/Filament/Resources/Admin/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ public static function getRecordSlug(): string
return 'announcements';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return AnnouncementModel::ATTRIBUTE_ID;
}

/**
* The form to the actions.
*
Expand Down
3 changes: 3 additions & 0 deletions app/Filament/Resources/Base/BaseViewResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Filament\Resources\Base;

use App\Filament\HeaderActions\Base\EditHeaderAction;
use Awcodes\Recently\Concerns\HasRecentHistoryRecorder;
use Filament\Resources\Pages\ViewRecord;
use Illuminate\Support\Arr;

Expand All @@ -13,6 +14,8 @@
*/
class BaseViewResource extends ViewRecord
{
use HasRecentHistoryRecorder;

/**
* Get the header actions available.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/BaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public static function getRecordRouteKeyName(): string
return (new $model)->getKeyName();
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return (new static::$model)->getKeyName();
}

/**
* The index page of the resource.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Document/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ public static function getRecordSlug(): string
return 'pages';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return PageModel::ATTRIBUTE_NAME;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/List/ExternalProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ public static function getRecordSlug(): string
return 'external-profiles';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return ExternalProfileModel::ATTRIBUTE_NAME;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/List/Playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ public static function getRecordSlug(): string
return 'playlists';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return PlaylistModel::ATTRIBUTE_NAME;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/Anime/Synonym.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ public static function getRecordSlug(): string
return 'anime-synonyms';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return SynonymModel::ATTRIBUTE_TEXT;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ public static function getRecordSlug(): string
return 'audios';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return AudioModel::ATTRIBUTE_BASENAME;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/ExternalResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ public static function getRecordSlug(): string
return 'external-resources';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return ExternalResourceModel::ATTRIBUTE_LINK;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ public static function getRecordSlug(): string
return 'images';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return ImageModel::ATTRIBUTE_PATH;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/Studio.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ public static function getRecordSlug(): string
return 'studios';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return StudioModel::ATTRIBUTE_NAME;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ public static function getRecordSlug(): string
return 'videos';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return VideoModel::ATTRIBUTE_BASENAME;
}

/**
* The form to the actions.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Filament/Resources/Wiki/Video/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ public static function getRecordSlug(): string
return 'video-scripts';
}

/**
* Get the title attribute for the resource.
*
* @return string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getRecordTitleAttribute(): string
{
return ScriptModel::ATTRIBUTE_PATH;
}

/**
* The form to the actions.
*
Expand Down
2 changes: 2 additions & 0 deletions app/Providers/FilamentPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Providers;

use App\Filament\Providers\GlobalSearchScoutProvider;
use Awcodes\Recently\RecentlyPlugin;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
Expand Down Expand Up @@ -52,6 +53,7 @@ public function panel(Panel $panel): Panel
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->plugins([
FilamentApexChartsPlugin::make(),
RecentlyPlugin::make(),
])
->middleware([
EncryptCookies::class,
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"ext-gd": "*",
"ext-intl": "*",
"ext-pdo": "*",
"awcodes/recently": "^1.0",
"babenkoivan/elastic-migrations": "^3.3",
"babenkoivan/elastic-scout-driver-plus": "^4.3",
"bepsvpt/secure-headers": "^7.4",
Expand Down
77 changes: 76 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions config/recently.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

// config for Awcodes/Recently
// Filament Plugin
return [
'user_model' => App\Models\Auth\User::class,
'max_items' => 20,
'width' => 'xl',
'global_search' => true,
'menu' => true,
'icon' => 'heroicon-o-arrow-uturn-left',
];
Loading

0 comments on commit 84a0281

Please sign in to comment.