Add nests & eggs
Cleanup middleware handling and parameters on controllers...
This commit is contained in:
parent
de07b3cc7f
commit
8afced3410
26 changed files with 737 additions and 446 deletions
|
@ -3,9 +3,11 @@
|
|||
namespace Pterodactyl\Http\Requests\Api\Application;
|
||||
|
||||
use Pterodactyl\Models\ApiKey;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Pterodactyl\Exceptions\PterodactylException;
|
||||
use Pterodactyl\Http\Middleware\Api\ApiSubstituteBindings;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
abstract class ApplicationApiRequest extends FormRequest
|
||||
|
@ -73,6 +75,25 @@ abstract class ApplicationApiRequest extends FormRequest
|
|||
return $this->attributes->get('api_key');
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab a model from the route parameters. If no model exists under
|
||||
* the specified key a default response is returned.
|
||||
*
|
||||
* @param string $model
|
||||
* @param mixed $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function getModel(string $model, $default = null)
|
||||
{
|
||||
$parameterKey = array_get(array_flip(ApiSubstituteBindings::getMappings()), $model);
|
||||
|
||||
if (! is_null($parameterKey)) {
|
||||
$model = $this->route()->parameter($parameterKey);
|
||||
}
|
||||
|
||||
return $model ?? $default;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine if the request passes the authorization check as well
|
||||
* as the exists check.
|
||||
|
|
Reference in a new issue