Closed saade closed 7 months ago
hi @saade, ✌
I've been testing this branch, and was getting the error:
Undefined array key "name"
and this is my $getState()
looks like:
after long debugging, I found that you do:
$record->only([$record->getKeyName(), ...$record->getFillable()]);
in HasRelationships.php
and my models don't have 'fillable' on it.
not sure but I think it's common to do $guarded = []
from what I've seen :), personally, I disable it from the serviceProvifer on all models.
is it possible maybe use $record->toArray()' or maybe add new property:
$treeFillable = []`.
Hey @atmonshi,
Are you still using this branch? Could you test to see if it works for you now? If yes, relationship support is ready =)
Thank you @saade for amazing work
I am getting weird thing, not sure if its related to my setup or not
Menus Model:
public function items()
{
return $this->hasMany(MenusItems::class, 'menu_id', 'id')->orderBy('ordering');
}
MenusItems Model:
public function children()
{
return $this->hasMany(MenusItems::class, 'menu_id', 'id')->orderBy('ordering');
}
MenuResource Form:
AdjacencyList::make('items')
->relationship('items')
->labelKey('created_by')
->childrenKey('children')
->form([
TextInput::make('app_code')->required(),
]),
but I got duplicated items one for the actual row, and one for its children's even if it doesn't have any.
Yeah, noticed that today,
TBH, I'm willing to keep this package json-only and wait for someone (maybe @cheesegrits) to work on the relationship feature (since my implementation will probably not work for graphs too).
I'm literally exhausted trying to make this work, (not only the relationship, but working with filament actions to make the correct parameter resolving inside the modal). Maybe i'm biased towards some business logic that i can't think of another way to make this work as expected. I've already rewritten the relationship support like 5 times, and always got stuck at some problem.
Sorry to disappoint you guys. (Glad i didnt made this a paid package)
Don't worry about it :) I wanted to make sure I had the correct setup. But now I'll try to take a shot at this and see if I can do something in the next few days.
thank you again.
waiting on https://github.com/staudenmeir/laravel-adjacency-list/issues/186 to support nested relationships.