2017-10-28 02:42:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Server;
|
|
|
|
|
2018-03-02 03:27:37 +00:00
|
|
|
use Pterodactyl\Models\Server;
|
2017-10-28 02:42:53 +00:00
|
|
|
use Pterodactyl\Http\Requests\FrontendUserFormRequest;
|
|
|
|
|
|
|
|
abstract class ServerFormRequest extends FrontendUserFormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Return the user permission to validate this request aganist.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract protected function permission(): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if a user has permission to access this resource.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
if (! parent::authorize()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-02 03:27:37 +00:00
|
|
|
return $this->user()->can($this->permission(), $this->getServer());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getServer(): Server
|
|
|
|
{
|
|
|
|
return $this->attributes->get('server');
|
2017-10-28 02:42:53 +00:00
|
|
|
}
|
|
|
|
}
|