File: D:/HostingSpaces/SBogers10/bomacon.komma.pro/app/Http/Wildcards/VacanciesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\Vacancies\Models\Vacancy;
use App\Vacancies\Models\VacancyTranslation;
use Illuminate\Http\Request;
class VacanciesWildcard implements WildcardInterface
{
/**
* @param Request $request
* @param string $route
* @param string $tail
* @return Request
*/
public function handle(Request $request, string $route, string $tail): Request
{
// Check if the first segment is found in the ProjectTranslation
// If ProjectTranslation isn't found then send to the filters method
if($VacancyTranslation = VacancyTranslation::where('slug', $tail)->first())
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'vacancies/'.$VacancyTranslation->vacancy_id);
return $request;
}
// Bind filters to the request and set uri to the filter function of the project controller
$request->merge(['filters' => $tail]);
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'vacancies/filters');
return $request;
}
}