File: D:/HostingSpaces/netwerkbrabant/netwerkbrabant.nl/app/Http/Wildcards/NewsArticlesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\KommaApp\Events\Models\EventTranslation;
use App\KommaApp\NewsArticles\Models\NewsArticleTranslation;
use App\KommaApp\Regions\Models\Region;
class NewsArticlesWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the NewsArticleTranslation
// If NewsArticleTranslation isn't found then send to the filters method
if($newsArticleTranslation = NewsArticleTranslation::where('slug', $wildcard->tail[0])->first())
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'newsArticles/'.$newsArticleTranslation->news_article_id);
return $request;
}
if(config('app.env') == 'local'){
var_dump('maybe make a correct pointer for the following tail');
dd($wildcard->tail);
}
return $request;
}
}