mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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 DB;
|
||||||
use App\Models\Statuslabel;
|
use App\Models\Statuslabel;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
|
use App\Models\AssetModel;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Manufacturer;
|
use App\Models\Manufacturer;
|
||||||
|
@ -38,6 +39,7 @@ class Helper
|
||||||
return trim($value);
|
return trim($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function ParseFloat($floatString)
|
public static function ParseFloat($floatString)
|
||||||
{
|
{
|
||||||
// use comma for thousands until local info is property used
|
// use comma for thousands until local info is property used
|
||||||
|
@ -50,12 +52,12 @@ class Helper
|
||||||
|
|
||||||
public static function modelList()
|
public static function modelList()
|
||||||
{
|
{
|
||||||
$model_list = array('' => trans('general.select_model')) + DB::table('models')
|
$models = AssetModel::with('manufacturer')->get();
|
||||||
->select(DB::raw('IF (modelno="" OR modelno IS NULL,name,concat(name, " / ",modelno)) as name, id'))
|
$model_array[''] = trans('general.select_model');
|
||||||
->orderBy('name', 'asc')
|
foreach ($models as $model) {
|
||||||
->whereNull('deleted_at')
|
$model_array[$model->id] = $model->displayModelName();
|
||||||
->pluck('name', 'id');
|
}
|
||||||
return $model_list;
|
return $model_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function companyList()
|
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
|
* BEGIN QUERY SCOPES
|
||||||
|
|
Loading…
Reference in a new issue