File: D:/HostingSpaces/stafa/stafa.nl/app/Http/Wildcards/AssortmentWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Komma\Assortments\Models\AssortmentTranslation;
class AssortmentWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the AssortmentTranslation
// If AssortmentTranslation isn't found then send to the filters method
if($assortmentTranslation = AssortmentTranslation::where('slug', $wildcard->tail[0])->first())
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'assortment/'.$assortmentTranslation->assortment_id);
return $request;
}
return $request;
}
}