Asmit Nepali
Asmit Nepali
FFilament
Created by Asmit Nepali on 11/14/2024 in #❓┊help
TextColumn text clickable.
No description
2 replies
FFilament
Created by Asmit Nepali on 10/24/2024 in #❓┊help
Share form problem.
No description
8 replies
FFilament
Created by Asmit Nepali on 10/19/2024 in #❓┊help
Custom field dynamic query
Here I have to create a custom field where I have to show suggestion by type [ char and variable name. I want to make it generic where user should pass the query builder and suggest according to the user enter value.
DynamicVairable::make('dynamic_varibale')
->modifyingQuery(function () {
return Notification::query();
})
DynamicVairable::make('dynamic_varibale')
->modifyingQuery(function () {
return Notification::query();
})
But I don't know how to make it dynamic
class DynamicVairable extends Field
{
protected string $view = 'forms.components.variable-field';

public string $text = '';


public Builder |\Closure $modifyingQuery;

public function modifyingQuery(Builder | \Closure $modifyingQuery): static
{
$this->modifyingQuery = $modifyingQuery;

return $this;
}

public function getModifyingQuery()
{
if($this->modifyingQuery instanceof \Closure) {
return ($this->modifyingQuery)();
}
return $this->modifyingQuery;
}

public function searchVariable(string $value)
{
$this->getModifyingQuery()->where('variable', 'like', '%'.$value.'%')->get();
}
}
class DynamicVairable extends Field
{
protected string $view = 'forms.components.variable-field';

public string $text = '';


public Builder |\Closure $modifyingQuery;

public function modifyingQuery(Builder | \Closure $modifyingQuery): static
{
$this->modifyingQuery = $modifyingQuery;

return $this;
}

public function getModifyingQuery()
{
if($this->modifyingQuery instanceof \Closure) {
return ($this->modifyingQuery)();
}
return $this->modifyingQuery;
}

public function searchVariable(string $value)
{
$this->getModifyingQuery()->where('variable', 'like', '%'.$value.'%')->get();
}
}
This is my custom field
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<input x-model="state">
</div>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<input x-model="state">
</div>
</x-dynamic-component>
Please suggest some idea I tried with livewire component but from field class I'm not able to pass query builder
7 replies
FFilament
Created by Asmit Nepali on 10/17/2024 in #❓┊help
Custom Field Send Multiple Data
I have to create a custom field and I have to send extra form data while submit the form with extra customization. like Here I make custom field by extending Rich Editor
CustomBio::make('bio')
->columnSpanFull(),
CustomBio::make('bio')
->columnSpanFull(),
This is my custom field class
<?php

namespace PackiMaster\Bio\Forms\Components;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Set;

class CustomBio extends RichEditor
{
protected string $view = 'bio::forms.components.bio-editor';

protected array|\Closure $mentionsItems = [];

public function setUp(): void
{
parent::setUp();

// Adding a hook to modify the form data on submission
$this->afterStateHydrated(function ($component, $state, Set $set) {
// Original state remains untouched
$set($this->getStatePath(), $state);

// Add mentions as separate data
$set('bio_with_style', 'SOME_EXTRA_CUSTOMIZATION');
});

}

}
<?php

namespace PackiMaster\Bio\Forms\Components;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Set;

class CustomBio extends RichEditor
{
protected string $view = 'bio::forms.components.bio-editor';

protected array|\Closure $mentionsItems = [];

public function setUp(): void
{
parent::setUp();

// Adding a hook to modify the form data on submission
$this->afterStateHydrated(function ($component, $state, Set $set) {
// Original state remains untouched
$set($this->getStatePath(), $state);

// Add mentions as separate data
$set('bio_with_style', 'SOME_EXTRA_CUSTOMIZATION');
});

}

}
How to send extra data
bio_with_style
bio_with_style
on submit the form ?
8 replies
FFilament
Created by Asmit Nepali on 10/15/2024 in #❓┊help
File Upload Issue
No description
9 replies
FFilament
Created by Asmit Nepali on 10/2/2024 in #❓┊help
Filament notification delete issue.
No description
3 replies
FFilament
Created by Asmit Nepali on 9/20/2024 in #❓┊help
How to registerAction on table selectColumn ?
SelectColumn::make('subject')
->options([])
->registerActions()
SelectColumn::make('subject')
->options([])
->registerActions()
This did not work
11 replies
FFilament
Created by Asmit Nepali on 9/5/2024 in #❓┊help
Add table name on edit page query
select
"products".*
from
"products"
inner join "categories" on "products"."category_id" = "categories"."id"
where
"id" = 8
and "categories"."type_id" = 1
and "products"."deleted_at" is null
limit
1
select
"products".*
from
"products"
inner join "categories" on "products"."category_id" = "categories"."id"
where
"id" = 8
and "categories"."type_id" = 1
and "products"."deleted_at" is null
limit
1
Here I use scope to fetch product for that types, The
id
id
Ambiguous issue is occur while try to edit and view the individual product, Is there any way to add table name on where
id
id
clause on filament to fetch individual record. like
select
"products".*
from
"products"
inner join "categories" on "products"."category_id" = "categories"."id"
where
"products.id" = 8
and "categories"."type_id" = 1
and "products"."deleted_at" is null
limit
1
select
"products".*
from
"products"
inner join "categories" on "products"."category_id" = "categories"."id"
where
"products.id" = 8
and "categories"."type_id" = 1
and "products"."deleted_at" is null
limit
1
2 replies
FFilament
Created by Asmit Nepali on 8/29/2024 in #❓┊help
Repeater edit value with array type.
No description
1 replies
FFilament
Created by Asmit Nepali on 8/8/2024 in #❓┊help
Hint action disappear.
Forms\Components\Select::make('client_id')
->native(false)
->preload()
->live()
->relationship('client', 'title',
->required()
->afterStateUpdated(function (Forms\Components\Select $select, $state) {
$select->hintAction(
Forms\Components\Actions\Action::make('View Client Accoutnts')
->action(function () {
info('View Rate Card');
})
);
}
}),
Forms\Components\Select::make('client_id')
->native(false)
->preload()
->live()
->relationship('client', 'title',
->required()
->afterStateUpdated(function (Forms\Components\Select $select, $state) {
$select->hintAction(
Forms\Components\Actions\Action::make('View Client Accoutnts')
->action(function () {
info('View Rate Card');
})
);
}
}),
While I try to click on hint, it disappear.
7 replies
FFilament
Created by Asmit Nepali on 8/6/2024 in #❓┊help
Load relationship on widget
I create a ManageRelatedRecord and add widget on it. While user save product card then it add the row on table below This is my widget
class AddProductCardWidget extends Widget implements HasForms
{
use InteractsWithForms;
use InteractsWithPageTable;

protected static string $view = 'filament.resources.product-resource.widgets.add-product-card-widget';

protected function getTablePage(): string
{
return ManageProductCards::class;
}

public function form(Form $form): Form
{
return $form->schema([
Select::make('rate_type_id')
->required()
->live()
->relationship('productCard', 'name'),
]);
}
}
class AddProductCardWidget extends Widget implements HasForms
{
use InteractsWithForms;
use InteractsWithPageTable;

protected static string $view = 'filament.resources.product-resource.widgets.add-product-card-widget';

protected function getTablePage(): string
{
return ManageProductCards::class;
}

public function form(Form $form): Form
{
return $form->schema([
Select::make('rate_type_id')
->required()
->live()
->relationship('productCard', 'name'),
]);
}
}
Inside MRR
protected function getHeaderWidgets(): array
{
return [
SpecialityResource\Widgets\AddProductCardWidget::class,
];
}
protected function getHeaderWidgets(): array
{
return [
SpecialityResource\Widgets\AddProductCardWidget::class,
];
}
2 replies
FFilament
Created by Asmit Nepali on 8/6/2024 in #❓┊help
Why Repeater items are not sent to the backend ?
Here I change the model explicitly
->model(Product::class)
->model(Product::class)
class ManageProductClients extends ManageRelatedRecords
{
protected static string $resource = ProductResource::class;

protected static string $relationship = 'clients';

protected static ?string $navigationIcon = 'heroicon-o-banknotes';


public function form(Form $form): Form
{
return $form
->schema(
[
Forms\Components\Repeater::make('Clients')
->model(Product::class)
->relationship('clients')
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\Select::make('client_id')
->required()
->live()
->relationship('client', 'name')
])->columns(4),
])
->columnSpanFull(),
]
);
}
}
class ManageProductClients extends ManageRelatedRecords
{
protected static string $resource = ProductResource::class;

protected static string $relationship = 'clients';

protected static ?string $navigationIcon = 'heroicon-o-banknotes';


public function form(Form $form): Form
{
return $form
->schema(
[
Forms\Components\Repeater::make('Clients')
->model(Product::class)
->relationship('clients')
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\Select::make('client_id')
->required()
->live()
->relationship('client', 'name')
])->columns(4),
])
->columnSpanFull(),
]
);
}
}
This is my table action
->headerActions([
Tables\Actions\CreateAction::make()
->modalWidth('7xl'),
])
->headerActions([
Tables\Actions\CreateAction::make()
->modalWidth('7xl'),
])
7 replies
FFilament
Created by Asmit Nepali on 7/19/2024 in #❓┊help
Send extra field from custom field.
I have this custom field
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="mentionable($wire.entangle('{{ $getStatePath() }}'))">
<input type="hidden" name="content" value="test content">
<input type="text" x-model="state">
</div>
</x-dynamic-component>
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
<div x-data="mentionable($wire.entangle('{{ $getStatePath() }}'))">
<input type="hidden" name="content" value="test content">
<input type="text" x-model="state">
</div>
</x-dynamic-component>
This is my custom component class
class CustomInputFiled extends Field
{
public string $content = '';

protected string $view = 'forms.components.metion-me';
}
class CustomInputFiled extends Field
{
public string $content = '';

protected string $view = 'forms.components.metion-me';
}
How to send this content with form data in filament ?
2 replies
FFilament
Created by Asmit Nepali on 7/15/2024 in #❓┊help
canViewAny on Manage Related Record.
Why
canViewAny()
canViewAny()
method not working on MRR(Manage Related Record)
protected function canViewAny(): bool
{
return false;
}
protected function canViewAny(): bool
{
return false;
}
I use dd() on this, but nothing happen
2 replies
FFilament
Created by Asmit Nepali on 7/7/2024 in #❓┊help
HasMany relationship inverse method name.
I have Customer model and Manager model. Where Manager can manage multiple Customer. My Customer model method
public function manager(): BelongsTo
{
return $this->belongsTo(Manager::class);
}
public function manager(): BelongsTo
{
return $this->belongsTo(Manager::class);
}
My Manager model method
public function customers(): HasMany
{
return $this->hasMany(Customer::class);
}
public function customers(): HasMany
{
return $this->hasMany(Customer::class);
}
While I try to associate custom on manager then this error is shown.
Call to undefined method App\Models\Customer::managers()
Call to undefined method App\Models\Customer::managers()
I user MRR (Manage Related Record) for manage relationship. I don't know why it calls managers instead of manager.
3 replies
FFilament
Created by Asmit Nepali on 6/17/2024 in #❓┊help
How to change the create button label globally ?
No description
5 replies
FFilament
Created by Asmit Nepali on 6/14/2024 in #❓┊help
Table Delete Action global configuration not working
I tried to configure the delete action from the service provider boot method in but it won't work.
DeleteAction::configureUsing(function (DeleteAction $deleteAction) {
return $deleteAction->action(function ($record) {
try {
$record->delete();
Notification::make()
->success()
->title('Record deleted successfully!')
->send();
} catch (\Exception $e) {
Notification::make()
->danger()
->title($e->getMessage())
->duration(5000)
->send();
}
});
});
DeleteAction::configureUsing(function (DeleteAction $deleteAction) {
return $deleteAction->action(function ($record) {
try {
$record->delete();
Notification::make()
->success()
->title('Record deleted successfully!')
->send();
} catch (\Exception $e) {
Notification::make()
->danger()
->title($e->getMessage())
->duration(5000)
->send();
}
});
});
2 replies
FFilament
Created by Asmit Nepali on 6/14/2024 in #❓┊help
Repeat form components with morphToMany delete previous data and add new data.
I have a user table and users may have different roles. Role could be added from form or other table action. Role can be Repeat form components with roles relationship. While I'm add through the create action then it works fine. But I made a table action add roles from the user table and show form with a repeat field role then it deleted old data and saved new data.
4 replies
FFilament
Created by Asmit Nepali on 6/13/2024 in #❓┊help
Action failed notification.
I have to delete the record from the table using table delete actions, Sometimes there is an issue with delete operation and throw the exception, I want to show that exception message on failed notification. How can I do that in filament.
9 replies
FFilament
Created by Asmit Nepali on 6/7/2024 in #❓┊help
Filament file upload issue
Here, I have a attachment form. In that form I choose a file to upload and it take time to complete upload process in temp dir. During uploading process if I do other action like type any other input field then it reset the upload: Shown in video
5 replies