cheesegrits
cheesegrits
FFilament
Created by hello_world on 4/16/2024 in #❓┊help
Getting Error in Sudden Change in Tab
For anyone stumbling across this, setting is $isLazy fixed an issue for me where I had multiple table widgets on a dashboard, using a filtersForm() on the dashboard and InteractsWithPageFilters on the widgets. Without setting $isLazy false for all table widgets, I was getting intermittent "table must not be accessed before initialization" when changing any of the filters. Setting $islazy to false for all table widgets fixed the problem.
9 replies
FFilament
Created by ShawnVeltman on 1/22/2024 in #❓┊help
Pest Testing Repeater (extra value added in tests)
@ShawnVeltman (and anyone stumbling across this searching for the same issue). I just ran into this, and figured out I can use the ->set('repeater', null) approach (to remove any defaultItems) by using mountTableAction rather than callTableAction ...
livewire(ListAircraft::class)
->mountTableAction(CreateAction::class)
->set('mountedTableActionsData.0.roles', null)
->setTableActionData(data: [
// ...
'roles' => [
[
'personnel_role_id' => PersonnelRole::factory()->create()->id,
'number' => fake()->numberBetween(0, 100),
],
],
])
->callMountedTableAction()
->assertHasNoTableActionErrors();
livewire(ListAircraft::class)
->mountTableAction(CreateAction::class)
->set('mountedTableActionsData.0.roles', null)
->setTableActionData(data: [
// ...
'roles' => [
[
'personnel_role_id' => PersonnelRole::factory()->create()->id,
'number' => fake()->numberBetween(0, 100),
],
],
])
->callMountedTableAction()
->assertHasNoTableActionErrors();
By using mountTableAction() followed by setTableActionsData() and callMountedTableAction(), rather than the atomic callTableAction(), this enables me to slide that set('roles', null) in there before setting the data. This lest me test repeaters with defaultItems, without changing my form schema.
9 replies
FFilament
Created by NolanN on 2/12/2024 in #❓┊help
Extra sessions being created when clicking an action button
@NolanN have you tried it on anything other than Herd?
17 replies
FFilament
Created by NolanN on 2/12/2024 in #❓┊help
Extra sessions being created when clicking an action button
Well, other people are using both together ... we don't necessarily know that they aren't having the same issue, and just haven't noticed the extra sessions. Not a folder anyone ever looks in, typically.
17 replies
FFilament
Created by hxn on 10/14/2023 in #❓┊help
conditional table column
Right, but that's a global thing, you are either showing a column or not, depending on some condition. What OP wanted to do was, in the same column, show different column types depending on some condition. So on some rows show a Curator cell, on other rows show a TextColumn cell, within the same column.
10 replies
FFilament
Created by .Sifat Kazi on 2/12/2024 in #❓┊help
A non-numeric value encountered
Dunno if you are running the same code version, but in my version of Laravel, line 156 is reading the decay time, which I think it derives from your middleware incantation in the route. So make sure you've specified that correctly, like ...
Route::middleware('auth:api', 'throttle:60,1')->group(function () {
//
});
Route::middleware('auth:api', 'throttle:60,1')->group(function () {
//
});
Or better yet, first just disable the throttle middleware entirely, see if the problem goes away. That would at least tell you where to start looking. Also, please don't @ me. 🙂
11 replies
FFilament
Created by Chriis on 11/30/2023 in #❓┊help
forceDeleteAction triggering deleted model event and not forceDeleted
Not at my computer, but iirc both delete and forceDelete events get triggered by Laravel when a model is force deleted, and in a deleting / deleted observer you have to check something like $model->isForceDeleting().
5 replies
FFilament
Created by ebermor on 10/4/2023 in #❓┊help
repeater
Yes, you do need to generate the UUID. Here's an example from one of my apps. I'm not doing it on an action, I'm doing it on an afterStateUpdated() on a Select, where the thing they select dictates how many instances of a Repeater I need. The relevant fragment is ...
// $role->slug is the name of the Repeater
$repeats = $get($role->slug);
// get the number of repeats we need
$number = AircraftHelper::getAircraftRoleCount($aircraft->id, $role->slug);

// if the new number is less than existing, chop off the excess
if ($number < count($repeats)) {
array_splice(
$repeats,
$number,
count($repeats) - $number,
);
}

// add additional repeat instances if new number is greater than existing instances
if ($number > count($repeats)) {
for ($x = count($repeats); $x < $number; $x++) {
$repeats[(string) Str::uuid()] = [
'unstaffed' => false,
'personnel_role_id' => $role->id,
'personnel_id' => null,
'duty_start' => DailyLogHelper::getStandardDutyStart($aircraft->id),
'duty_stop' => DailyLogHelper::getStandardDutyStop($aircraft->id),
];
}
}

$set($role->slug, $repeats);
// $role->slug is the name of the Repeater
$repeats = $get($role->slug);
// get the number of repeats we need
$number = AircraftHelper::getAircraftRoleCount($aircraft->id, $role->slug);

