File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Http/Wildcards/CustomerStoriesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Komma\CustomerStories\Models\CustomerStory;
class CustomerStoriesWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the CustomerStories
if (count($wildcard->tail) == 1 && $customerStory = CustomerStory::where('slug', $wildcard->tail[0])->first()) {
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'customerStories/'.$customerStory->id);
return $request;
}
return $request;
}
}