Move sanitization of input to the model attribute setters. This cleans up a lot of checks in the various controller methods and ensures data will be set in the model accurately regardless of where it's set. Add unit tests for these methods (#3102)

This commit is contained in:
Daniel Meltzer
2016-12-26 18:17:46 -05:00
committed by snipe
parent fd450e2773
commit 06af9311fc
19 changed files with 403 additions and 417 deletions
+8 -16
View File
@@ -80,11 +80,7 @@ class LocationsController extends Controller
{
$location = new Location();
$location->name = Input::get('name');
if (Input::get('parent_id')=='') {
$location->parent_id = null;
} else {
$location->parent_id = Input::get('parent_id');
}
$location->parent_id = Input::get('parent_id', null);
$location->currency = Input::get('currency', '$');
$location->address = Input::get('address');
$location->address2 = Input::get('address2');
@@ -180,18 +176,14 @@ class LocationsController extends Controller
// Update the location data
$location->name = Input::get('name');
if (Input::get('parent_id')=='') {
$location->parent_id = null;
} else {
$location->parent_id = Input::get('parent_id', '');
}
$location->currency = Input::get('currency', '$');
$location->address = Input::get('address');
$location->address2 = Input::get('address2');
$location->city = Input::get('city');
$location->state = Input::get('state');
$location->parent_id = Input::get('parent_id', null);
$location->currency = Input::get('currency', '$');
$location->address = Input::get('address');
$location->address2 = Input::get('address2');
$location->city = Input::get('city');
$location->state = Input::get('state');
$location->country = Input::get('country');
$location->zip = Input::get('zip');
$location->zip = Input::get('zip');
// Was the asset created?
if ($location->save()) {