Tieme
Tieme
FFilament
Created by Tieme on 12/17/2023 in #❓┊help
EditTenantProfile in Navigation
up
5 replies
FFilament
Created by Tieme on 2/24/2025 in #❓┊help
Disable validation (when save as concept)
i solved it like this. create a function in the resource
private static function requiredConcept(): \Closure
{
return fn ($livewire) => ! array_key_exists('status', $livewire->data) || $livewire->data['status'] != CarStatus::CONCEPT;
}
private static function requiredConcept(): \Closure
{
return fn ($livewire) => ! array_key_exists('status', $livewire->data) || $livewire->data['status'] != CarStatus::CONCEPT;
}
and call this function in required
Forms\Components\TextInput::make('price')
->prefixIcon('heroicon-o-currency-euro')
->formatStateUsing(fn ($state) => str_replace('.', ',', $state))
->mask(Support\RawJs::make('$money($input, \',\', \' \', 2)'))
->stripCharacters(' ')
->dehydrateStateUsing(fn ($state) => str_replace(',', '.', $state))
->columnSpan([
'default' => 1,
])
->required(self::requiredConcept()),
Forms\Components\TextInput::make('price')
->prefixIcon('heroicon-o-currency-euro')
->formatStateUsing(fn ($state) => str_replace('.', ',', $state))
->mask(Support\RawJs::make('$money($input, \',\', \' \', 2)'))
->stripCharacters(' ')
->dehydrateStateUsing(fn ($state) => str_replace(',', '.', $state))
->columnSpan([
'default' => 1,
])
->required(self::requiredConcept()),
and change the create action
$this->getCreateFormAction()
->label(Helpers::translate('Create Subscription'))
->keyBindings(false)
->color('success')
->submit(null)
->action(function ($livewire) {
$livewire->data['status'] = CarStatus::PENDING;
$this->create();
})
->requiresConfirmation()
$this->getCreateFormAction()
->label(Helpers::translate('Create Subscription'))
->keyBindings(false)
->color('success')
->submit(null)
->action(function ($livewire) {
$livewire->data['status'] = CarStatus::PENDING;
$this->create();
})
->requiresConfirmation()
If someone has a different more reliable approached i would love to here it.
6 replies
FFilament
Created by Alnuaimi on 2/18/2024 in #❓┊help
Too many login attempts Not work.
13 replies
FFilament
Created by Tieme on 2/13/2025 in #❓┊help
Import validation
I think it was a cache issue, after removing all the cache and tried it again. No errors.
14 replies
FFilament
Created by Tieme on 2/13/2025 in #❓┊help
Import validation
The import has "NULL" as string, and in database i want it to be null so nothing in DB if from_email = 'NULL' if i only use
php ImportColumn::make('from_email')
php ImportColumn::make('from_email')
than in DB there will be a string "NULL"
14 replies
FFilament
Created by Tieme on 2/13/2025 in #❓┊help
Import validation
up
14 replies
FFilament
Created by Tieme on 10/19/2024 in #❓┊help
Import, before action
For now i use the before action on the importAction
->before(function () {
Staffelprijzen::query()->delete();
}),
->before(function () {
Staffelprijzen::query()->delete();
}),
Not as reliable as i want, but does the job.
3 replies
FFilament
Created by Tieme on 8/14/2024 in #❓┊help
Apply ->translateLabel() everywhere
Totaly forgot about configureUsing]
5 replies
FFilament
Created by Tieme on 8/3/2024 in #❓┊help
2 "save" actions on CreateResource with "mutateFormDataBeforeCreate"
Here is the solution. Create a Formfield, hide the label and add hidden as extraAttributes
Forms\Components\ToggleButtons::make('status')
->options(InternalProjectStatus::class)
->label(false)
->dehydrated(true)
->columnSpan('full')
->default(fn () => InternalProjectStatus::LOCKED)
->extraAttributes([
'class' => 'hidden',
]),
Forms\Components\ToggleButtons::make('status')
->options(InternalProjectStatus::class)
->label(false)
->dehydrated(true)
->columnSpan('full')
->default(fn () => InternalProjectStatus::LOCKED)
->extraAttributes([
'class' => 'hidden',
]),
For the action, set submit to null and update the $livewire->data['status'] in action and than create the record. This will set status to Concept in my case.
protected function getCreateConceptFormAction(): Action
{
return Action::make('concept')
->label(Helpers::translate('Save as concept'))
->color(Color::Blue->getColor())
->submit(null)
->action(function ($livewire) {
$livewire->data['status'] = InternalProjectStatus::CONCEPT;
$this->create();
})
->successNotification(
Notifications\Notification::make()
->success()
->title('Order saves as concept'),
)
->keyBindings(['mod+s']);
}
protected function getCreateConceptFormAction(): Action
{
return Action::make('concept')
->label(Helpers::translate('Save as concept'))
->color(Color::Blue->getColor())
->submit(null)
->action(function ($livewire) {
$livewire->data['status'] = InternalProjectStatus::CONCEPT;
$this->create();
})
->successNotification(
Notifications\Notification::make()
->success()
->title('Order saves as concept'),
)
->keyBindings(['mod+s']);
}
If there is another way i would love to see it. Because this works, but dont think this is the best way of doing this.
11 replies
FFilament
Created by Tieme on 8/3/2024 in #❓┊help
2 "save" actions on CreateResource with "mutateFormDataBeforeCreate"
Damn, did not think about that! Thanks, that will do the trick!
11 replies
FFilament
Created by Tieme on 8/3/2024 in #❓┊help
2 "save" actions on CreateResource with "mutateFormDataBeforeCreate"
So i need to duplicate the create function to only change 1 attribute that needs to be changed? Just like below where i added the $data['status'] = InternalProjectStatus::CONCEPT->value; Isent there a better way to do this?
Action::make('createConcept')
->label('Create Concept')
->submit('createConcept')
->keyBindings(['mod+s']);

