Wim
Wim
FFilament
Created by Wim on 7/6/2024 in #❓┊help
Filtered resource in menu
No description
2 replies
FFilament
Created by Wim on 6/16/2024 in #❓┊help
Check upon login
Upon logging in, I would like to check whether a user has filled in his profile information. Is there any hook I could use to accomplish this?
4 replies
FFilament
Created by Wim on 5/24/2024 in #❓┊help
Infolist TextEntry
No description
5 replies
FFilament
Created by Wim on 5/24/2024 in #❓┊help
Custom view for Conversation with Messages
No description
12 replies
FFilament
Created by Wim on 4/21/2024 in #❓┊help
Don't show Actions for Database notifications that are marked as read
I have the following database notification:
Notification::make()
->title('Product published')
->body('Product published successfully')
->actions([
Action::make('Mark As Read')
->button()
->markAsRead()
])
->sendToDatabase($recipient);
Notification::make()
->title('Product published')
->body('Product published successfully')
->actions([
Action::make('Mark As Read')
->button()
->markAsRead()
])
->sendToDatabase($recipient);
This successfully shows a
Mark As Read
Mark As Read
button on each notification. How can I NOT show the
Mark as Read
Mark as Read
button when the notification is read (e.g. in the notifications table there is a read_at that is not null in such case) I tried it as follows but that does not work:
Notification::make()
->title('Product published')
->body('Product published successfully')
->actions([
Action::make('Mark As Read')
->button()
->markAsRead()
])
->visible(function (Notification $record) {
return $record->read_at !== null;
})
->sendToDatabase($recipient);
Notification::make()
->title('Product published')
->body('Product published successfully')
->actions([
Action::make('Mark As Read')
->button()
->markAsRead()
])
->visible(function (Notification $record) {
return $record->read_at !== null;
})
->sendToDatabase($recipient);
Any idea's?
3 replies
FFilament
Created by Wim on 4/20/2024 in #❓┊help
Favorite products: many to many not working
I have an app where users can favor many products. This is done via a many to many relation with a Favorite pivot table. Adding things into the database works. The favorites table is as follows:
id | user_id | product_id
1 | 2 | 2
2 | 2 | 4
id | user_id | product_id
1 | 2 | 2
2 | 2 | 4
In Filament I have a Favorites resources where the idea is the user can get an overview of the products he's favoured. In a Filament table I have the following:
return $table
->columns([
Tables\Columns\TextColumn::make('user.name'),
Tables\Columns\TextColumn::make('product.name'),
return $table
->columns([
Tables\Columns\TextColumn::make('user.name'),
Tables\Columns\TextColumn::make('product.name'),
The username is printed but the product name is not. Any idea how to do this? I keep on struggling with this. Some more information in case relevant: User Model:
public function favorites()
{
return $this->belongsToMany(Product::class, 'favorites');
}
public function favorites()
{
return $this->belongsToMany(Product::class, 'favorites');
}
Product model:
public function favorites()
{
return $this->belongsToMany(User::class, 'favorites');
}
public function favorites()
{
return $this->belongsToMany(User::class, 'favorites');
}
Favorite model:
public function user()
{
return $this->belongsTo(User::class);
}


public function product()
{
return $this->belongsTo(Product::class);
}
public function user()
{
return $this->belongsTo(User::class);
}


public function product()
{
return $this->belongsTo(Product::class);
}
4 replies
FFilament
Created by Wim on 4/15/2024 in #❓┊help
Use of variables inside a Field
I want to display information inside a Field. I have used a Text Input below because there is no label Field. Ideally I just want to display the plan name into a Form. Can this be done?

public function form(Form $form): Form {
$plan = $organisation->getPlan();
$plan_name= $plan->name;

return $form
->schema([
TextInput::make($plan_name) //this line
->label('Name')
]);
}

public function form(Form $form): Form {
$plan = $organisation->getPlan();
$plan_name= $plan->name;

return $form
->schema([
TextInput::make($plan_name) //this line
->label('Name')
]);
}
4 replies
FFilament
Created by Wim on 4/12/2024 in #❓┊help
Spark's current subscription plan in Filament Form
I'm integrating Laravel Spark with Filament. I would like to show the user's current subscription in a Form (on the Profile page) I can get the subscription as follows:
$organization = auth()->user()->organizations()->first();
$subscription = $organization->subscriptions()->first()->stripe_price;
$organization = auth()->user()->organizations()->first();
$subscription = $organization->subscriptions()->first()->stripe_price;
return $form
->schema([
Grid::make(4)
->schema([
Section::make('Current Subscription')
->schema([
TextInput::make($subscription)
->label('Subscription')
->readonly(),
])
return $form
->schema([
Grid::make(4)
->schema([
Section::make('Current Subscription')
->schema([
TextInput::make($subscription)
->label('Subscription')
->readonly(),
])
Obviously this does not work. Any idea how I can show the current user's subscription For info, here's the relevant database section:
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('organization_id');
$table->string('stripe_id')->unique();
$table->string('stripe_status');
$table->string('stripe_price')->nullable();
$table->integer('quantity')->nullable();
$table->index(['organization_id', 'stripe_status']);
}

Schema::create('subscription_items', function (Blueprint $table) {
$table->id();
$table->foreignId('subscription_id');
$table->string('stripe_id')->unique();
$table->string('stripe_product');
$table->string('stripe_price');
});
Schema::create('subscriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('organization_id');
$table->string('stripe_id')->unique();
$table->string('stripe_status');
$table->string('stripe_price')->nullable();
$table->integer('quantity')->nullable();
$table->index(['organization_id', 'stripe_status']);
}

Schema::create('subscription_items', function (Blueprint $table) {
$table->id();
$table->foreignId('subscription_id');
$table->string('stripe_id')->unique();
$table->string('stripe_product');
$table->string('stripe_price');
});
1 replies
FFilament
Created by Wim on 4/9/2024 in #❓┊help
Filament with Spark integration
I'm currently integrating Filament v3 with Laravel Spark for a multi-tenant application. In the AppPanelProvider.php I have added ->requiresTenantSubscription(), the document states that users will be redirected to the billing page if they don't have an active subscription. My issue is that I'm always being redirected to the billing portal. I do have a subscription for the organization (which is the tenant). I get a 'Your subscription has been started successfully.', as well as a way to 'change the subscription plan' as well as entries in the database subscription table. The expected behaviour would be that in this case (with a subscription) it would simply allow me to go the the Filament backend of my application. Any ideas?
3 replies
FFilament
Created by Wim on 4/1/2024 in #❓┊help
Color the Dashboard
No description
2 replies
FFilament
Created by Wim on 3/26/2024 in #❓┊help
Multi-tenancy: don't show tenancy menu when individual user
I have setup multi-tenancy according to the information here. I know I can use tenantMenu(false) as I did below.
public function panel(Panel $panel): Panel
{
return $panel
->id('app')
->path('app')
->tenant(Organization::class, ownershipRelationship: 'organizations')
->tenantRegistration(RegisterOrganization::class)
->tenantProfile(EditOrganizationProfile::class)
->tenantMenu(false)
public function panel(Panel $panel): Panel
{
return $panel
->id('app')
->path('app')
->tenant(Organization::class, ownershipRelationship: 'organizations')
->tenantRegistration(RegisterOrganization::class)
->tenantProfile(EditOrganizationProfile::class)
->tenantMenu(false)
However, I want to do this only when a user is an individual. In my database I have a table organizations that has a column is_individual. How can I change is to that only organizations see the menu whereas individual users don't get to see it. Or would I need two panels: one for individuals and one for organizations?
2 replies
FFilament
Created by Wim on 3/26/2024 in #❓┊help
Form validation messages
No description
18 replies
FFilament
Created by Wim on 3/16/2024 in #❓┊help
Filament resource for Markable
I'm using this package. It works well however I would like to show the favorites in Filament backend. I have a model Product. A user can mark a Product as favorite, which results in entries in the table favorites as follows:
id | user_id | markable_type | markable_id
1 | 1 | App\Models\Product | 5
2 | 1 | App\Models\Product | 6
id | user_id | markable_type | markable_id
1 | 1 | App\Models\Product | 5
2 | 1 | App\Models\Product | 6
I have the following model:
class Product extends Model
{
use HasFactory, Multitenantable, Markable;

public function favorites(): belongsToMany
{
return $this->belongsToMany(Markable::class);
}
}
class Product extends Model
{
use HasFactory, Multitenantable, Markable;

public function favorites(): belongsToMany
{
return $this->belongsToMany(Markable::class);
}
}
Ideally I have a resource called FavoriteResource which allows me to show all favorite products for that user. Any idea how this can be done, given I did not create the model Favorites (but rather using the markable package).
1 replies
FFilament
Created by Wim on 3/12/2024 in #❓┊help
Layout messed up when returning from Filament login page
I have an issue when I go to the Filament login page and then go back (via browser) to the original page. The layout of the original page gets messed up, a refresh of the page helps. You can see it here. Steps to reproduce: 1) Go to the page, you will see overview of animals 2) Click on Login 3) Use back button on browser. You will see the same page but with another layout 4) Click refresh in browser (it will 'restore' the original layout') Any idea why this is?
5 replies
FFilament
Created by Wim on 2/25/2024 in #❓┊help
Different sections on Create and Edit form
I have a form with a grid and 4 sections as follows:
public static function form(Form $form): Form {
return $form
->schema([
Grid::make(4)
->schema([
Section::make(__('products.general_info'))
Section::make(__('products.publish_info'))
Section::make(__('products.medical_social_info'))
Section::make(__('products.media'))
]);
}
public static function form(Form $form): Form {
return $form
->schema([
Grid::make(4)
->schema([
Section::make(__('products.general_info'))
Section::make(__('products.publish_info'))
Section::make(__('products.medical_social_info'))
Section::make(__('products.media'))
]);
}
As it is now all 4 sections are displayed on the create and the edit page. I would want to change it so that section publish_info is only shown on the edit page.
4 replies
FFilament
Created by Wim on 2/25/2024 in #❓┊help
formatStateUsing with condition
I have a table with users. Some users are individuals, others are organizations (db field 'organization' is either true or false). For the organizations I have a field 'organization_name' which is null for individuals. I want to display a table with users. For the organization name is have the following:
Tables\Columns\TextColumn::make('organization_name')
->formatStateUsing(
function ($state, User $user) {
if ($user->organization_name != NULL) {
return $user->organization_name . 'test';
} else {
return 'NA';
}
})
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('organization_name')
->formatStateUsing(
function ($state, User $user) {
if ($user->organization_name != NULL) {
return $user->organization_name . 'test';
} else {
return 'NA';
}
})
->searchable()
->sortable(),
The idea is to display NA in the table where the organization_name is null. However it does only display the organization_name (when filled in in the database) but it does not display the NA when not filled in in the database
4 replies
FFilament
Created by Wim on 2/18/2024 in #❓┊help
Filament table enum: enum does not exist
I have a database table where a column 'organization' can be 0 or 1 (non-organization or organization). The column type is tinyint(1). I was using the following code with an enum() function
Tables\Columns\TextColumn::make('organization')
->badge()
->color(fn (string $state): string => match ($state) {
'0' => 'danger',
'1' => 'info'
})
->enum([
'0' => 'Non-Organization',
'1' => 'Organization',
]),
Tables\Columns\TextColumn::make('organization')
->badge()
->color(fn (string $state): string => match ($state) {
'0' => 'danger',
'1' => 'info'
})
->enum([
'0' => 'Non-Organization',
'1' => 'Organization',
]),
But I'm getting Method Filament\Tables\Columns\TextColumn::enum does not exist. error. Any ideas?
2 replies
FFilament
Created by Wim on 1/6/2024 in #❓┊help
Custom table action to show blade file
In a Filament table, next to the view/edit/delete action I have defined a custom action (publish). For this, I'm using the following
Tables\Actions\Action::make('Publish')
Tables\Actions\Action::make('Publish')
This shows a modal form and all works well. I know I could use an InfoList so that one clicks on a view that the Infolist is displayed. But I would like this to happen when a user clicks on a custom action (instead of the view button). Is this possible?
1 replies
FFilament
Created by Wim on 1/4/2024 in #❓┊help
Display two sections next to each other
I would like to have a Filament Form where I have two sections next to each other. I was looking into the documentation but it seems not to be possible. Grid columns does seem to create two columns but inside a section. I don't want that, I want two independent sections next to each other I have been trying the following:
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('Voucher Information')
->schema([

Section::make('General Information')
->schema([Forms\Components\TextInput::make('name')]),

Section::make('Product Information')
->schema([Forms\Components\TextInput::make('code')])

])->columns(2)

]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('Voucher Information')
->schema([

Section::make('General Information')
->schema([Forms\Components\TextInput::make('name')]),

Section::make('Product Information')
->schema([Forms\Components\TextInput::make('code')])

])->columns(2)

]);
}
and
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('General Information')
->schema([Forms\Components\TextInput::make('name')]),
Section::make('Product Information')
->schema([Forms\Components\TextInput::make('code')])

])->columns(2);
}
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('General Information')
->schema([Forms\Components\TextInput::make('name')]),
Section::make('Product Information')
->schema([Forms\Components\TextInput::make('code')])

])->columns(2);
}
Both don't work.
6 replies
FFilament
Created by Wim on 1/3/2024 in #❓┊help
Conditionally display Form TextInput
I have the following text input:
Forms\Components\TextInput::make('vouchers.code')
->label('Voucher')
Forms\Components\TextInput::make('vouchers.code')
->label('Voucher')
It can be that there is no voucher code and then I prefer not to show the Text Input. If there is a voucher code, I want to show the Text Input. Note: not sure if relevant but I'm using this inside the action method of a table. How can this be achieved?
4 replies