Pritbor
Pritbor
FFilament
Created by Pritbor on 11/18/2024 in #❓┊help
Don't want Create Form to show if No Subscription
I created custom create action listpage.
protected function getHeaderActions(): array
{
return [
Actions\Action::make('create')
->label('Create Job Seeking Post')
->action(function () {
// This action will be called when the user clicks "Create"
// It will first check for subscription status.
$this->checkSubscriptionAndRedirect();
}),
];
}

protected function checkSubscriptionAndRedirect()
{
$subscriptionService = app(SubscriptionService::class); // Get your subscription service

if (! $subscriptionService->canPerformAction(Auth::user()->member, ModelType::JOB_SEEKING_POST, 'create')) {
Notification::make()
->warning()
->title('You don\'t have an active subscription!')
->body('Choose a plan to continue.')
->persistent()
->actions([
Action::make('subscribe')
->button()
->url(route('subscribe'), shouldOpenInNewTab: true),
])
->send();

return; // Stop further execution
}

// If subscribed, redirect to create page
return redirect()->route('filament.user.resources.job-seeking-posts.create');
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('create')
->label('Create Job Seeking Post')
->action(function () {
// This action will be called when the user clicks "Create"
// It will first check for subscription status.
$this->checkSubscriptionAndRedirect();
}),
];
}

protected function checkSubscriptionAndRedirect()
{
$subscriptionService = app(SubscriptionService::class); // Get your subscription service

if (! $subscriptionService->canPerformAction(Auth::user()->member, ModelType::JOB_SEEKING_POST, 'create')) {
Notification::make()
->warning()
->title('You don\'t have an active subscription!')
->body('Choose a plan to continue.')
->persistent()
->actions([
Action::make('subscribe')
->button()
->url(route('subscribe'), shouldOpenInNewTab: true),
])
->send();

return; // Stop further execution
}

// If subscribed, redirect to create page
return redirect()->route('filament.user.resources.job-seeking-posts.create');
}
4 replies
FFilament
Created by Pritbor on 11/14/2024 in #❓┊help
UserMenuItem with User Tenant Switch Option
thanks alot. my bad. yes i am able to achieve desired functionality using render hooks.
5 replies
FFilament
Created by Pints on 10/31/2024 in #❓┊help
Filament Shield: 1 Same Model in 2 Filament Resource
Sheild has a way to have custom permissions for each resource. So maybe you can create permissions with slghtly different names for each resource and then select accordingly. Further in your Model policy file develope the conditional logic accordingly. https://filamentphp.com/plugins/bezhansalleh-shield#custom-permissions
3 replies
FFilament
Created by Nicole on 10/18/2024 in #❓┊help
Filament Teams with Some Multi-Tenancy Features
You need to basically create three panels. First panel is could be default panel (admin panel). Second you can create UserPanel and third is your Tenant panel. Try to setup multitenancy between User panel and Tenant panel. Use roles and permission to make clear separation between users with multi-tenancy. And users who will be respobsible for managing platform. Only they can access this Admin panel provider. Ofcourse you can setup rolses and permissions within this group of users.
9 replies
FFilament
Created by RawaN on 8/29/2024 in #❓┊help
How to use filament component in front-end of website?
@FilamentStyles @FilamentScripts is just a wrapper around livewireStyles and livewireScripts with additional filament features. Ensure you configure talwindConfig correctly.
7 replies
FFilament
Created by RawaN on 8/29/2024 in #❓┊help
How to use filament component in front-end of website?
You should use only @FilamentStyles @FilamentScripts I am using it. Further, to use any blade component as given in Filament blade, you can just use as per documentation. But to you forms, table, actions and more you would need livewire or any filament custom pages and follow documentation of using forms, table, action etc in livewire.
7 replies
FFilament
Created by Pritbor on 8/25/2024 in #❓┊help
MorphToSelect is too slow
I realised using Preload() is the problem. I removed and I see significant jump. But still i was wondering if i am using preload() with ->optionsLimit(5), then there should not be an issue but i see my page just hangs when i try typing .
6 replies
FFilament
Created by Pritbor on 8/25/2024 in #❓┊help
MorphToSelect is too slow
yes i have name field set as index in both Company and User model.
6 replies
FFilament
Created by Pritbor on 8/22/2024 in #❓┊help
Table relationship sort error.
Thanks @toeknee . You mean have $name = 'member.memberable.name' in table and use $name in column. I tried this and it gives same error. But then i wrote callback query inside sortable()
4 replies
FFilament
Created by Pritbor on 8/6/2024 in #❓┊help
Attach action error in RelationManager
Hi @Dennis Koch . i tried
public function scopeWithNoChildren(Builder $query): Builder
{
return $query->whereDoesntHave('children');
}

// Method to get categories with no children
public static function businessCategories(): Builder
{
return self::withNoChildren();
}
public function scopeWithNoChildren(Builder $query): Builder
{
return $query->whereDoesntHave('children');
}

// Method to get categories with no children
public static function businessCategories(): Builder
{
return self::withNoChildren();
}
But i still get error Call to undefined method Illuminate\Database\Eloquent\Builder::getRelated(). I am writing custom Attach action now.
7 replies
FFilament
Created by Pritbor on 8/6/2024 in #❓┊help
Attach action error in RelationManager
Agree.
7 replies
FFilament
Created by Pritbor on 6/20/2024 in #❓┊help
Using Filament Notification number in Frontpage notification icon
thanks @nanopanda . I went thruogh this doc. just wanted filamentphp reusable options.
7 replies
FFilament
Created by Pritbor on 6/20/2024 in #❓┊help
Using Filament Notification number in Frontpage notification icon
thanks @Leandro Ferreira both do my job.
7 replies
FFilament
Created by Pritbor on 6/11/2024 in #❓┊help
Select form not retrieving data using getSearchResultsUsing()
3 replies
FFilament
Created by Pritbor on 5/28/2024 in #❓┊help
how to show a MorphOne table in filament Table?
Sure @Tally . I was struggling with Morph relationship. Cause Table needs a way to know Model type.
16 replies
FFilament
Created by Pritbor on 5/28/2024 in #❓┊help
how to show a MorphOne table in filament Table?
thanks alot its working. So I can use ->state not just for image column rather anywhere for any morph relationship. Thanks alot.
16 replies
FFilament
Created by Pritbor on 5/28/2024 in #❓┊help
how to show a MorphOne table in filament Table?
Actually I have been able to one at a time either ImageColumn::make('memberable->profile_photo_path') or ImageColumn::make('memberable->profile->logo') for user or company but not generically for both depending upon member_type. since I have MorphOne elation.
16 replies
FFilament
Created by Pritbor on 5/28/2024 in #❓┊help
how to show a MorphOne table in filament Table?
But it say
ImageColumn::formatStateUsing does not exist.
ImageColumn::formatStateUsing does not exist.
16 replies
FFilament
Created by Pritbor on 5/28/2024 in #❓┊help
how to show a MorphOne table in filament Table?
You mean, i should choose any random 'string' in make() and use ->formatStateUsing() to define my callback.
16 replies
FFilament
Created by Pritbor on 5/28/2024 in #❓┊help
how to show a MorphOne table in filament Table?
Hi @Tally .. thanks for quick response. Is not my return is string.
16 replies