I have a controller that receives input from a from. My controller handles both the create and the update in different functions.
Is there a way that I can create an array / function of sorts that I can then call in both locations so that I don't have to repeat the same code bellow in the create and update functions?
$client->company_name = Input::get('company_name');
$client->telephone = Input::get('telephone');
$client->website = Input::get('website');
$client->building_name = Input::get('building_name');
$client->street_address = Input::get('street_address');
$client->town = Input::get('town');
I've created the rules array (below), I just need to try to do the same for the input values.
/**
* create the validation rules for database input
*
* @return array
*/
private function rules()
{
$rules = array(
'company_name' => 'required',
'telephone' => 'required',
'website' => 'url',
'building_name' => '',
'street_address' => '',
'town' => '',
);
return $rules;
}
Thanks all, I'd appreciate any assistance.