2016-01-13 11:34:56 -06:00
|
|
|
<?php
|
2016-05-20 05:41:23 -05:00
|
|
|
/**
|
|
|
|
* RuleGroupFormRequest.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
2016-02-05 05:08:25 -06:00
|
|
|
declare(strict_types = 1);
|
2016-01-13 11:34:56 -06:00
|
|
|
/**
|
|
|
|
* RuleGroupFormRequest.php
|
2016-04-01 09:44:46 -05:00
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
2016-01-13 11:34:56 -06:00
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace FireflyIII\Http\Requests;
|
|
|
|
|
|
|
|
use Auth;
|
|
|
|
use FireflyIII\Models\RuleGroup;
|
|
|
|
use Input;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class RuleGroupFormRequest
|
|
|
|
*
|
2016-02-04 00:28:39 -06:00
|
|
|
*
|
2016-01-13 11:34:56 -06:00
|
|
|
* @package FireflyIII\Http\Requests
|
|
|
|
*/
|
|
|
|
class RuleGroupFormRequest extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
// Only allow logged in users
|
|
|
|
return Auth::check();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
|
|
|
|
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title';
|
|
|
|
if (RuleGroup::find(Input::get('id'))) {
|
|
|
|
$titleRule = 'required|between:1,100|uniqueObjectForUser:rule_groups,title,' . intval(Input::get('id'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
2016-01-15 16:12:52 -06:00
|
|
|
'title' => $titleRule,
|
2016-01-13 11:34:56 -06:00
|
|
|
'description' => 'between:1,5000',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|