firefly-iii/app/Http/Requests/ExportFormRequest.php

58 lines
1.5 KiB
PHP
Raw Normal View History

2016-02-04 10:16:16 -06:00
<?php
/**
* ExportFormRequest.php
2016-04-01 09:44:46 -05:00
* Copyright (C) 2016 thegrumpydictator@gmail.com
2016-02-04 10:16:16 -06:00
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
2016-02-04 10:16:16 -06:00
*/
declare(strict_types = 1);
2016-02-04 10:16:16 -06:00
namespace FireflyIII\Http\Requests;
use Carbon\Carbon;
/**
* Class ExportFormRequest
*
*
* @package FireflyIII\Http\Requests
*/
class ExportFormRequest extends Request
{
/**
* @return bool
*/
public function authorize()
{
// Only allow logged in users
2016-09-16 05:07:45 -05:00
return auth()->check();
2016-02-04 10:16:16 -06:00
}
/**
* @return array
*/
public function rules()
{
2016-02-07 02:11:46 -06:00
$sessionFirst = clone session('first');
$first = $sessionFirst->subDay()->format('Y-m-d');
2016-02-04 10:16:16 -06:00
$today = Carbon::create()->addDay()->format('Y-m-d');
$formats = join(',', array_keys(config('firefly.export_formats')));
return [
'export_start_range' => 'required|date|after:' . $first,
'export_end_range' => 'required|date|before:' . $today,
2016-02-04 10:16:16 -06:00
'accounts' => 'required',
'job' => 'required|belongsToUser:export_jobs,key',
'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',
'include_attachments' => 'in:0,1',
'include_config' => 'in:0,1',
'exportFormat' => 'in:' . $formats,
];
}
}