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

43 lines
841 B
PHP
Raw Normal View History

2015-02-22 08:40:13 -06:00
<?php
namespace FireflyIII\Http\Requests;
use Auth;
use FireflyIII\Models\Budget;
use Input;
/**
* Class BudgetFormRequest
*
2015-05-10 01:08:07 -05:00
* @codeCoverageIgnore
2015-02-22 08:40:13 -06:00
* @package FireflyIII\Http\Requests
*/
class BudgetFormRequest extends Request
{
/**
* @return bool
*/
public function authorize()
{
// Only allow logged in users
return Auth::check();
}
/**
* @return array
*/
public function rules()
{
2015-03-31 07:16:25 -05:00
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted';
2015-02-22 08:40:13 -06:00
if (Budget::find(Input::get('id'))) {
2015-04-07 11:26:14 -05:00
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,encrypted,' . intval(Input::get('id'));
2015-02-22 08:40:13 -06:00
}
return [
'name' => $nameRule,
'active' => 'numeric|between:0,1'
2015-02-22 08:40:13 -06:00
];
}
2015-03-29 01:14:32 -05:00
}