mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Fixes #1944 - add manufacturer to model list
This commit is contained in:
parent
3eb09871cf
commit
96911b9e57
|
@ -4,6 +4,7 @@ namespace App\Helpers;
|
|||
use DB;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Location;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\User;
|
||||
use App\Models\Manufacturer;
|
||||
|
@ -38,6 +39,7 @@ class Helper
|
|||
return trim($value);
|
||||
}
|
||||
|
||||
|
||||
public static function ParseFloat($floatString)
|
||||
{
|
||||
// use comma for thousands until local info is property used
|
||||
|
@ -50,12 +52,12 @@ class Helper
|
|||
|
||||
public static function modelList()
|
||||
{
|
||||
$model_list = array('' => trans('general.select_model')) + DB::table('models')
|
||||
->select(DB::raw('IF (modelno="" OR modelno IS NULL,name,concat(name, " / ",modelno)) as name, id'))
|
||||
->orderBy('name', 'asc')
|
||||
->whereNull('deleted_at')
|
||||
->pluck('name', 'id');
|
||||
return $model_list;
|
||||
$models = AssetModel::with('manufacturer')->get();
|
||||
$model_array[''] = trans('general.select_model');
|
||||
foreach ($models as $model) {
|
||||
$model_array[$model->id] = $model->displayModelName();
|
||||
}
|
||||
return $model_array;
|
||||
}
|
||||
|
||||
public static function companyList()
|
||||
|
|
|
@ -87,6 +87,15 @@ class AssetModel extends Model
|
|||
|
||||
}
|
||||
|
||||
public function displayModelName()
|
||||
{
|
||||
$name = $this->manufacturer->name.' '.$this->name;
|
||||
if ($this->modelno) {
|
||||
$name .=" / ".$this->modelno;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
* BEGIN QUERY SCOPES
|
||||
|
|
Loading…
Reference in a new issue