pratik
pratik
FFilament
Created by RMK147 on 10/3/2024 in #❓┊help
Form Builder Block & Spatie Media Library
5 replies
FFilament
Created by Adnan Yalahow on 5/12/2024 in #❓┊help
Can I create something like this in filament
@Adnan Yalahow Filament way is the TALL way. create custom filament page with custom view, Create blade components, use tailwind for styles, use Filament Modals, Filament actions and sprinkle some livewire and alpinejs. Here are some useful blade components mentioned in the documentation : https://filamentphp.com/docs/3.x/support/blade-components/overview
4 replies
FFilament
Created by xerk4497 on 5/11/2024 in #❓┊help
Create Policies for each Auth Model (Multi Panels)
If you are trying to achieve different polices for different panels you can do something like this in AuthServiceProvider:
use Illuminate\Support\Facades\Gate;

Gate::guessPolicyNamesUsing(function ($modelClass) {
return str($modelClass)
->replace(
search: 'App\Models\\'.str(filament()->getCurrentPanel()- >getId())->studly(),
replace: 'App\Policies\\'.str(filament()->getCurrentPanel()->getId())->studly()
)
->append('Policy')
->toString();
});

$this->registerPolicies();
use Illuminate\Support\Facades\Gate;

Gate::guessPolicyNamesUsing(function ($modelClass) {
return str($modelClass)
->replace(
search: 'App\Models\\'.str(filament()->getCurrentPanel()- >getId())->studly(),
replace: 'App\Policies\\'.str(filament()->getCurrentPanel()->getId())->studly()
)
->append('Policy')
->toString();
});

$this->registerPolicies();
Suppose you have two panel providers, AdminPanelProvider and CustomerPanelProvider, To use this implementation, you should have Admin related Models in App\Models\Admin directory and Customer related models in App\Models\Customer directory. Also, Admin related policies in App\Policies\Admin and Customer related policies in App\Policies\Customer directory. The directory name is based on Panel's id.
5 replies
FFilament
Created by Sayy on 5/11/2024 in #❓┊help
Error when select data with afterstateupdated
From as much as I understand, This simple if condition will solve your problem.
->afterStateUpdated(function ($state) {
if($state){
$product = Product::find($state);
$this->record->orderDetails()->updateOrCreate(
[
'order_id' => $this->record->id,
'product_id' => $state,
],
[
'product_id' => $state,
'quantity' => $this->quantityValue,
'price' => $product->price,
'subtotal' => $product->price * $this->quantityValue,
]
);
}
}),
->afterStateUpdated(function ($state) {
if($state){
$product = Product::find($state);
$this->record->orderDetails()->updateOrCreate(
[
'order_id' => $this->record->id,
'product_id' => $state,
],
[
'product_id' => $state,
'quantity' => $this->quantityValue,
'price' => $product->price,
'subtotal' => $product->price * $this->quantityValue,
]
);
}
}),
11 replies
FFilament
Created by blink on 5/11/2024 in #❓┊help
File (image) upload preview as grid
6 replies
FFilament
Created by Sayy on 5/11/2024 in #❓┊help
Error when select data with afterstateupdated
There is no selected product ($state is null) after you clear the select field, what are you trying to achieve when no product is selected ? you can just check if the $state is not null and wrap the logic in the condition.
11 replies
FFilament
Created by jkbcoder on 5/10/2024 in #❓┊help
Modal Footer
3 replies
FFilament
Created by Roland Barkóczi on 5/11/2024 in #❓┊help
Update RichEditor based on other field
@rolandbarkoczi Can you check again, The same code is working on my machine, and click outside the input field after you have finished typing in Prompt field.
6 replies
FFilament
Created by Sayy on 5/11/2024 in #❓┊help
Error when select data with afterstateupdated
@Sayy let's dd the product after, $product = Product::find($state); and find out if the product is not null .
11 replies
FFilament
Created by BlackShadow on 11/3/2023 in #❓┊help
Chart scales ticks
@CodeWithDennis Have you tried returning RAwJs instead of php array? This is working for me . As mentioned in the docs : https://filamentphp.com/docs/3.x/widgets/charts#setting-chart-configuration-options
use Filament\Support\RawJs;

protected function getOptions(): RawJs
{
return RawJs::make(<<<JS
{
scales: {
y: {
ticks: {
callback: (value) => '€' + value,
},
},
},
}
JS);
}
use Filament\Support\RawJs;