public function createConcept(bool $another = false): void
{
$this->authorizeAccess();

try {
$this->beginDatabaseTransaction();

$this->callHook('beforeValidate');

$data = $this->form->getState();

$this->callHook('afterValidate');

$data = $this->mutateFormDataBeforeCreate($data);
$data['status'] = InternalProjectStatus::CONCEPT->value;

$this->callHook('beforeCreate');

$this->record = $this->handleRecordCreation($data);

$this->form->model($this->getRecord())->saveRelationships();

$this->callHook('afterCreate');

$this->commitDatabaseTransaction();
} catch (Halt $exception) {
$exception->shouldRollbackDatabaseTransaction() ?
$this->rollBackDatabaseTransaction() :
$this->commitDatabaseTransaction();

return;
} catch (Throwable $exception) {
$this->rollBackDatabaseTransaction();

throw $exception;
}

$this->rememberData();

$this->getCreatedNotification()?->send();

if ($another) {
// Ensure that the form record is anonymized so that relationships aren't loaded.
$this->form->model($this->getRecord()::class);
$this->record = null;

$this->fillForm();

return;
}

$redirectUrl = $this->getRedirectUrl();

$this->redirect($redirectUrl, navigate: FilamentView::hasSpaMode() && is_app_url($redirectUrl));
}
Action::make('createConcept')
->label('Create Concept')
->submit('createConcept')
->keyBindings(['mod+s']);

public function createConcept(bool $another = false): void
{
$this->authorizeAccess();

try {
$this->beginDatabaseTransaction();

$this->callHook('beforeValidate');

$data = $this->form->getState();

$this->callHook('afterValidate');

$data = $this->mutateFormDataBeforeCreate($data);
$data['status'] = InternalProjectStatus::CONCEPT->value;

$this->callHook('beforeCreate');

$this->record = $this->handleRecordCreation($data);

$this->form->model($this->getRecord())->saveRelationships();

$this->callHook('afterCreate');

$this->commitDatabaseTransaction();
} catch (Halt $exception) {
$exception->shouldRollbackDatabaseTransaction() ?
$this->rollBackDatabaseTransaction() :
$this->commitDatabaseTransaction();

return;
} catch (Throwable $exception) {
$this->rollBackDatabaseTransaction();

throw $exception;
}

$this->rememberData();

$this->getCreatedNotification()?->send();

if ($another) {
// Ensure that the form record is anonymized so that relationships aren't loaded.
$this->form->model($this->getRecord()::class);
$this->record = null;

$this->fillForm();

return;
}

$redirectUrl = $this->getRedirectUrl();

$this->redirect($redirectUrl, navigate: FilamentView::hasSpaMode() && is_app_url($redirectUrl));
}
11 replies
FFilament
Created by Tieme on 8/3/2024 in #❓┊help
2 "save" actions on CreateResource with "mutateFormDataBeforeCreate"
I have that implemented, But don't know how to mutate the data for the "getCreateConceptFormAction"
protected function getFormActions(): array
{
return [
$this->getCreateFormAction()
->keyBindings(false)
->requiresConfirmation()
->label(Helpers::translate('Place Order')),
$this->getCreateConceptFormAction(), // Todo :: figure out how to do this.
$this->getCancelFormAction(),
];
}

