mrleblanc101
mrleblanc101
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
@awcodes I think i got it be removing the beforeStateDehydrated. I have no idea what purpose it served, I can't even find documentation about this function in the doc. I guess 3.2.84 fixed a bug where the beforeStateDehydrated was not called, but we didn't need it in the first place ? 🤷‍♂️ Thanks for your help !
protected function setUp(): void
{
parent::setUp();

$this->afterStateHydrated(static function ($record, PracticeMatrix $component, $state) {
if ($record) {
$practiceData = self::getPracticeData($record->id);
$component->practicesData($practiceData);
$component->state($practiceData);
}
});
// $this->beforeStateDehydrated(static function ($record, PracticeMatrix $component, $state) {
// if ($record) {
// $practiceData = self::getPracticeData($record->id);
// $component->practicesData($practiceData);
// $component->state($practiceData);
// }
// });
}
protected function setUp(): void
{
parent::setUp();

$this->afterStateHydrated(static function ($record, PracticeMatrix $component, $state) {
if ($record) {
$practiceData = self::getPracticeData($record->id);
$component->practicesData($practiceData);
$component->state($practiceData);
}
});
// $this->beforeStateDehydrated(static function ($record, PracticeMatrix $component, $state) {
// if ($record) {
// $practiceData = self::getPracticeData($record->id);
// $component->practicesData($practiceData);
// $component->state($practiceData);
// }
// });
}
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
We are coming from Laravel Nova where this wasn't possible.
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
I think the goal was being able to edit all the row of the relationship (and the 2 pivot fields) directly, but maybe that possible natively ?
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Since I couldn't find where the save was happening
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Honestly I thought everything was handled by Filament directly
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Yeah I'll put some dd() and check what is happening
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Might be a good place to debug next
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
There is that:
protected function beforeSave()
{
$hook = App::make(HookProduct::class);
$hook->onProductSave($this->data['id']);
$product = Product::find($this->data['id']);
$practiceToSave = [];
foreach ($this->data['practice_matrix'] as $practice) {
$practiceToSave[$practice['id']] = [
'state' => $practice['state'] ?: 'no',
'notes' => $practice['notes'],
'practice_id' => $practice['id'],
'product_id' => $this->data['id'],
];
}
$product->practices()->sync($practiceToSave);
}
protected function beforeSave()
{
$hook = App::make(HookProduct::class);
$hook->onProductSave($this->data['id']);
$product = Product::find($this->data['id']);
$practiceToSave = [];
foreach ($this->data['practice_matrix'] as $practice) {
$practiceToSave[$practice['id']] = [
'state' => $practice['state'] ?: 'no',
'notes' => $practice['notes'],
'practice_id' => $practice['id'],
'product_id' => $this->data['id'],
];
}
$product->practices()->sync($practiceToSave);
}
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Oh god, I didn't even know about those file lol. I'm sorry as I said I'm not the one that made that code, only trying to debug why the update broke it
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
I don't think so. Do you mean in the Filament resource ? No
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
I don't know what you mean. I'm pretty new to Filament
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
On the Product resource I have this:
protected $fillable = [
'name',
'slug',
'notes',
'team_id',
'client_id',
'state',
'leads'
];

...

public function practices(): BelongsToMany
{
return $this->belongsToMany(Practice::class, 'product_practice')
->withPivot('notes', 'state');
}

...
protected $fillable = [
'name',
'slug',
'notes',
'team_id',
'client_id',
'state',
'leads'
];

...

public function practices(): BelongsToMany
{
return $this->belongsToMany(Practice::class, 'product_practice')
->withPivot('notes', 'state');
}

...
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
I'll try to provide more data once I get home, this is on a private Gitlab instance so I can't share easily
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
I think the state is ok, because everything is fine if I edit in phpMyAdmin. Just the save that doesn't work anymore
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
I think must be related to the pivot
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
If I add line 228 back by editing the source in vendor, it works again
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
The field is hidden on create, I'd have to try but I'm out and I don't have my laptop with me (just my phone)
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
That's because of the change I showed in the screenshot above, there has been to other change to that file since patch 84
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Yes I did try, it doesn't work either.
40 replies
FFilament
Created by mrleblanc101 on 8/16/2024 in #❓┊help
Updating from 3.2.83 to 3.2.84 break custom component
Anyone has an idea ?
40 replies