From 5d946b19cb9a00676fb5d40e7d15238bbb8aec86 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 27 Mar 2015 17:44:49 -0700 Subject: [PATCH] Fixed checkmodel at route level --- app/controllers/admin/AssetsController.php | 4 ++-- app/models/Asset.php | 7 ------- app/routes.php | 8 ++++++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 484da8f29f8f..ac8cdc1898ff 100755 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -155,7 +155,7 @@ public function postCreate() } else { $asset->rtd_location_id = e(Input::get('rtd_location_id')); } - $checkModel = $asset->checkModel(e(Input::get('model_id'))); + $asset->mac_address = ($checkModel == true) ? e(Input::get('mac_address')) : NULL; // Save the asset data @@ -292,7 +292,7 @@ public function postEdit($assetId = null) $asset->rtd_location_id = e(Input::get('rtd_location_id')); } - $checkModel = $this->checkModel(e(Input::get('model_id'))); + $asset->mac_address = ($checkModel == true) ? e(Input::get('mac_address')) : NULL; // Update the asset data diff --git a/app/models/Asset.php b/app/models/Asset.php index a62f58a6030b..d04e4fd3a8e9 100755 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -132,13 +132,6 @@ public function assetNameForEula() } } - - public function checkModel($modelId) { - $model = Model::find($modelId); - return $model->show_mac_address; - } - - public function warrantee_expires() { $date = date_create($this->purchase_date); diff --git a/app/routes.php b/app/routes.php index 14dbd4c96bb5..37b6189c7809 100755 --- a/app/routes.php +++ b/app/routes.php @@ -29,8 +29,12 @@ /*---Models API---*/ Route::group(array('prefix'=>'models'), function() { Route::resource('/', 'ModelsController'); - Route::get('list/{status?}', array('as'=>'api.models.list', 'uses'=>'ModelsController@getDatatable')); - Route::get('{modelId}/check', array('as' => 'api.models.check', 'uses' => 'ModelsController@checkModel')); + Route::get('list/{status?}', array('as'=>'api.models.list', 'uses'=>'ModelsController@getDatatable')); + Route::get('{modelId}/check', function ($modelId) { + $model = Model::find($modelId); + return $model->show_mac_address; + }); + Route::get('{modelID}/view', array('as'=>'api.models.view', 'uses'=>'ModelsController@getDataView')); }); /*--- Categories API---*/