add location editing

This commit is contained in:
Dane Everitt 2016-01-16 22:57:28 -05:00
parent 21a95a5d0e
commit fb5533f107
4 changed files with 146 additions and 2 deletions

View file

@ -5,7 +5,11 @@ namespace Pterodactyl\Http\Controllers\Admin;
use DB;
use Pterodactyl\Models;
use Pterodactyl\Repositories\LocationRepository;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Exceptions\DisplayValidationException;
use Illuminate\Http\Request;
class LocationsController extends Controller
@ -51,4 +55,25 @@ class LocationsController extends Controller
return response('', 204);
}
public function patchLocation(Request $request, $id)
{
try {
$location = new LocationRepository;
$location->edit($id, $request->all());
return response('', 204);
} catch (DisplayValidationException $ex) {
return response()->json([
'error' => 'There was a validation error while processing this request. Location descriptions must be between 1 and 255 characters, and the location code must be between 1 and 10 characters with no spaces or special characters.'
], 422);
} catch (\Exception $ex) {
// This gets caught and processed into JSON anyways.
throw $ex;
}
}
public function postLocation(Request $request)
{
//
}
}

View file

@ -219,6 +219,12 @@ class AdminRoutes {
$router->delete('/{id}', [
'uses' => 'Admin\LocationsController@deleteLocation'
]);
$router->patch('/{id}', [
'uses' => 'Admin\LocationsController@patchLocation'
]);
$router->post('/', [
'uses' => 'Admin\LocationsController@postLocation'
]);
});
// API Routes