firefly-iii/app/Http/Requests/CurrencyFormRequest.php
2015-05-10 08:08:07 +02:00

59 lines
1.2 KiB
PHP

<?php
namespace FireflyIII\Http\Requests;
use Auth;
use Input;
/**
* Class BillFormRequest
*
* @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class CurrencyFormRequest extends Request
{
/**
* @return bool
*/
public function authorize()
{
// Only allow logged in users
return Auth::check();
}
/**
* @return array
*/
public function getCurrencyData()
{
return [
'name' => $this->get('name'),
'code' => $this->get('code'),
'symbol' => $this->get('symbol'),
];
}
/**
* @return array
*/
public function rules()
{
$rules = [
'code' => 'required|min:3|max:3|unique:transaction_currencies,code',
'name' => 'required|max:48|min:1|unique:transaction_currencies,name',
'symbol' => 'required|min:1|max:8|unique:transaction_currencies,symbol',
];
if (intval(Input::get('id')) > 0) {
$rules = [
'code' => 'required|min:3|max:3',
'name' => 'required|max:48|min:1',
'symbol' => 'required|min:1|max:8',
];
}
return $rules;
}
}