spatie/laravel-missing-page-redirector

A few fast questions

rawzone opened this issue · 6 comments

Trying to wrap my brain around a setup with this package in a new project.

Question 1. Would i be possible to setup a redirect like this:
'/event/{slug}' => '/events/[event-year]/{slug}'

Where I would need to get the [event-year] from a database model? So like check for an event with the given slug - Grap the first one (Or event better grap all and show index page with filtered results)?

Question 2. Is there away to trigger an Laravel event when a route is hit - So in time the redirects could be removed?

Question 3. Is there any way to setup this redirect (Will use old url / new url):
'/merchandise/clothing/#!retrofoot-A111792131' => '/merchandise/retrofoot-A111792131'

Soo needs to remove the "hash" thingy in the URL (The old url was a ajax embedded thingy - The new url is a database model's show template).

Thanks in advance!

  1. Yes, but you'll probably have to write a custom redirector. Here's an example implementation: https://github.com/spatie/blender/blob/351d925543c47e22a6533fff5e70d7a3584c2d10/app/Services/MissingPageRedirector/DatabaseRedirector.php

  2. Not at the moment, but I think we'd accept a PR that adds an event here (cc @freekmurze)

  3. Nope, because hashes are only available to browsers (see https://stackoverflow.com/questions/3664257/why-the-hash-part-of-the-url-is-not-in-the-server-side)

Hope this helps!

That was an epic response! Thanks. Have a great weekend.

Not at the moment, but I think we'd accept a PR that adds an event here

Yup, we'd accept a PR with tests that adds this event to the package.

Hello there,

I've attempted to add a "Route was hit" event in #23. I hope this helps.

The RouteWasHit event is added in v1.3.0.

Wow... That was pretty fast... Well done guys!