Mark Chaney
Mark Chaney
FFilament
Created by Mark Chaney on 6/24/2024 in #❓┊help
Inline Radio - Single Column?
No description
2 replies
FFilament
Created by Mark Chaney on 6/8/2024 in #❓┊help
updatedTableFilters() no longer firing
Since upgrading to livewire 3/filament 3, ive noticed that
public function updatedTableFilters(): void
{
dd($this->tableFilters);
}
public function updatedTableFilters(): void
{
dd($this->tableFilters);
}
no longer fires when a filter is removed. It does run when one is added. Any suggestions?
2 replies
FFilament
Created by Mark Chaney on 6/4/2024 in #❓┊help
Database Notifications on Vapor
No description
3 replies
FFilament
Created by Mark Chaney on 5/3/2024 in #❓┊help
Custom ValidationMessages for minDate/maxDate
I have tried the following, but the html5 validation still shows the default browser error. Do i need to about it differently?
DatePicker::configureUsing(function (DatePicker $datePicker) {
return $datePicker->minDate(Carbon::createFromDate(1500, 1, 1))
->maxDate(now()->addYears(9))
->validationMessages([
'after_or_equal' => 'The :attribute must be after January 1, 1500.',
'before_or_equal' => 'The :attribute cannot be more than 9 years in the future.',
]);
});
DatePicker::configureUsing(function (DatePicker $datePicker) {
return $datePicker->minDate(Carbon::createFromDate(1500, 1, 1))
->maxDate(now()->addYears(9))
->validationMessages([
'after_or_equal' => 'The :attribute must be after January 1, 1500.',
'before_or_equal' => 'The :attribute cannot be more than 9 years in the future.',
]);
});
4 replies
FFilament
Created by Mark Chaney on 4/19/2024 in #❓┊help
Testing and requiresConfirmation
I have a RM with a table row action, that row action launches a modal with an approval action. I can get all the way up that point and it works fine in my test and will perform the approveAction, but if i add a confirmation to the approveAction, I cant seem to figure how to click the "Confirm" on the requiresConfirmation modal as it doesnt appear to have a mountAction for me to be able to call. This is wher i am so far:
Livewire::test(RftaResource\RelationManagers\ComparableUnitsRelationManager::class, [
'pageClass' => RftaResource\Pages\ViewRfta::class,
'ownerRecord' => $rfta,
])
->assertCanSeeTableRecords(collect([$comparable]))
->mountTableAction(ViewAction::class, record: $comparable->id)
->assertSee('Review Comparable Unit')
->assertSee('approveAction')
->mountTableAction('approveAction')
->callMountedTableAction() // requires confirmation
// now how do I click confirm on the requiresConfirmation() modal?
->assertHasNoTableActionErrors();
Livewire::test(RftaResource\RelationManagers\ComparableUnitsRelationManager::class, [
'pageClass' => RftaResource\Pages\ViewRfta::class,
'ownerRecord' => $rfta,
])
->assertCanSeeTableRecords(collect([$comparable]))
->mountTableAction(ViewAction::class, record: $comparable->id)
->assertSee('Review Comparable Unit')
->assertSee('approveAction')
->mountTableAction('approveAction')
->callMountedTableAction() // requires confirmation
// now how do I click confirm on the requiresConfirmation() modal?
->assertHasNoTableActionErrors();
21 replies
FFilament
Created by Mark Chaney on 4/9/2024 in #❓┊help
SpatieMediaLibraryFileUpload Save on Upload
Any suggestions for saving a file on upload? Easy to do with on a regular field by doing something like
->afterStateUpdated(function ($state) use ($tenancy) {
$tenancy->update([
'foo' => $state,
]);
}),
->afterStateUpdated(function ($state) use ($tenancy) {
$tenancy->update([
'foo' => $state,
]);
}),
but not sure what magic is needed for an upload field
2 replies
FFilament
Created by Mark Chaney on 4/8/2024 in #❓┊help
DatePicker First of the Month only
For the datepicker field, anyone tried limit the selection to only the first day of any month?
11 replies
FFilament
Created by Mark Chaney on 4/2/2024 in #❓┊help
$getAction() and visibility
When using ->registerActions() on a Form or Infolist component, it seems that visible() and hidden() no longer apply when you use
{{ $getAction('setMaximum') }}
{{ $getAction('setMaximum') }}
to place the action. That causes a log of headaches. No way for that to be respected?
6 replies
FFilament
Created by Mark Chaney on 4/2/2024 in #❓┊help
Still no way to hook into a modalCancelAction, right?
As in do something after a requiresConfirmation() modal is canceled (either by clicking the x or the close button), right? We already disabled clicking away, so thats not a concern. Basically if a user clicks the action and decides not to submit or hits the X in the corner of a modal, I need to do something. Last fall this wasnt possible from what I am reading.
3 replies
FFilament
Created by Mark Chaney on 3/28/2024 in #❓┊help
Hide Column From Export
I dont see an option to hide a column from an export conditionally? Am i missing something?
5 replies
FFilament
Created by Mark Chaney on 3/26/2024 in #❓┊help
CreateAnother Retain Some Data
With the panel builder, CreateAction, how can i retain data when a user clicks the create another button? Ive seen quite a few different ways to go about it, but none of them seemed that clean or native. Right now I am not even doing a custom action() and hoping i dont have to redo that whole process.
7 replies
FFilament
Created by Mark Chaney on 3/19/2024 in #❓┊help
ViewRecord Listener Method Launch Action
I have 5 header actions that are listed in cachedActions and mountedActions is listed as empty. I can then do a $this->mountAction('action_name')? Ive even extracted the action to a public method with the name of whateverAction() that returns the Action with the same name and its never called as well. Im thinking its either because i am using a listener method to launch it or something to do with cached actions. I am obviously missing something simple as usual.
4 replies
FFilament
Created by Mark Chaney on 3/13/2024 in #❓┊help
Call to a member function isRelation() on null
I have the following createOptionAction where that I am getting that isRelation() on null error
->createOptionAction(function ($action, Get $get) {
// hide the button to create a unit if this is a property that can't have multiple units
$property = Property::find($get('property_id'));
if ($property) {
if (! $property->canHaveMultipleUnits()) {
return $action->hidden();
}

return $action
//->record(fn ($livewire) => $livewire->model)
->fillForm([
'property_id' => $property->id,
])
->slideOver()
->modalWidth('7xl')
->modalHeading('Create Unit');
}

return $action->hidden();
})
->createOptionAction(function ($action, Get $get) {
// hide the button to create a unit if this is a property that can't have multiple units
$property = Property::find($get('property_id'));
if ($property) {
if (! $property->canHaveMultipleUnits()) {
return $action->hidden();
}

return $action
//->record(fn ($livewire) => $livewire->model)
->fillForm([
'property_id' => $property->id,
])
->slideOver()
->modalWidth('7xl')
->modalHeading('Create Unit');
}

return $action->hidden();
})
. ->record() isnt available on this form action though, so i cant use it, which appears to be the solution for the issue. The problem is that in this form, I am trying to use a select with a relationship(), which throws that error. Recommendations?
2 replies
FFilament
Created by Mark Chaney on 3/10/2024 in #❓┊help
Modal not closing after action
Ive tried closing in both the action() and after() with no luck. Its properly making the change, just got closing after. I know i must be missing something simple.
->modalFooterActions(fn ($action) => [
Tables\Actions\Action::make('reject')
->requiresConfirmation()
->action(function (ComparableUnit $record, $action) {
$record->rftas()->updateExistingPivot($this->getOwnerRecord()->id, ['status' => ComparableUnitRftaStatus::Rejected]);
return $action->cancel();
}),
$action->getModalCancelAction(),
]),
->modalFooterActions(fn ($action) => [
Tables\Actions\Action::make('reject')
->requiresConfirmation()
->action(function (ComparableUnit $record, $action) {
$record->rftas()->updateExistingPivot($this->getOwnerRecord()->id, ['status' => ComparableUnitRftaStatus::Rejected]);
return $action->cancel();
}),
$action->getModalCancelAction(),
]),
5 replies
FFilament
Created by Mark Chaney on 3/10/2024 in #❓┊help
Sorting tables by dynamic columns
I know we cant sort or search by attributes, but with certain fields that need to be calculated on the fly (lets say a match score that is relative to the ownerRecord() on an RM), how should we go about sorting such columns? Most of the time I simply dont sort an attribute column like so, but in this particular case, its integral to be able to do so.
2 replies
FFilament
Created by Mark Chaney on 3/9/2024 in #❓┊help
Custom Filter Default
Im using an enum for this filter. The options are working great and filtering correctly, but I cant seem to set a default.
Tables\Filters\Filter::make('property_type')
->default(function () use ($rfta) {
return [
$rfta->property->type->value,
];
})
->form([
Forms\Components\Section::make('Property Type')
->schema([
Forms\Components\Select::make('type')
->hiddenLabel()
->multiple()
->placeholder('All Property Types')
->options(PropertyType::class),
]),
])
->query(function ($query, $data) {
return $query->when($data['type'], function ($query, $value) {
return $query->whereHas('property', function ($query) use ($value) {
$query->whereIn('type', $value);
});
});
}),
Tables\Filters\Filter::make('property_type')
->default(function () use ($rfta) {
return [
$rfta->property->type->value,
];
})
->form([
Forms\Components\Section::make('Property Type')
->schema([
Forms\Components\Select::make('type')
->hiddenLabel()
->multiple()
->placeholder('All Property Types')
->options(PropertyType::class),
]),
])
->query(function ($query, $data) {
return $query->when($data['type'], function ($query, $value) {
return $query->whereHas('property', function ($query) use ($value) {
$query->whereIn('type', $value);
});
});
}),
Any advice?
9 replies
FFilament
Created by Mark Chaney on 3/5/2024 in #❓┊help
userMenuItems Action?
I want to add an Action to the user menu in the panel builder so that it launches a modal. Seems like MenuItem is just for urls(). Any suggestions? Also, while were on it, can we also adjust the positioning of the theme-switcher. Seem to be in the middle of the user menu items.
6 replies
FFilament
Created by Mark Chaney on 2/28/2024 in #❓┊help
Phone Attribute and sendPasswordReset notification voodoo
I have this on my user model, this is super weird. In all cases, the user is created just fine, but if i try modify the phone number, the password reset email fails to send. As mentioned, in all cases, the user is created fine.
protected function phone(): Attribute
{
return Attribute::make(
get: function ($value) {
// Format the phone number as '555-555-5555' if the value is set
return $value ? substr($value, 0, 3) . '-' . substr($value, 3, 3) . '-' . substr($value, 6) : null;
},
set: function ($value) {
if (blank($value)) {
return;
}

ray($value); // Debugging line: 555-555-5555
// Remove any non-numeric characters
// $value = preg_replace('/[^0-9]/', '', $value); // Fails to send password reset email
// $value = '5555555555'; // Fails to send password reset email
$value = '555-555-5555'; // Works to send password reset email

// Remove leading 1 if it's an 11-digit number
if (strlen($value) === 11 && Str::startsWith($value, '1')) {
$value = Str::substr($value, 1);
}

return $value;
}
);
}
protected function phone(): Attribute
{
return Attribute::make(
get: function ($value) {
// Format the phone number as '555-555-5555' if the value is set
return $value ? substr($value, 0, 3) . '-' . substr($value, 3, 3) . '-' . substr($value, 6) : null;
},
set: function ($value) {
if (blank($value)) {
return;
}

ray($value); // Debugging line: 555-555-5555
// Remove any non-numeric characters
// $value = preg_replace('/[^0-9]/', '', $value); // Fails to send password reset email
// $value = '5555555555'; // Fails to send password reset email
$value = '555-555-5555'; // Works to send password reset email

// Remove leading 1 if it's an 11-digit number
if (strlen($value) === 11 && Str::startsWith($value, '1')) {
$value = Str::substr($value, 1);
}

return $value;
}
);
}
15 replies
FFilament
Created by Mark Chaney on 2/20/2024 in #❓┊help
ImportColumn, relationship(), and lifecycle hooks
When using ->relationship() on an ImportColumn, at what point is relationship resolved? it it accessible in beforeSave()? Trying to add some additional validation and would love to avoid querying that relationship again if needed. Haven't had any luck yet figuring it out though.
2 replies
FFilament
Created by Mark Chaney on 2/8/2024 in #❓┊help
Avatar Border
Without having to create a custom avatar, is there a way to dynamically set a border color or background color for the avatar? I want to change it a bit when in a particular mode.
4 replies