File: D:/HostingSpaces/SBogers10/netwerkbrabant.komma.pro/app/Http/Wildcards/CompaniesWildcard.php
<?php
namespace App\Http\Wildcards;
use App\KommaApp\Companies\Models\Company;
class CompaniesWildcard implements WildcardInterface
{
/**
* @param $request
* @param $wildcard
* @return mixed
*/
public function handle($request, $wildcard)
{
// Check if the first segment is found in the Company
// If Company isn't found then send to the filters method
if($company = Company::where('slug', $wildcard->tail[0])->first())
{
//Set the request URI and the original path
$request->server->set('REQUEST_URI', 'companies/'.$company->id);
return $request;
}
if(config('app.env') == 'local'){
var_dump('maybe make a correct pointer for the following tail');
dd($wildcard->tail);
}
return $request;
}
}