Fixes #1909 - allow 0 month depreciation

This commit is contained in:
snipe 2016-04-19 07:39:54 -07:00
parent 679a6a5522
commit 13f85e82bb
2 changed files with 5 additions and 5 deletions

View file

@ -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);
}

View file

@ -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.'%');
});