Hasith
Hasith
FFilament
Created by Hasith on 9/9/2024 in #❓┊help
"make:filament-widget" is not defined
I'm successfully using Filament notifications and UI components already in my project. When i try to install widget and try to create new widget as mention in the Doc I'm getting this error.
2 replies
FFilament
Created by Hasith on 5/24/2024 in #❓┊help
Form Database Transactions
How i use DB transactions outside of filament inside my Livewire Component ? If Project create/update failed how i roll back relationship data insertions ?
public function create(): void
{
$data = $this->form->getState();

$data['user_id'] = auth()->id();

$record = Project::create($data);

$this->form->model($record)->saveRelationships();
}
public function create(): void
{
$data = $this->form->getState();

$data['user_id'] = auth()->id();

$record = Project::create($data);

$this->form->model($record)->saveRelationships();
}
3 replies
FFilament
Created by Hasith on 5/23/2024 in #❓┊help
Form css not working
No description
4 replies
FFilament
Created by Hasith on 5/17/2024 in #❓┊help
Convert Repeater to a Multiple Select Field
I have a 'postCategories' Pivot relationship. I already prepared the Models and Relationships as they mentioned in the Doc. The repeater works fine as expected. Is there any way to convert this Repeater field to a multiple-select field? So then it's looks cleaner than a repeater. Because i don't have extra data fields on my pivot table. Just 'post_id' and 'category_id'.
Forms\Components\Repeater::make('postCategories')
->relationship()
->schema([
Select::make('category_id')
->label('Category')
->options(Category::all()->pluck('name', 'id'))
->searchable()->preload()
->required()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
])->minItems(1)
Forms\Components\Repeater::make('postCategories')
->relationship()
->schema([
Select::make('category_id')
->label('Category')
->options(Category::all()->pluck('name', 'id'))
->searchable()->preload()
->required()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
])->minItems(1)
18 replies
FFilament
Created by Hasith on 2/29/2024 in #❓┊help
Repeater - Rollback Main record creation if Pivot Table Data insert failed
I have an Order and Product pivot relationship. If saving pivot table data fails i want to rollback order creation. Is that possible?
2 replies
FFilament
Created by Hasith on 2/22/2024 in #❓┊help
Insert data to a pivot table in table CreateAction?
I have Gem Model and Gem has many Sizes and each size have a price. Size can be belongs to many gems. So i create and pivot table. I added a repeater to set the sizes and price. But Gem creation gives me an error. this is my action and form ===>
Repeater::make('sizes')
->relationship('sizes')
->schema([
Select::make('size_id')
->label('Size')
->options(Size::all()->pluck('size', 'id'))
->searchable()->preload()
->required()->disableOptionsWhenSelectedInSiblingRepeaterItems(),
TextInput::make('price')->suffix('$')->required()->numeric()
->inputMode('decimal'),
])->columns(2)->columnSpanFull()->minItems(1),


public function sizes(): BelongsToMany
{
return $this->belongsToMany(Size::class, 'gem_sizes', 'gem_id', 'size_id')->withPivot('price')->withTimestamps();
}
Repeater::make('sizes')
->relationship('sizes')
->schema([
Select::make('size_id')
->label('Size')
->options(Size::all()->pluck('size', 'id'))
->searchable()->preload()
->required()->disableOptionsWhenSelectedInSiblingRepeaterItems(),
TextInput::make('price')->suffix('$')->required()->numeric()
->inputMode('decimal'),
])->columns(2)->columnSpanFull()->minItems(1),


public function sizes(): BelongsToMany
{
return $this->belongsToMany(Size::class, 'gem_sizes', 'gem_id', 'size_id')->withPivot('price')->withTimestamps();
}
3 replies
FFilament
Created by Hasith on 9/22/2023 in #❓┊help
filament breezy - Myprofile not working with multiple panels
No description
3 replies
FFilament
Created by Hasith on 9/19/2023 in #❓┊help
can i add action button to a stat widget?
I have this widget card. i want to add a button to it and when the user click it I want to delete a record inside the database. Is it possible to add action and how can I do that?
class WarningWidget extends BaseWidget
{
protected static ?int $sort = -2;

protected function getColumns(): int
{
return 1;
}

public static function canView():bool
{

return true;

}

protected function getStats(): array
{
return [

Stat::make('Unknown API Request','')
->description('We are having unknown API request from a unregistered domain')
->icon('heroicon-m-exclamation-triangle')
->color('danger'),

];
}
}
class WarningWidget extends BaseWidget
{
protected static ?int $sort = -2;

protected function getColumns(): int
{
return 1;
}

public static function canView():bool
{

return true;

}

protected function getStats(): array
{
return [

Stat::make('Unknown API Request','')
->description('We are having unknown API request from a unregistered domain')
->icon('heroicon-m-exclamation-triangle')
->color('danger'),

];
}
}
8 replies
FFilament
Created by Hasith on 9/19/2023 in #❓┊help
conditionally render widget stat?
How can I show hide stat using a condition? I want to show the first stat only when $this->productCount > 0.
protected function getStats(): array
{
return [

Stat::make('Processed', '192.1k')
->color('success')
->extraAttributes([
'class' => 'cursor-pointer',
'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),

Stat::make('Product Count', $this->productCount)
->chart([7, 2, 10, 3, 15, 4, 17])
->description('Current product count')
->icon('heroicon-m-banknotes')
->color('success'),
];
}
protected function getStats(): array
{
return [

Stat::make('Processed', '192.1k')
->color('success')
->extraAttributes([
'class' => 'cursor-pointer',
'wire:click' => "\$dispatch('setStatusFilter', { filter: 'processed' })",
]),

Stat::make('Product Count', $this->productCount)
->chart([7, 2, 10, 3, 15, 4, 17])
->description('Current product count')
->icon('heroicon-m-banknotes')
->color('success'),
];
}
6 replies
FFilament
Created by Hasith on 9/15/2023 in #❓┊help
Notification inside a table action
How can i add notification inside an action?
->actions([

Tables\Actions\ViewAction::make(),
TableAction::make('delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-s-trash')
->action(function (User $record) {

Log::info($record);
if($record->id == 1){
Notification::make()
->success()
->title('User deleted')
->body('The user has been deleted successfully.');
}else{
return;
}

}),
])
->actions([

Tables\Actions\ViewAction::make(),
TableAction::make('delete')
->requiresConfirmation()
->color('danger')
->icon('heroicon-s-trash')
->action(function (User $record) {

Log::info($record);
if($record->id == 1){
Notification::make()
->success()
->title('User deleted')
->body('The user has been deleted successfully.');
}else{
return;
}

}),
])
7 replies
FFilament
Created by Hasith on 9/15/2023 in #❓┊help
Use custom tailwind css inside livewire component (resource edit page)?
No description
16 replies
FFilament
Created by Hasith on 9/14/2023 in #❓┊help
How can I access the model object inside the custom Edit page?
No description
9 replies
FFilament
Created by Hasith on 9/13/2023 in #❓┊help
filament-breezy configuration error
No description
1 replies
FFilament
Created by Hasith on 9/7/2023 in #❓┊help
How to use tailwind css inside the filament custom created page?
No description
3 replies
FFilament
Created by Hasith on 9/7/2023 in #❓┊help
Navigation Item Set Active
No description
4 replies