File: D:/HostingSpaces/SBogers10/reiskick.komma.nl/app/Http/Wildcards/JourneysWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Journeys\Models\JourneyTranslation;
use Illuminate\Http\Request;
class JourneysWildcard implements WildcardInterface
{
/**
* @param Request $request
* @param string $route
* @param string $tail
* @return Request
*/
public function handle(Request $request, string $route, string $tail): Request
{
// Check if the first segment is found in the TranslatableModel
$model = JourneyTranslation::where('slug', $tail)
->first();
// If found then send to the show method
if($model)
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'journeys/' . $model->journey_id);
return $request;
}
// // Bind filters to the request and set uri to the filter function of the post controller
// $request->merge(['filters' => $tail]);
//
// //Set the request URI and the original path
// $request->server->set('REQUEST_URI', 'posts/filters');
return $request;
}
}