Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public static function configure(Schema $schema): Schema
->partiallyRenderComponentsAfterStateUpdated(['name'])
->required(),
Select::make('owner_id')
->relationship('owner', 'name')
->native(false)
->searchable()
->relationship(name: 'owner', titleAttribute: 'name', modifyQueryUsing: fn ($query) => $query->limit(10))
->required(),
Toggle::make('active')
->required(),
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions app-modules/tenant/src/Plugins/AdminTenantPanelPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Filament\Contracts\Plugin;
use Filament\Panel;
use He4rt\Tenant\Filament\Admin\Resources\Tenants\TenantResource;
use He4rt\Tenant\Filament\Admin\Widgets\TenantsStatsOverview;

class AdminTenantPanelPlugin implements Plugin
{
Expand All @@ -23,9 +22,6 @@ public function register(Panel $panel): void
TenantResource::class,
]);

$panel->widgets([
TenantsStatsOverview::class,
]);
}

public function boot(Panel $panel): void {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
use He4rt\User\Filament\Admin\Resources\Users\Schemas\UserForm;
use He4rt\User\Filament\Admin\Resources\Users\Tables\UsersTable;
use He4rt\User\Models\User;
use Illuminate\Support\Number;
use UnitEnum;

use function Illuminate\Support\minutes;

class UserResource extends Resource
{
protected static ?string $model = User::class;
Expand All @@ -31,7 +34,7 @@ class UserResource extends Resource

public static function getNavigationBadge(): ?string
{
return (string) self::$model::count();
return Number::abbreviate((int) (cache()->remember('total_users', minutes(5), fn () => self::$model::count()) ?? 0));
}

public static function form(Schema $schema): Schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,32 @@

namespace He4rt\User\Filament\Shared\Widgets;

use Filament\Facades\Filament;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use He4rt\User\Models\User;
use Illuminate\Contracts\Database\Query\Builder;

use function Illuminate\Support\minutes;

class UsersStatsOverview extends BaseWidget
{
protected static ?int $sort = 1;

protected function getStats(): array
{
$user = Filament::auth()->user();

$query = User::query();

if (! $user->isAdmin()) {
$query->whereHas('tenants', fn (Builder $q) => $q->where('tenants.id', Filament::getTenant()->getKey())
);
}

$totalDonators = (clone $query)
$totalDonators = cache()->remember('total_users_donators', minutes(5), fn () => $query
->where('is_donator', true)
->count();
->count());

$totalUsersToday = (clone $query)
$totalUsersToday = cache()->remember('total_users_today', minutes(5), fn () => $query
->whereDate('created_at', today())
->count();
->count());

$totalUsersMonth = (clone $query)
$totalUsersMonth = cache()->remember('total_users_month', minutes(5), fn () => $query
->whereYear('created_at', now()->year)
->whereMonth('created_at', now()->month)
->count();
->count());
Comment thread
danielhe4rt marked this conversation as resolved.

return [
Stat::make('Usuários criados hoje', $totalUsersToday)
Expand Down
7 changes: 1 addition & 6 deletions app-modules/user/src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,14 @@ public function registerMediaCollections(): void

public function canAccessPanel(Panel $panel): bool
{
match ($panel->getId()) {
return match ($panel->getId()) {
'admin' => app()->isProduction() ? $this->isAdmin() : true,
default => true
};

return $this->isAdmin();
}

public function getFilamentAvatarUrl(): string
{
if ($this->providers->firstWhere('provider_name', 'github')) {
return sprintf('https://github.com/%s.png', $this->username);
}

return sprintf('https://github.com/%s.png', $this->username);
}
Expand Down
5 changes: 5 additions & 0 deletions app-modules/user/src/Plugins/AdminUserPanelPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Filament\Contracts\Plugin;
use Filament\Panel;
use He4rt\User\Filament\Admin\Resources\Users\UserResource;
use He4rt\User\Filament\Shared\Widgets\UsersStatsOverview;

class AdminUserPanelPlugin implements Plugin
{
Expand All @@ -22,6 +23,10 @@ public function register(Panel $panel): void
UserResource::class,
]);

$panel->widgets([
UsersStatsOverview::class,
]);

}

public function boot(Panel $panel): void {}
Expand Down
53 changes: 53 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace App\Providers;

use App\Providers\Tools\DebugbarServiceProvider;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\ServiceProvider;

final class AppServiceProvider extends ServiceProvider
Expand All @@ -13,7 +16,57 @@ final class AppServiceProvider extends ServiceProvider
* Register any application services.
*/
public function register(): void
{
$this->registerDebugbar();
}

/**
* Bootstrap any application services.
*/
public function boot(): void
{
$this->configureDatabase();
$this->configureDates();
$this->configureVite();
$this->configureUrl();
}

/**
* Configure the application's models
*/
private function configureDatabase(): void
{
Model::automaticallyEagerLoadRelationships();
}

/**
* Configure the application's Vite
*/
private function configureVite(): void
{
Vite::useAggressivePrefetching();
}

/**
* Configure the dates.
*/
private function configureDates(): void
{
// Date::use(CarbonImmutable::class);
}

/**
* Configure the application's URL
*/
private function configureUrl(): void
{
URL::forceHttps($this->app->isProduction());
}

private function registerDebugbar(): void
{
if (app()->isLocal() && class_exists(\Barryvdh\Debugbar\ServiceProvider::class)) {
$this->app->register(DebugbarServiceProvider::class);
}
}
}
48 changes: 24 additions & 24 deletions app/Providers/Filament/GuestPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,46 @@ public function panel(Panel $panel): Panel
->defaultThemeMode(ThemeMode::Dark)
->topNavigation()
->brandLogo(fn (): View => view('he4rt::components.logo'))
->renderHook(PanelsRenderHook::FOOTER, fn (): View => view('he4rt::components.partials.footer', [
'description' => 'Conheça MeuGuia.app! Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Vivamus sed egestas nisl. Vivamus blandit vehicula eleifend.
Phasellus vulputate elit leo, porta vehicula nunc placerat placerat.',
'columns' => [
'Sobre nós' => [
'Home' => '/',
'Quem somos' => '/about',
],
'Suporte' => [
'Termos e Privacidade' => '/terms',
'Junte-se à nós' => '/jobs',
],
'Social Media' => [
'Discord' => 'https://discord.gg/he4rt',
'Github' => 'https://github.com/he4rt',
'X' => 'https://x.com/he4rtdevs',
],
],
]))
// ->renderHook(PanelsRenderHook::FOOTER, fn (): View => view('he4rt::components.partials.footer', [
// 'description' => 'Conheça MeuGuia.app! Lorem ipsum dolor sit amet,
// consectetur adipiscing elit. Vivamus sed egestas nisl. Vivamus blandit vehicula eleifend.
// Phasellus vulputate elit leo, porta vehicula nunc placerat placerat.',
// 'columns' => [
// 'Sobre nós' => [
// 'Home' => '/',
// 'Quem somos' => '/about',
// ],
// 'Suporte' => [
// 'Termos e Privacidade' => '/terms',
// 'Junte-se à nós' => '/jobs',
// ],
// 'Social Media' => [
// 'Discord' => 'https://discord.gg/he4rt',
// 'Github' => 'https://github.com/he4rt',
// 'X' => 'https://x.com/he4rtdevs',
// ],
// ],
// ]))
->renderHook(PanelsRenderHook::SIDEBAR_NAV_END, fn () => Blade::render(<<<'BLADE'
@guest
<div class="flex flex-col md:hidden mt-auto items-center space-y-4">
<x-he4rt::button icon="heroicon-s-arrow-top-right-on-square" variant="outline">
<x-he4rt::button href="https://github.com/he4rt" icon="heroicon-s-arrow-top-right-on-square" variant="outline">
Github
</x-he4rt::button>

<x-he4rt::button icon-position="leading" icon="heroicon-o-user">Entrar agora</x-he4rt::button>
<!-- <x-he4rt::button icon-position="leading" icon="heroicon-o-user">Entrar agora</x-he4rt::button>-->
</div>
@endguest
BLADE
))
->renderHook(PanelsRenderHook::TOPBAR_END, fn () => Blade::render(<<<'BLADE'
@guest
<div class="hidden md:flex items-center space-x-4">
<x-he4rt::button icon="heroicon-s-arrow-top-right-on-square" variant="outline">
<x-he4rt::button href="https://github.com/he4rt" icon="heroicon-s-arrow-top-right-on-square" variant="outline">
Github
</x-he4rt::button>

<x-he4rt::button icon-position="leading" icon="heroicon-o-user">Entrar agora</x-he4rt::button>
<!-- <x-he4rt::button icon-position="leading" icon="heroicon-o-user">Entrar agora</x-he4rt::button>-->
</div>
@endguest
BLADE
Expand Down
24 changes: 24 additions & 0 deletions app/Providers/Tools/DebugbarServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Providers\Tools;

use Barryvdh\Debugbar\ServiceProvider;

class DebugbarServiceProvider extends ServiceProvider
{
public function boot(): void
{
if (! $this->canBoot()) {
return;
}

parent::boot();
}

private function canBoot(): bool
{
return config('debugbar.enabled');
}
}
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"he4rt/user": ">=1",
"internachi/modular": "^2.3.0",
"laracord/framework": "dev-next",
"laravel/framework": "^12.40.1",
"laravel/framework": "^12.40.2",
"laravel/nightwatch": "^1.19",
"laravel/sanctum": "^4.2.1",
"laravel/tinker": "^2.10.2",
Expand Down Expand Up @@ -140,7 +140,9 @@
},
"extra": {
"laravel": {
"dont-discover": []
"dont-discover": [
"barryvdh/laravel-debugbar"
]
}
},
"config": {
Expand Down
Loading