38 lines
872 B
PHP
38 lines
872 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Admin\Backups;
|
||
|
|
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Request for downloading a backup.
|
||
|
|
*/
|
||
|
|
class DownloadBackupRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Determine if the user is authorized to make this request.
|
||
|
|
*
|
||
|
|
* @return bool
|
||
|
|
*/
|
||
|
|
public function authorize(): bool
|
||
|
|
{
|
||
|
|
return $this->user()->hasPermission('manage-backups');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||
|
|
*/
|
||
|
|
public function rules(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'filename' => [
|
||
|
|
'required',
|
||
|
|
'string',
|
||
|
|
'regex:/^[a-zA-Z0-9_\-\.]+\.gz$/', // Basic safety against traversal and only allows .gz
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|