2015-02-25 08:57:43 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Http\Requests;
|
|
|
|
|
|
|
|
use Auth;
|
|
|
|
use Input;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BillFormRequest
|
|
|
|
*
|
2015-05-10 01:08:07 -05:00
|
|
|
* @codeCoverageIgnore
|
2015-02-25 08:57:43 -06:00
|
|
|
* @package FireflyIII\Http\Requests
|
|
|
|
*/
|
|
|
|
class CurrencyFormRequest extends Request
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
|
|
|
// Only allow logged in users
|
|
|
|
return Auth::check();
|
|
|
|
}
|
|
|
|
|
2015-04-05 13:47:19 -05:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getCurrencyData()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'name' => $this->get('name'),
|
|
|
|
'code' => $this->get('code'),
|
|
|
|
'symbol' => $this->get('symbol'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-02-25 08:57:43 -06:00
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
}
|
2015-03-29 01:14:32 -05:00
|
|
|
}
|