File: D:/HostingSpaces/SBogers95/rentman.io/app/Http/Wildcards/UpdatesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Komma\Updates\Models\UpdateTranslation;
class UpdatesWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the UpdateTranslation
// If UpdateTranslation isn't found then send to the filters method
if (count($wildcard->tail) == 1 && $updateTranslation = UpdateTranslation::where('slug', $wildcard->tail[0])->first()) {
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'updates/'.$updateTranslation->update_id);
return $request;
}
if (count($wildcard->tail) == 2 && is_numeric($wildcard->tail[1])) {
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'updates/categories/'.$wildcard->tail[1]);
return $request;
}
// // Bind filters to the request and set uri to the filter function of the post controller
// $request->merge(['filters' => $wildcard->tail]);
//
// //Set the request URI and the original path
// $request->server->set('REQUEST_URI', 'posts/filters');
return $request;
}
}