Update logic that handles creation of folders for a server

This commit is contained in:
Dane Everitt 2019-05-01 21:45:39 -07:00
parent ec87330a81
commit 95d19bf09e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
13 changed files with 116 additions and 9 deletions

View file

@ -26,8 +26,13 @@ class SubstituteClientApiBindings extends ApiSubstituteBindings
// column rather than the default 'id'.
$this->router->bind('server', function ($value) use ($request) {
try {
$column = 'uuidShort';
if (preg_match('/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i', $value)) {
$column = 'uuid';
}
return Container::getInstance()->make(ServerRepositoryInterface::class)->findFirstWhere([
['uuidShort', '=', $value],
[$column, '=', $value],
]);
} catch (RecordNotFoundException $ex) {
$request->attributes->set('is_missing_model', true);