1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Http/Requests/Chart/ShowChartRequest.php

51 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-20 02:15:33 +01:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
2022-04-27 05:20:41 +02:00
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
2022-01-20 02:15:33 +01:00
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Http\Requests\Chart;
use App\Http\Requests\Request;
use App\Models\Activity;
class ShowChartRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize() : bool
{
return auth()->user()->isAdmin();
}
public function rules()
{
return [
2022-01-21 02:00:32 +01:00
'start_date' => 'date',
'end_date' => 'date',
2022-01-20 02:15:33 +01:00
];
}
2022-01-21 02:00:32 +01:00
protected function prepareForValidation()
{
$input = $this->all();
if(!array_key_exists('start_date', $input))
$input['start_date'] = now()->subDays(20);
if(!array_key_exists('end_date', $input))
$input['end_date'] = now();
$this->replace($input);
}
2022-01-20 02:15:33 +01:00
}