1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +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
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @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
}