Saturday, March 4, 2017

eloquent-sluggable uniqueness test by relationship id

I try to use cviebrock/eloquent-sluggable in Laravel (5.4). I have a Page model and a website model. It's using sluggable in the Page model. Now, if i create a page i want tot check for uniqueness by the columns website_id and slug before generating a slug (with -1 or -2 after the title for example). It looks like i should use the method "customizeSlugEngine", but it isn't called when i add it to the Page model.

When it's working i need to find page by slug and page id. In my pageController (front-end) i use:

Page::findBySlug($slug);

How can i find pages by slug and webiste_id?



via Tom

Advertisement