protected function getOptions(): RawJs
{
return RawJs::make(<<<JS
{
scales: {
y: {
ticks: {
callback: (value) => '€' + value,
},
},
},
}
JS);
}
13 replies
FFilament
Created by BlackShadow on 11/3/2023 in #❓┊help
Chart scales ticks
I got it working, I wanted to customize the ticks stepsize
protected function getOptions(): RawJs
{
return RawJs::make(<<<JS
{
scales: {
y: {
ticks: {
stepSize: 10,
},
},
},
}
JS);
}
protected function getOptions(): RawJs
{
return RawJs::make(<<<JS
{
scales: {
y: {
ticks: {
stepSize: 10,
},
},
},
}
JS);
}
13 replies
FFilament
Created by BlackShadow on 11/3/2023 in #❓┊help
Chart scales ticks
@CodeWithDennis Stuck with the same problem. Did you figure it out?
13 replies
FFilament
Created by Nima Hamidpour on 1/24/2024 in #❓┊help
how can create custom action?
@Nima Hamidpour You can create custom actions using :
use Filament\Tables\Actions\Action;
Action::make('Download')->icon('icon')->action(function(Model $record){
// do something
}),
use Filament\Tables\Actions\Action;
Action::make('Download')->icon('icon')->action(function(Model $record){
// do something
}),
Inside of $table->actions([ //your action here ]) in public static function table(Table $table) of the Resource. Or you can create a new action class extending the base action class and use it on any table you like.
4 replies
FFilament
Created by pratik on 11/3/2023 in #❓┊help
How to render json column data in table TextColumn
Thank you so much @Dennis Koch @Vp
7 replies
FFilament
Created by pratik on 11/3/2023 in #❓┊help
How to render json column data in table TextColumn
No description
7 replies
FFilament
Created by pratik on 9/25/2023 in #❓┊help
createOptionForm without relationship
@Lara Zeus It works now ! Thanks a lot again.
6 replies
FFilament
Created by pratik on 9/25/2023 in #❓┊help
createOptionForm without relationship
protected function getReferralSourceFormComponent(): Component
{
return Select::make('source')
->options(ReferSource::pluck('name'))
->getOptionLabelUsing(fn ($value): ?string => ucfirst($value))
->searchable()
->createOptionForm([
TextInput::make('name')
->required(),
])
->createOptionUsing(function (array $data) {
$source = new ReferSource();
$source->name = $data['name'];
$source->save();
return $source->name;
})
->label(__('where did you hear about us ?'))
->required();
}
protected function getReferralSourceFormComponent(): Component
{
return Select::make('source')
->options(ReferSource::pluck('name'))
->getOptionLabelUsing(fn ($value): ?string => ucfirst($value))
->searchable()
->createOptionForm([
TextInput::make('name')
->required(),
])
->createOptionUsing(function (array $data) {
$source = new ReferSource();
$source->name = $data['name'];
$source->save();
return $source->name;
})
->label(__('where did you hear about us ?'))
->required();
}
This is my code, The popup doesn't show when clicking plus button.
6 replies
FFilament
Created by pratik on 9/25/2023 in #❓┊help
createOptionForm without relationship
🤯🤯🤯🤯, Thank you @Lara Zeus I didn't find it in the docs.
6 replies
FFilament
Created by pratik on 8/10/2023 in #❓┊help
Tenant password reset token is being stored on landlord password_reset_tokens table.
Here is my tenantPanelProvider's code :
return $panel
->domain()
->id('tenant')
->path('tenant')
->login()
->registration()
->passwordReset()
->authPasswordBroker('tenants')
->emailVerification()
->profile()
->colors([
'primary' => Color::Purple,
])
->discoverResources(in: app_path('Filament/Tenant/Resources'), for: 'App\\Filament\\Tenant\\Resources')
->discoverPages(in: app_path('Filament/Tenant/Pages'), for: 'App\\Filament\\Tenant\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Tenant/Widgets'), for: 'App\\Filament\\Tenant\\Widgets')
->widgets([
Widgets\AccountWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
\Spatie\Multitenancy\Http\Middleware\NeedsTenant::class,
\Spatie\Multitenancy\Http\Middleware\EnsureValidTenantSession::class,
])
->authGuard('tenant')
->authMiddleware([
Authenticate::class,
]);
}
return $panel
->domain()
->id('tenant')
->path('tenant')
->login()
->registration()
->passwordReset()
->authPasswordBroker('tenants')
->emailVerification()
->profile()
->colors([
'primary' => Color::Purple,
])
->discoverResources(in: app_path('Filament/Tenant/Resources'), for: 'App\\Filament\\Tenant\\Resources')
->discoverPages(in: app_path('Filament/Tenant/Pages'), for: 'App\\Filament\\Tenant\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Tenant/Widgets'), for: 'App\\Filament\\Tenant\\Widgets')
->widgets([
Widgets\AccountWidget::class,
])
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
\Spatie\Multitenancy\Http\Middleware\NeedsTenant::class,
\Spatie\Multitenancy\Http\Middleware\EnsureValidTenantSession::class,
])
->authGuard('tenant')
->authMiddleware([
Authenticate::class,
]);
}
2 replies
FFilament
Created by robert on 7/29/2023 in #❓┊help
Recommended way to register tenant panels via domain
@r_sier do you mean to say when someone visits tenant subdomain or domain they get to register as an user to the tenant ?
2 replies