2018-02-27 21:28:43 -06:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Http\Requests\Api\Client;
|
2018-02-27 21:28:43 -06:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Contracts\Http\ClientPermissionsRequest;
|
|
|
|
|
use App\Http\Requests\Api\Application\ApplicationApiRequest;
|
2025-09-24 13:34:19 +02:00
|
|
|
use App\Models\Server;
|
2018-02-27 21:28:43 -06:00
|
|
|
|
2020-03-18 21:08:32 -07:00
|
|
|
class ClientApiRequest extends ApplicationApiRequest
|
2018-02-27 21:28:43 -06:00
|
|
|
{
|
|
|
|
|
/**
|
2018-08-22 22:29:20 -07:00
|
|
|
* Determine if the current user is authorized to perform the requested action against the API.
|
2018-02-27 21:28:43 -06:00
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
2018-08-22 22:29:20 -07:00
|
|
|
if ($this instanceof ClientPermissionsRequest || method_exists($this, 'permission')) {
|
2020-03-22 13:56:15 -07:00
|
|
|
$server = $this->route()->parameter('server');
|
|
|
|
|
|
|
|
|
|
if ($server instanceof Server) {
|
|
|
|
|
return $this->user()->can($this->permission(), $server);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-30 16:39:17 -05:00
|
|
|
// If there is no server available on the request, trigger a failure since
|
2020-03-22 13:56:15 -07:00
|
|
|
// we expect there to be one at this point.
|
|
|
|
|
return false;
|
2018-08-22 22:29:20 -07:00
|
|
|
}
|
|
|
|
|
|
2018-02-27 21:28:43 -06:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|