Ehsan
Ehsan
FFilament
Created by Ehsan on 2/18/2024 in #❓┊help
File upload with Livewire component
The solution is to save the relationships manually with model creation. Means, if you are passing Model::class to the ->model(Model::class); form creation method, you have to manually save the relationships by calling saveRelationships() method on form class. $this->form->model($member)->saveRelationships();
4 replies
FFilament
Created by Mehmet K. on 11/28/2023 in #❓┊help
How can I prevent the record creation if the conditions are not met in the BeforeCreate method?
Happy to help
6 replies
FFilament
Created by Mehmet K. on 11/28/2023 in #❓┊help
How can I prevent the record creation if the conditions are not met in the BeforeCreate method?
For filament v3, you can use
protected function handleRecordCreation(array $data): Model
{
$user = Auth::user();

// Retrieve the user's credit status from the database
$credits = $user->credits;

if ($credits >= 2) {
return static::getModel()::create($data);
} else {
// Insufficient credit, prevent record creation and throw an error notification
Notification::make()
->title('Insufficient Credit')
->error()
->send();

// Return false to prevent record creation
return false;
}
}
protected function handleRecordCreation(array $data): Model
{
$user = Auth::user();

// Retrieve the user's credit status from the database
$credits = $user->credits;

if ($credits >= 2) {
return static::getModel()::create($data);
} else {
// Insufficient credit, prevent record creation and throw an error notification
Notification::make()
->title('Insufficient Credit')
->error()
->send();

// Return false to prevent record creation
return false;
}
}
Alternatively, you can also use halt the creation process like this
protected function beforeCreate(): void
{
$user = Auth::user();

// Retrieve the user's credit status from the database
$credits = $user->credits;

if ($credits < 2) {
// Insufficient credit, prevent record creation and throw an error notification
Notification::make()
->title('Insufficient Credit')
->error()
->send();

$this->halt();
}
}
protected function beforeCreate(): void
{
$user = Auth::user();

// Retrieve the user's credit status from the database
$credits = $user->credits;

if ($credits < 2) {
// Insufficient credit, prevent record creation and throw an error notification
Notification::make()
->title('Insufficient Credit')
->error()
->send();

$this->halt();
}
}
6 replies
FFilament
Created by Abrar on 11/28/2023 in #❓┊help
Show one time messages for user guidance
Try this package https://github.com/JibayMcs/filament-tour
2 replies
FFilament
Created by ericmp #2 on 11/28/2023 in #❓┊help
Disable createAnother in form footer
You can also use protected static bool $canCreateAnother = false; in the create page
9 replies
FFilament
Created by ericmp #2 on 11/28/2023 in #❓┊help
Disable createAnother in form footer
Use CreateAction::make()->disableCreateAnother()
9 replies
FFilament
Created by Ehsan on 8/29/2023 in #❓┊help
Unable to use colors on blade components in livewire form component
I was using filament/filament panel builder and not installed form builder specifically. Followed this tailwindcss.config.js configuration and it worked. Thank you. My tailwind.config.js file looks like this now
import preset from './vendor/filament/support/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./resources/**/*.blade.php',
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
]
}
import preset from './vendor/filament/support/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./resources/**/*.blade.php',
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
]
}
6 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
Removing the manual entry for Alpine.start() in resources/js/app.js fixed the issue.
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
Can you please share the component view file and the layout on how you have implemented it.
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
@krekas This one is on admin panel side, not the livewire form component
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
Same is happening with basic FileUpload component
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
19 replies
FFilament
Created by Ehsan on 8/27/2023 in #❓┊help
Spatie Media Library plugin not working in livewire form component
There are no console errors.
19 replies
FFilament
Created by Ehsan on 8/17/2023 in #❓┊help
Disabling dark mode for form component only
I am following this example https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component It can be either for the same form component or the whole page.
6 replies
FFilament
Created by Ehsan on 7/29/2023 in #❓┊help
Help with custom resource page
But there is no layouts.base defined. Or is it? Will have to create a new one.
6 replies
FFilament
Created by Ehsan on 7/29/2023 in #❓┊help
Help with custom resource page
I was able to access the record using mount() method on PrintCouponBatch class by doing
public function mount(CouponBatch $record): void
{
$this->couponBatch = $record;
}
public function mount(CouponBatch $record): void
{
$this->couponBatch = $record;
}
Now I want a custom blank layout for the page and not default admin panel container.
6 replies
FFilament
Created by Ehsan on 7/26/2023 in #❓┊help
Update TextInput programmatically in reactive way
Thank you. Worked like charm
5 replies