diff --git a/app/Http/Controllers/DepreciationsController.php b/app/Http/Controllers/DepreciationsController.php index 35df4da837..a84174dc83 100755 --- a/app/Http/Controllers/DepreciationsController.php +++ b/app/Http/Controllers/DepreciationsController.php @@ -11,6 +11,7 @@ use Str; use View; use Auth; + /** * This controller handles all actions related to Depreciations for * the Snipe-IT Asset Management application. @@ -46,8 +47,7 @@ class DepreciationsController extends Controller public function getCreate() { // Show the page - $depreciation_options = \App\Helpers\Helper::depreciationList(); - return View::make('depreciations/edit')->with('depreciation_options', $depreciation_options)->with('depreciation', new Depreciation); + return View::make('depreciations/edit')->with('depreciation', new Depreciation); } @@ -103,7 +103,7 @@ class DepreciationsController extends Controller // Show the page //$depreciation_options = array('' => 'Top Level') + Depreciation::lists('name', 'id'); - $depreciation_options = array('' => 'Top Level') + DB::table('depreciations')->where('id', '!=', $depreciationId)->lists('name', 'id'); + $depreciation_options = Helper::depreciationList(); return View::make('depreciations/edit', compact('depreciation'))->with('depreciation_options', $depreciation_options); } diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php index a1f6287e62..48e8e7d8b5 100755 --- a/app/Models/Depreciation.php +++ b/app/Models/Depreciation.php @@ -9,7 +9,7 @@ class Depreciation extends Model // Declare the rules for the form validation protected $rules = array( 'name' => 'required|min:3|max:255|unique:depreciations,name', - 'months' => 'required|min:1|max:240|integer', + 'months' => 'required|max:240|integer', ); /** @@ -53,7 +53,7 @@ class Depreciation extends Model { return $query->where(function ($query) use ($search) { - + $query->where('name', 'LIKE', '%'.$search.'%') ->orWhere('months', 'LIKE', '%'.$search.'%'); });