You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was thinking if it would make sense to introduce model nesting a bit differently.
As far as I understand it is possible to mimic the default Laravel behavior like assigning one model as the unique parent e.g. /jobs/frontend-web-developer.
How would I go about a scenario where a model can be parent to multiple other models and vice versa?
I would like to nest a page model something like this:
-Page 1 {page-1}
--Page 2 {page-1/page-2}
----Page A {page-1/page-2/page-a}
--Page 3 {page-1/page-3}
-Category A {category-a}
--Page 4 {category-a/page-4}
----Page 5 {category-5/page-4/page-5}
--Page 6 {category-a/page-6}
-Page 7 {page-7}
--Category A {page-7/category-a}
One issue is the restriction that parent_for must be unique. I was thinking with a pivot table using parent id, child id and entity type this could be solved?
Having the model id, entity type and all it's children the slugs still could be recursively updated I think.
Any thoughts on that or a better way to achieve that sort of nesting?
*Something else: what is the reason you check $permalink->getOriginal('slug') !== $permalink->slug?
/**
* Updating event.
*
* @param $model
*/
public function updating($permalink)
{
if ($permalink->getOriginal('slug') !== $permalink->slug) {
$this->ensureSlugIsUnique($permalink);
config('permalink.rebuild_children_on_update')
? $this->path->recursive($permalink)
: $this->path->single($permalink);
}
}
The text was updated successfully, but these errors were encountered:
Hi,
I was thinking if it would make sense to introduce model nesting a bit differently.
As far as I understand it is possible to mimic the default Laravel behavior like assigning one model as the unique parent e.g.
/jobs/frontend-web-developer
.How would I go about a scenario where a model can be parent to multiple other models and vice versa?
I would like to nest a page model something like this:
One issue is the restriction that
parent_for
must be unique. I was thinking with a pivot table using parent id, child id and entity type this could be solved?Having the model id, entity type and all it's children the slugs still could be recursively updated I think.
Any thoughts on that or a better way to achieve that sort of nesting?
*Something else: what is the reason you check
$permalink->getOriginal('slug') !== $permalink->slug
?The text was updated successfully, but these errors were encountered: