File: D:/HostingSpaces/SBogers10/reiskick.komma.nl/app/Http/Wildcards/ArticlesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Articles\Models\ArticleTranslation;
use App\Overnights\Models\OvernightTranslation;
use Illuminate\Http\Request;
class ArticlesWildcard 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 = ArticleTranslation::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', 'articles/' . $model->article_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;
}
}