1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 17:01:33 +02:00
invoiceninja/app/Http/Requests/Chart/ShowChartRequest.php

52 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
2022-06-24 03:55:41 +02:00
public function prepareForValidation()
2022-01-21 02:00:32 +01:00
{
$input = $this->all();
if (! array_key_exists('start_date', $input)) {
$input['start_date'] = now()->subDays(20);
}
2022-01-21 02:00:32 +01: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
}