48 lines
1.1 KiB
PHP
Executable File
48 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Admin\app\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Modules\Admin\app\Rules\TimezoneOffsetRule;
|
|
|
|
class DashboardRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$actionMethod = $this->route()->getActionMethod();
|
|
$rules = array();
|
|
|
|
if (in_array($actionMethod, [
|
|
'statisticKeywordsByMonth',
|
|
'statisticRevenuesByMonth'
|
|
])) {
|
|
$rules = [
|
|
'timezone_offset' => [
|
|
'required',
|
|
new TimezoneOffsetRule,
|
|
],
|
|
'month' => [
|
|
'integer',
|
|
'between:1,12',
|
|
],
|
|
'year' => [
|
|
'integer'
|
|
],
|
|
];
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|