Skip to content

Commit

Permalink
Merge pull request #706 from pinkary-project/feat/pan-in-admin
Browse files Browse the repository at this point in the history
[wip] Feat: pan-in-admin
  • Loading branch information
nunomaduro authored Oct 15, 2024
2 parents 5589054 + 8ae350f commit 22d7f4d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
40 changes: 40 additions & 0 deletions app/Filament/Widgets/Analytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace App\Filament\Widgets;

use Filament\Tables;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Model;

final class Analytics extends BaseWidget
{
/**
* @var int | string | array<string, int | null>
*/
protected int | string | array $columnSpan = 'full';

/**
* The table that will be displayed in the widget.
*/
public function table(Table $table): Table
{
$panAnalytics = new class extends Model
{
protected $table = 'pan_analytics';
};

return $table
->query(
$panAnalytics::query()
)
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('impressions'),
Tables\Columns\TextColumn::make('hovers'),
Tables\Columns\TextColumn::make('clicks'),
]);
}
}
4 changes: 4 additions & 0 deletions app/Providers/Filament/CitadelPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Navigation\MenuItem;
use Filament\Pages\Dashboard;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
Expand All @@ -33,6 +34,9 @@ public function panel(Panel $panel): Panel
->path('citadel')
->homeUrl(fn (): string => route('home.feed'))
->spa()
->pages([
Dashboard::class,
])
->favicon(asset('/img/ico.svg'))
->brandLogo(asset('/img/logo-text.svg'))
->brandLogoHeight('1.85rem')
Expand Down
15 changes: 15 additions & 0 deletions tests/Http/Citadel/DashboardTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use App\Filament\Widgets\Analytics;
use App\Models\User;

it('does renders', function () {
$this->actingAs(User::factory()->create([
'email' => '[email protected]',
]))
->get('citadel/')
->assertSeeLivewire(Analytics::class)
->assertStatus(200);
});
10 changes: 10 additions & 0 deletions tests/Unit/Citadel/Widgets/AnalyticsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);
use App\Filament\Widgets\Analytics;
use Livewire\Livewire;

test('displays the analytics', function () {
Livewire::test(Analytics::class)
->assertSee('Analytics');
});

0 comments on commit 22d7f4d

Please sign in to comment.