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

41 lines
683 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
*
* @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()
{
$nameRule = 'required|between:1,100|uniqueForUser:budgets,name';
if (Budget::find(Input::get('id'))) {
$nameRule = 'required|between:1,100';
}
return [
'name' => $nameRule,
];
}
2015-03-29 01:14:32 -05:00
}