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();
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (! array_key_exists('start_date', $input)) {
|
|
|
|
$input['start_date'] = now()->subDays(20);
|
|
|
|
}
|
2022-01-21 02:00:32 +01:00
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
if (! array_key_exists('end_date', $input)) {
|
|
|
|
$input['end_date'] = now();
|
|
|
|
}
|
2022-01-21 02:00:32 +01:00
|
|
|
|
|
|
|
$this->replace($input);
|
|
|
|
}
|
2022-01-20 02:15:33 +01:00
|
|
|
}
|