thyk123
thyk123
FFilament
Created by thyk123 on 10/27/2024 in #❓┊help
Make custom form like GForm
Hello, I have a new project to make a custom form like GForm where the user tenant can create custom forms themselves. So the custom forms will made and appear on the front page and filled by the guest.
Is that possible in filament? Do you have any suggestions? Thank you and have a nice day!
2 replies
FFilament
Created by thyk123 on 5/26/2024 in #❓┊help
is it possible to get model name inside resource?
is it possible to get model name inside resource? i want to get model name and query it like this
(fn (Builder $query) => $query->where('type', $modelName/$resourcesName)->where('deleted_at',)),
(fn (Builder $query) => $query->where('type', $modelName/$resourcesName)->where('deleted_at',)),
Is that possible? thank you!
5 replies
FFilament
Created by thyk123 on 5/26/2024 in #❓┊help
notification inside action not showing
i have code action like this but when it create, the success notification not fired how to tackle this? thank you!
->suffixAction(
Forms\Components\Actions\Action::make('newCategoryForAsset')
->icon('heroicon-m-squares-plus')
->form([
Forms\Components\TextInput::make('name')
->maxLength(255)
->required(),
Forms\Components\TextArea::make('note')
])
->mutateFormDataUsing(function (array $data): array {
$data['type'] = 'Asset';
$data['user_id'] = auth()->id();
return $data;
})
->successNotification(function (array $data){
Notification::make()
->title('Category registered')
->body('Saved new '.$data['type'].' category named '.$data['name'].'.')
->success();
})
->action(function (array $data): void {
Category::create($data);
})
),
->suffixAction(
Forms\Components\Actions\Action::make('newCategoryForAsset')
->icon('heroicon-m-squares-plus')
->form([
Forms\Components\TextInput::make('name')
->maxLength(255)
->required(),
Forms\Components\TextArea::make('note')
])
->mutateFormDataUsing(function (array $data): array {
$data['type'] = 'Asset';
$data['user_id'] = auth()->id();
return $data;
})
->successNotification(function (array $data){
Notification::make()
->title('Category registered')
->body('Saved new '.$data['type'].' category named '.$data['name'].'.')
->success();
})
->action(function (array $data): void {
Category::create($data);
})
),
8 replies
FFilament
Created by thyk123 on 5/26/2024 in #❓┊help
is it possible to use mutateFormDataUsing inside createOptionForm
based on the title, is it possible to use mutateFormDataUsing inside createOptionForm? How to achive that? thank you!
4 replies
FFilament
Created by thyk123 on 5/21/2024 in #❓┊help
get maxvalue qty based on stock
hello, I want to set
maxValue
maxValue
on
TextInput::make('qty')->numeric()
TextInput::make('qty')->numeric()
from specific qty stock based on what the user chooses in
Select::make('inventory_id')
Select::make('inventory_id')
but as we know
Select
Select
isn't chosen yet by the user and make the
TextInput::make('qty')->numeric()
TextInput::make('qty')->numeric()
got an error
Forms\Components\Select::make('inventory_id')
->label('Inventory Name')
->distinct()
->required()
->live()
->options(Inventory::all()->pluck('asset_name', 'id'))
->searchable(),
Forms\Components\TextInput::make('qty')
->numeric()
->minValue(1)
->step(1)
->maxValue(function(Forms\Get $get, $record)
{
if (!empty($record))
return $record->inventory->qty-$record->inventory->inventory_location_list->count();
else return Inventory::where('id',$get('inventory_id'))->select(['qty'])->first()->qty;
})
->required(),
Forms\Components\Select::make('inventory_id')
->label('Inventory Name')
->distinct()
->required()
->live()
->options(Inventory::all()->pluck('asset_name', 'id'))
->searchable(),
Forms\Components\TextInput::make('qty')
->numeric()
->minValue(1)
->step(1)
->maxValue(function(Forms\Get $get, $record)
{
if (!empty($record))
return $record->inventory->qty-$record->inventory->inventory_location_list->count();
else return Inventory::where('id',$get('inventory_id'))->select(['qty'])->first()->qty;
})
->required(),
How could i tackle this problem? Thank you so much!
9 replies
FFilament
Created by thyk123 on 5/21/2024 in #❓┊help
Change layout of Dynamic form
hello I have a dynamic form like this but instead of the layout dynamic form shown below, I want it to show beside the customer button. How can I achieve that?
Forms\Components\Placeholder::make('Choose and input customer data'), FilamentSelectify\Components\ButtonGroup::make('customer_type')
->live()
->required()
->afterStateUpdated(fn ( FilamentSelectify\Components\ButtonGroup $component) => $component
->getContainer()
->getComponent('dynamicCustomerForm')
->getChildComponentContainer()
->fill()),
Forms\Components\Grid::make(3)
->schema(fn (Forms\Get $get): array => match ($get('customer_type')) {
default => [],
})
->key('dynamicCustomerForm'),
Forms\Components\Placeholder::make('Choose and input customer data'), FilamentSelectify\Components\ButtonGroup::make('customer_type')
->live()
->required()
->afterStateUpdated(fn ( FilamentSelectify\Components\ButtonGroup $component) => $component
->getContainer()
->getComponent('dynamicCustomerForm')
->getChildComponentContainer()
->fill()),
Forms\Components\Grid::make(3)
->schema(fn (Forms\Get $get): array => match ($get('customer_type')) {
default => [],
})
->key('dynamicCustomerForm'),
2 replies
FFilament
Created by thyk123 on 5/16/2024 in #❓┊help
is it possible to add loading screen
I want to ask is it possible to add loading state in forms\components\section while make all the component ready after update? If possible how to achive that? Thank you!
7 replies
FFilament
Created by thyk123 on 5/16/2024 in #❓┊help
return string instead array
hello i have this code want to show student fullName
Tables\Columns\TextColumn::make('customer_id')
->label('Customer Name')
->formatStateUsing(function ($record, string $state): string{
switch ($record->customer_type) {
case 'student':
return Student::where('id', $state)->select(['first_name','last_name'])->get();
// dd($data);
break
Tables\Columns\TextColumn::make('customer_id')
->label('Customer Name')
->formatStateUsing(function ($record, string $state): string{
switch ($record->customer_type) {
case 'student':
return Student::where('id', $state)->select(['first_name','last_name'])->get();
// dd($data);
break
but i get like this
[{"first_name":"lskdn","last_name":"laksjd"}]
[{"first_name":"lskdn","last_name":"laksjd"}]
how to show pnly first_name and last_name value? thank you
5 replies
FFilament
Created by thyk123 on 5/15/2024 in #❓┊help
insert value from function when create
hello i want to insert new invoice_number from function when create the form. I try using
formatStateUsing
formatStateUsing
seems like no working at all. please help, thank you!
Forms\Components\TextInput::make('invoice_number')
->readOnly()
->unique()
->validationMessages([
'unique' => 'Oops... seems like the :attribute has already been used by other, just generate again!.',
])
->formatStateUsing(function (Forms\Set $set) {
self::generateInvoiceNumber($set);
})
->hintAction(
Action::make('newInvoiceNumber')
->icon('heroicon-s-arrow-path')
->action(function (Forms\Set $set) {
self::generateInvoiceNumber($set);
})
),
Forms\Components\TextInput::make('invoice_number')
->readOnly()
->unique()
->validationMessages([
'unique' => 'Oops... seems like the :attribute has already been used by other, just generate again!.',
])
->formatStateUsing(function (Forms\Set $set) {
self::generateInvoiceNumber($set);
})
->hintAction(
Action::make('newInvoiceNumber')
->icon('heroicon-s-arrow-path')
->action(function (Forms\Set $set) {
self::generateInvoiceNumber($set);
})
),
9 replies
FFilament
Created by thyk123 on 5/15/2024 in #❓┊help
is it possible to make maxvalue in texinput dependant based on select?
i want to achieve that max value from text input can change depend on how many qty left in stock from 'asset_id', so when the user select specific 'asset_id', max value 'to_use' field is change depend on what user select Thank you for your help!
Select::make('asset_id')
TextInput::make('to use')
->numeric()
->minValue(1)
->maxValue(get qty from select asset_id)
Select::make('asset_id')
TextInput::make('to use')
->numeric()
->minValue(1)
->maxValue(get qty from select asset_id)
3 replies
FFilament
Created by thyk123 on 5/15/2024 in #❓┊help
is it possible to group select items from query database
is it possible to group select from this
Select::make('status')
->searchable()
->options([
'In Process' => [
'draft' => 'Draft',
'reviewing' => 'Reviewing',
],
'Reviewed' => [
'published' => 'Published',
'rejected' => 'Rejected',
],
])
Select::make('status')
->searchable()
->options([
'In Process' => [
'draft' => 'Draft',
'reviewing' => 'Reviewing',
],
'Reviewed' => [
'published' => 'Published',
'rejected' => 'Rejected',
],
])
but get the group list from query database like this with category hasmany sub category:
Forms\Components\Select::make('payment_type_list_id')
->options([
category::query() => [
sub_category::query()]
])
Forms\Components\Select::make('payment_type_list_id')
->options([
category::query() => [
sub_category::query()]
])
thank you!
25 replies
FFilament
Created by thyk123 on 5/15/2024 in #❓┊help
Reset/load fields after select field updated
Hello, i want to make field qty reset or loaded after select field updated.
Forms\Components\Select::make('inventory_id')
->label('Inventory Name')
->distinct()
->required()
->live()
->options(Inventory::all()->pluck('asset_name', 'id'))
->searchable()
->afterStateUpdated(function (Livewire $livewire) {
$livewire->reset('qty');
}),

\LaraZeus\Quantity\Components\Quantity::make('qty')
->minValue(1)
->maxValue(function($record){
if(!empty($record))
$record->inventory->qty-$record->inventory->inventory_location_list->count();
else return '1';
})
->required(),
Forms\Components\Select::make('inventory_id')
->label('Inventory Name')
->distinct()
->required()
->live()
->options(Inventory::all()->pluck('asset_name', 'id'))
->searchable()
->afterStateUpdated(function (Livewire $livewire) {
$livewire->reset('qty');
}),

\LaraZeus\Quantity\Components\Quantity::make('qty')
->minValue(1)
->maxValue(function($record){
if(!empty($record))
$record->inventory->qty-$record->inventory->inventory_location_list->count();
else return '1';
})
->required(),
I want to get data maxValue qty have relationship from $record that must be selected before How to achive that? Thank you!
6 replies
FFilament
Created by thyk123 on 5/13/2024 in #❓┊help
how to mutateFormDataBeforeCreate inside simple resource?
Hello, i want to ask how to use mutateFormDataBeforeCreate inside simple resouce because i try to add here
use App\Filament\Resources\CashflowResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;

class ManageCashflows extends ManageRecords
{
protected static string $resource = CashflowResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}

protected function mutateFormDataBeforeCreate(array $data): array
{
$data['user_id'] = auth()->id();

return $data;
}
}
use App\Filament\Resources\CashflowResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;

class ManageCashflows extends ManageRecords
{
protected static string $resource = CashflowResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}

protected function mutateFormDataBeforeCreate(array $data): array
{
$data['user_id'] = auth()->id();

return $data;
}
}
it doesn't work Thank you
6 replies
FFilament
Created by thyk123 on 5/13/2024 in #❓┊help
Call another model inside repeater, it is possible?
I want to use another model inside repeater form like this
->maxValue(fn(Inventory $record) => dd($record))
->maxValue(fn(Inventory $record) => dd($record))
but get error like this
App\Filament\Resources\InventoryLocationResource::App\Filament\Resources\{closure}(): Argument #1 ($record) must be of type App\Models\Inventory, App\Models\InventoryLocationList given, called in D:\asc\vendor\filament\support\src\Concerns\EvaluatesClosures.php on line 35
App\Filament\Resources\InventoryLocationResource::App\Filament\Resources\{closure}(): Argument #1 ($record) must be of type App\Models\Inventory, App\Models\InventoryLocationList given, called in D:\asc\vendor\filament\support\src\Concerns\EvaluatesClosures.php on line 35
9 replies
FFilament
Created by thyk123 on 5/13/2024 in #❓┊help
it is possible to make badges with link for each badge
I want to ask it is possible to make badges in table that have multiple url link for each badge? If it is possible how to do that? Thank you
8 replies
FFilament
Created by thyk123 on 5/12/2024 in #❓┊help
badge with link and show name instead id
Hello everyone! Have a nice weekend! I want to ask about my code here below
Tables\Columns\TextColumn::make('inventory_location_list.inventory_location.id')
->searchable()
->badge()
->url(function ($state): string {
return InventoryLocationResource::getUrl('edit', ['record' => $state[0]]);
})
->separator(',')
->label('At Room'),
Tables\Columns\TextColumn::make('inventory_location_list.inventory_location.id')
->searchable()
->badge()
->url(function ($state): string {
return InventoryLocationResource::getUrl('edit', ['record' => $state[0]]);
})
->separator(',')
->label('At Room'),
firstly I want to make each badge from the relationship have a link, not only 1 link but multiple links from how much data from the relationship second, I want to show
inventory_location.room_name
inventory_location.room_name
instead
inventory_location.id
inventory_location.id
but still want to get the id for link the URL each badge how can I do that? Thank you!
8 replies
FFilament
Created by thyk123 on 4/4/2024 in #❓┊help
grouping table with boolean
No description
2 replies
FFilament
Created by thyk123 on 4/4/2024 in #❓┊help
I want to mutate record data using $this->record
how to
mutateRecordDataUsing
mutateRecordDataUsing
but using $this->record array? Thank you
protected function getHeaderActions(): array
{
return [
EditAction::make()
->label('Check In')
->record($this->record)
->form([
Toggle::make('isCheckedIn'),
])
//below doesn't work if using $this->record
->mutateRecordDataUsing(function (array $this->record): array {
$data['chekedInTime'] = Carbon::now();

return $data;
})
];
}
protected function getHeaderActions(): array
{
return [
EditAction::make()
->label('Check In')
->record($this->record)
->form([
Toggle::make('isCheckedIn'),
])
//below doesn't work if using $this->record
->mutateRecordDataUsing(function (array $this->record): array {
$data['chekedInTime'] = Carbon::now();

return $data;
})
];
}
5 replies
FFilament
Created by thyk123 on 4/1/2024 in #❓┊help
dark mode in form livewire component
Hi, i want to ask how to make a dark mode or auto color theme in livewire component. My Livewire component always in light mode
4 replies
FFilament
Created by thyk123 on 3/21/2024 in #❓┊help
add label in layout table split
Hi i try to use split on my table so it can be responsive. But it missing the column title, is anything to bring back title or there is way to add label before the text? Thank you
4 replies