2016-02-23 07:18:09 -06:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* SelectTransactionsRequest.php
|
2016-05-20 05:41:23 -05:00
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
2016-02-23 07:18:09 -06:00
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
2016-05-20 05:41:23 -05:00
|
|
|
declare(strict_types = 1);
|
|
|
|
|
2016-02-23 07:18:09 -06:00
|
|
|
namespace FireflyIII\Http\Requests;
|
|
|
|
|
|
|
|
use Auth;
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ExportFormRequest
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Http\Requests
|
|
|
|
*/
|
|
|
|
class SelectTransactionsRequest extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
// Only allow logged in users
|
|
|
|
return Auth::check();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
$sessionFirst = clone session('first');
|
|
|
|
|
2016-02-23 08:55:09 -06:00
|
|
|
$first = $sessionFirst->subDay()->format('Y-m-d');
|
|
|
|
$today = Carbon::create()->addDay()->format('Y-m-d');
|
2016-02-23 07:18:09 -06:00
|
|
|
|
|
|
|
return [
|
2016-02-23 08:55:09 -06:00
|
|
|
'start_date' => 'required|date|after:' . $first,
|
|
|
|
'end_date' => 'required|date|before:' . $today,
|
|
|
|
'accounts' => 'required',
|
|
|
|
'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts',
|
2016-02-23 07:18:09 -06:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|