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

36 lines
972 B
PHP
Raw Normal View History

<?php
namespace FireflyIII\Http\Requests;
use Auth;
2015-02-09 00:23:39 -06:00
use Config;
/**
* Class AccountFormRequest
*
* @package FireflyIII\Http\Requests
*/
class AccountFormRequest extends Request
{
public function authorize()
{
// Only allow logged in users
return Auth::check();
}
public function rules()
{
2015-02-09 00:23:39 -06:00
$accountRoles = join(',', array_keys(Config::get('firefly.accountRoles')));
$types = join(',', array_keys(Config::get('firefly.subTitlesByIdentifier')));
return [
2015-02-09 00:23:39 -06:00
'name' => 'required|between:1,100|uniqueForUser:accounts,name',
'openingBalance' => 'numeric',
'openingBalanceDate' => 'date',
'accountRole' => 'in:' . $accountRoles,
'active' => 'boolean',
'balance_currency_id' => 'required|exists:transaction_currencies,id',
'what' => 'in:' . $types
];
}
}