// if the new number is less than existing, chop off the excess
if ($number < count($repeats)) {
array_splice(
$repeats,
$number,
count($repeats) - $number,
);
}

// add additional repeat instances if new number is greater than existing instances
if ($number > count($repeats)) {
for ($x = count($repeats); $x < $number; $x++) {
$repeats[(string) Str::uuid()] = [
'unstaffed' => false,
'personnel_role_id' => $role->id,
'personnel_id' => null,
'duty_start' => DailyLogHelper::getStandardDutyStart($aircraft->id),
'duty_stop' => DailyLogHelper::getStandardDutyStop($aircraft->id),
];
}
}

$set($role->slug, $repeats);
Note that I'm not prepending the UUID with record-. I'm pretty sure Filament only expects that prefix for existing data, where it's record-<key>. A new instance would just be a UUID. And yes, I'm individually setting up each field in the repeat.
14 replies
FFilament
Created by H.Bilbao on 10/27/2023 in #❓┊help
Get hiddenOn field value when mutate
I may be wrong. Doing some testing.
5 replies
FFilament
Created by myster on 10/28/2023 in #❓┊help
NavigationGroup
I don't think so, unless Dan snuck a feature in when I wasn't looking. Might be a neat thing to PR tho.
7 replies
FFilament
Created by H.Bilbao on 10/27/2023 in #❓┊help
Get hiddenOn field value when mutate
Afaik you can't. Once hidden, it doesn't exist in the form state.
5 replies
FFilament
Created by Jean Roumeau on 10/20/2023 in #❓┊help
Adding BelongsToMany that includes another BelongsToMany relation to a form
Your terminology is very inconsistent. You have referred to users, business areas, client areas, clinics and clients. Can you describe what you are trying to achieve using consistent terminology, which matches your models. And describe the UI you are trying to achieve. Like by "select the business areas" do you mean literally a multi select field?
16 replies
FFilament
Created by Javier Mercedes on 10/27/2023 in #❓┊help
Get the latest record from a relation in a TextColumn
Show your code, there may be a better way of doing it
9 replies
FFilament
Created by Xiquita on 10/27/2023 in #❓┊help
tiptapeditor inside infolist
Best to ask plugin specific question in the dedicated channel for that plugin. Which I think would be #tiptap
19 replies
FFilament
Created by Becker Maxime on 10/27/2023 in #❓┊help
Update repeater
Just @ me if you need more help. This stuff can be confusing.
25 replies
FFilament
Created by Becker Maxime on 10/27/2023 in #❓┊help
Update repeater
N/p
25 replies
FFilament
Created by Becker Maxime on 10/27/2023 in #❓┊help
Update repeater
Your BelongsToMany relationships should still work, as they only care about the two foreign keys.
25 replies
FFilament
Created by Becker Maxime on 10/27/2023 in #❓┊help
Update repeater
The takeaway here is that when you need to create a model for the pivot and work directly on it, rather than simply using a pivot as part of relationships and only working on the models either "side" of the pivot, then you need a singular primary key. This is a limitation of Laravel.
25 replies
FFilament
Created by Becker Maxime on 10/27/2023 in #❓┊help
Update repeater
Usually a pivot table doesn't need a singular primary key like 'id', it uses a composite key, like you did. Because usually you aren't directly working on the pivot table itself, you are working with the target table on the other "side" of the pivot, with BelongsToMany relationships. But when you need to work on the actual pivot itself, where you create a model for the pivot, you do need a singular primary key. Laravel (and hence Filament) doesn't natively support composite keys for models. So the migration would need to look more like this:
public function up(): void
{
Schema::create('artist_lead', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('lead_id');
$table->foreign('lead_id')->references('id')->on('leads')->onDelete('cascade');
$table->unsignedBigInteger('artist_id');
$table->foreign('artist_id')->references('id')->on('artists')->onDelete('cascade');
$table->boolean('accept')->default(0);
$table->boolean('refuse')->default(0);
$table->unique(['lead_id', 'artist_id']);
$table->timestamps();
});
}
public function up(): void
{
Schema::create('artist_lead', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('lead_id');
$table->foreign('lead_id')->references('id')->on('leads')->onDelete('cascade');
$table->unsignedBigInteger('artist_id');
$table->foreign('artist_id')->references('id')->on('artists')->onDelete('cascade');
$table->boolean('accept')->default(0);
$table->boolean('refuse')->default(0);
$table->unique(['lead_id', 'artist_id']);
$table->timestamps();
});
}
The unique() isn't really needed, but you can include it if you want to enforce referential integrity.
25 replies
FFilament
Created by Becker Maxime on 10/27/2023 in #❓┊help
Update repeater
Does your artist_lead table have a primary key, like 'id'? The code you quoted won't show that. Maybe paste the migration.
25 replies