// Todo : not working...
protected function getCreateConceptFormAction(): Action
{
return Action::make('createConcept')
->label('Create Concept')
->action(function (array $data) {
$data = $this->mutateFormDataBeforeCreate($data);
$data['status'] = InternalProjectStatus::CONCEPT->value;
dd($data);
static::getModel()::create($data);
})
->model(static::getModel())
->form(fn ($livewire) => static::getResource()::form(new Form($livewire)));

// return Action::make('create')
// //->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
// ->label(Helpers::translate('Save as concept'))
// ->color(Color::Blue->getColor())
// ->submit('create')
// ->successNotification(
// Notifications\Notification::make()
// ->success()
// ->title('Order saves as concept'),
// )
// ->keyBindings(['mod+s']);
}
protected function getFormActions(): array
{
return [
$this->getCreateFormAction()
->keyBindings(false)
->requiresConfirmation()
->label(Helpers::translate('Place Order')),
$this->getCreateConceptFormAction(), // Todo :: figure out how to do this.
$this->getCancelFormAction(),
];
}

// Todo : not working...
protected function getCreateConceptFormAction(): Action
{
return Action::make('createConcept')
->label('Create Concept')
->action(function (array $data) {
$data = $this->mutateFormDataBeforeCreate($data);
$data['status'] = InternalProjectStatus::CONCEPT->value;
dd($data);
static::getModel()::create($data);
})
->model(static::getModel())
->form(fn ($livewire) => static::getResource()::form(new Form($livewire)));

// return Action::make('create')
// //->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
// ->label(Helpers::translate('Save as concept'))
// ->color(Color::Blue->getColor())
// ->submit('create')
// ->successNotification(
// Notifications\Notification::make()
// ->success()
// ->title('Order saves as concept'),
// )
// ->keyBindings(['mod+s']);
}
11 replies
FFilament
Created by ddoddsr on 7/2/2024 in #❓┊help
Why is my $record->save(); not working
in your case if you want to update the model you need to do
Action::make('Pause Campaign')
->action(function (?Model $record) {
$record->status_id = CampaignStatusEnum::Paused;
$record->save();
})
Action::make('Pause Campaign')
->action(function (?Model $record) {
$record->status_id = CampaignStatusEnum::Paused;
$record->save();
})
10 replies
FFilament
Created by astronomic on 4/29/2024 in #❓┊help
Doubts with summarize(Count)
No description
21 replies
FFilament
Created by jepewsykes on 5/5/2024 in #❓┊help
custom field appends error when sum using summariz
i think you need a query for that. Summarize does a query to the database, that is why it is not working. https://filamentphp.com/docs/3.x/tables/summaries#scoping-the-dataset ->query(fn (Builder $query) => $query->where('is_published', true))
4 replies
FFilament
Created by astronomic on 4/29/2024 in #❓┊help
Doubts with summarize(Count)
Have you read the docs (https://filamentphp.com/docs/3.x/tables/summaries)?
Tables\Columns\TextColumn::make('type')
->label('Tipo')
->summarize(
Count::make('uno')->label('Nº total de clientes')->query(fn ($query) => $query),
Count::make()->label('Nº total de ayuntamientos')->query(fn ($query) => $query->where('type', 0)),
Count::make()->label('Nº total de NO ayuntamientos')->query(fn ($query) => $query->where('type', 1)),
)
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('type')
->label('Tipo')
->summarize(
Count::make('uno')->label('Nº total de clientes')->query(fn ($query) => $query),
Count::make()->label('Nº total de ayuntamientos')->query(fn ($query) => $query->where('type', 0)),
Count::make()->label('Nº total de NO ayuntamientos')->query(fn ($query) => $query->where('type', 1)),
)
->sortable()
->searchable(),
21 replies
FFilament
Created by KingStalker on 5/2/2024 in #❓┊help
widget doesin't update when i use the filter on a table help please
3 replies
FFilament
Created by Jon Mason on 5/2/2024 in #❓┊help
is it possible to add dividers in a grouped action blade / livewire component?
Yes this it possible. You can checkout all the code of fillament on Github and start looking how it should be done, Below is the code you can find in https://github.com/filamentphp/filament/blob/2f5ac6078d522672a437b56d573a78ecf869a67a/docs-assets/app/resources/views/livewire/actions.blade.php#L106-L114
<x-filament-actions::group
:actions="[
\Filament\Actions\ActionGroup::make([
\Filament\Actions\Action::make('view'),
\Filament\Actions\Action::make('edit'),
])->dropdown(false),
\Filament\Actions\Action::make('delete'),
]"
/>
<x-filament-actions::group
:actions="[
\Filament\Actions\ActionGroup::make([
\Filament\Actions\Action::make('view'),
\Filament\Actions\Action::make('edit'),
])->dropdown(false),
\Filament\Actions\Action::make('delete'),
]"
/>
4 replies
FFilament
Created by Expecto Patronum on 5/3/2024 in #❓┊help
Versionable By Mansoor Khan
3 replies