File: D:/HostingSpaces/SBogers10/komma.pro/app/Http/Wildcards/CasesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\KommaApp\Cases\Models\CaseTranslation;
use App\KommaApp\Posts\Models\PostTranslation;
class CasesWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the CaseTranslation
// If CaseTranslation isn't found then send to the filters method
if($caseTranslation = CaseTranslation::where('slug', $wildcard->tail[0])->first())
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'cases/'.$caseTranslation->case_id);
return $request;
}
return $request;
}
}