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