TIPOFF / locations

Laravel Package for locations in markets
MIT License
0 stars 1 forks source link

Proposed Page Extension for Market & Location #85 #95

Closed drewroberts closed 3 years ago

drewroberts commented 3 years ago

This PR allows both Market (#41) & Location (#42) to become extensions of the Page (https://github.com/drewroberts/blog/issues/15) model in drewroberts/blog and therefore simplifies the issues with routing we are running into with the following PR:

https://github.com/drewroberts/blog/pull/59

Here is the proposal for the overall routing structure that will be used for all Tipoff applications:

https://github.com/drewroberts/blog/issues/50

{page}/{child-page}/{grandchild-page}

In that example, Market will become the {page} and Location will become the {child-page} and therefore all Locations in the saving boot method must verify that the Page associated with the Market that the location belongs to is also the parent_id on the Page associated with the Location.

pdbreen commented 3 years ago

@drewroberts - this can work, but doesn't solve the issue with a package trying to register a route with 3 wildcard segments and no fixed segment to match on. Additional things this change will require:

Since you seem determined to support paths with absolutely no fixed segment to match upon, I think you only have 2 options

If you go with the second solution, the blog package (which is registering the routes) needs to make sure that any new/deleted/changed page model slug will properly deal with route caching. This means -- figure out if routes are cached or not (either by disk inspection or config) and if they are, update the cache with the artisan command. This needs to happen on ALL servers - not just the server that happened to process the page model change. You also need to make sure permissions allow for the route:cache command to update the cache.

drewroberts commented 3 years ago

Thank you, @pdbreen. Those are great points. Let's discuss this one first:

Should creation of a market or location automatically create a corresponding page model based on market/location slug? Should an error occur if a page already exists with the slug, or should the slug be modified to be unique?

I like the concept of having it automatically create the page when you create a Market or Location. I'll add the slug back onto both resources and we'll need to lock pages that have a Market or Location relationship so that the Slug can only be updated on the resource in this package and upon saving, it will automatically update the Page slug.

Let's do both approaches in regards to the slug conflicts. Let's display an error in Nova if the slug already exists on another Page resource. For testing purposes with factories, it would be easiest to just create the function on the model that modifies it to be unique.

pdbreen commented 3 years ago

@wolfrednicolas - here a debugging tip you can use. Within any unit test, you can temporarily add $this->logToStderr()->logSql(); at the start of the test to see the SQL being run by the commands that come later. Just make sure to remove these lines prior to official commit.

pdbreen commented 3 years ago

@drewroberts - this is ready, but requires new version of drewroberts/blog before merge