Scott
Scott
FFilament
Created by Scott on 10/9/2023 in #❓┊help
Disable "create another" on form (non modal)
Nice, thank you!
8 replies
FFilament
Created by Scott on 9/8/2023 in #❓┊help
Show a "preview" within an action modal
Thanks, will take a look 🙂
7 replies
FFilament
Created by Scott on 9/8/2023 in #❓┊help
Show a "preview" within an action modal
7 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
Thanks again for all the help!
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
In the end I did it as middleware on hte panel as I needed to do things based on the user's Auth status
->authMiddleware([
Authenticate::class,
RegisterSubscriptionNotice::class,
]);
->authMiddleware([
Authenticate::class,
RegisterSubscriptionNotice::class,
]);
Middleware
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
use Filament\Support\Facades\FilamentView;

class RegisterSubscriptionNotice
{
public function handle($request, Closure $next)
{

if (Auth::check()) {
$subscriptionData = [
'subscribed' => Auth::user()->currentTeam->subscribed(),
'trial_expired' => now()->greaterThanOrEqualTo(Auth::user()->currentTeam->trial_ends_at),
'team' => Auth::user()->currentTeam,
];

FilamentView::registerRenderHook(
'panels::content.start',
fn (): View => view('filament.hooks.subscription-notice', $subscriptionData)
);
}

return $next($request);
}
}
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
use Filament\Support\Facades\FilamentView;

class RegisterSubscriptionNotice
{
public function handle($request, Closure $next)
{

if (Auth::check()) {
$subscriptionData = [
'subscribed' => Auth::user()->currentTeam->subscribed(),
'trial_expired' => now()->greaterThanOrEqualTo(Auth::user()->currentTeam->trial_ends_at),
'team' => Auth::user()->currentTeam,
];

FilamentView::registerRenderHook(
'panels::content.start',
fn (): View => view('filament.hooks.subscription-notice', $subscriptionData)
);
}

return $next($request);
}
}
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
fab, thank you, will give it a go!
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
thanks for your help!
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
oohhh, ok, cool - will take a look at that 🙂
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
I'm on a beta version, will try upgrading to the released v3
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
lol
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
yep
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
Still learning I suppose! I've tried doing this, but I get errors about the $scope
class AdminPanelProvider extends PanelProvider
{

public function boot()
{
FilamentView::registerRenderHook(
'panels::page.start',
fn (): \Illuminate\Contracts\View\View => view('subscription-notice'),
scopes: [
\App\Filament\Resources\SiteResource\Pages\ListSites::class,
\App\Filament\Resources\SiteResource\Pages\CreateSite::class,
\App\Filament\Resources\UserResource\Pages\EditSite::class,
],
);
}
}
class AdminPanelProvider extends PanelProvider
{

public function boot()
{
FilamentView::registerRenderHook(
'panels::page.start',
fn (): \Illuminate\Contracts\View\View => view('subscription-notice'),
scopes: [
\App\Filament\Resources\SiteResource\Pages\ListSites::class,
\App\Filament\Resources\SiteResource\Pages\CreateSite::class,
\App\Filament\Resources\UserResource\Pages\EditSite::class,
],
);
}
}
Error: Unknown named parameter $scopes Any ideas what I might be doing wrong?
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
yep, but it doesnt say whether it goes in a boot function 🙂
28 replies
FFilament
Created by Scott on 8/9/2023 in #❓┊help
Add a notice to the top of a table page
@toeknee_iom Thank you, hooks look like the solution. However, the documentation isn't clear where in a service provider the render hooks go. This is a common theme I'm finding wiht the docs, where it doesn't give an example in context :/
28 replies
FFilament
Created by Scott on 8/2/2023 in #❓┊help
How do you get the current tenant id?
Had to go digging in the filament vendor package... Basically, you add an event listener to the setTenant function. php artisan make:listener UpdateLatestTeamId --event=TenantSet Then in your new file (e.g. app/Listeners/UpdateLatestTeamId.php) you could put
<?php

namespace App\Listeners;

use Filament\Events\TenantSet;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;

class UpdateLatestTeamId
{
/**
* Create the event listener.
*/
public function __construct()
{
//
Log::info('UpdateLatestTeamId::__construct()');
}

/**
* Handle the event.
*/
public function handle(TenantSet $event): void
{
// get the user from the event
$user = $event->getUser();

// get the tenant (team) from the event
$team = $event->getTenant();

// update the user's latest_team_id
$user->latest_team_id = $team->id;
$user->save();
}
}
<?php

namespace App\Listeners;

use Filament\Events\TenantSet;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;

class UpdateLatestTeamId
{
/**
* Create the event listener.
*/
public function __construct()
{
//
Log::info('UpdateLatestTeamId::__construct()');
}

/**
* Handle the event.
*/
public function handle(TenantSet $event): void
{
// get the user from the event
$user = $event->getUser();

// get the tenant (team) from the event
$team = $event->getTenant();

// update the user's latest_team_id
$user->latest_team_id = $team->id;
$user->save();
}
}
And then you need to register your new listener in app/Providers/EventServiceProvider.php like so
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
'Filament\Events\TenantSet' => [
'App\Listeners\UpdateLatestTeamId',
],
];
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
'Filament\Events\TenantSet' => [
'App\Listeners\UpdateLatestTeamId',
],
];
5 replies
FFilament
Created by Scott on 8/2/2023 in #❓┊help
How do you get the current tenant id?
The docs talk about getting the latest tenant: https://filamentphp.com/docs/3.x/panels/tenancy#setting-the-default-tenant I've added a migration to add the latest_tenant_id column, but how do we set this value?
5 replies
FFilament
Created by X7Ryan on 7/21/2023 in #❓┊help
[V3] Multitenancy - HasTenants Contract canAccessTenant() method
Same here! Do you have a likn to the PR?
6 replies
FFilament
Created by Scott on 7/30/2023 in #❓┊help
Registration?
Thank you 🙂
5 replies
FFilament
Created by Scott on 7/28/2023 in #❓┊help
Setting section background color
nice! that worked, thanks
9 replies
FFilament
Created by Scott on 7/28/2023 in #❓┊help
Dynamically setting a label on a relationship
Nevermind, it works fine when I use html() instead of label()
4 replies