File: D:/HostingSpaces/stafa/stafa.nl/app/Http/Wildcards/EventsWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Komma\Events\Models\EventTranslation;
class EventsWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the EventTranslation
// If EventTranslation isn't found then send to the filters method
if($eventTranslation = EventTranslation::where('slug', $wildcard->tail[0])->first())
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'events/'.$eventTranslation->event_id);
return $request;
}
// Bind filters to the request and set uri to the filter function of the event controller
$request->merge(['filters' => $wildcard->tail]);
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'events/filters');
return $request;
}
}