mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Eager load adminuser
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
bc540b6564
commit
2fc88a0e08
|
@ -48,6 +48,8 @@ class AssetModelsController extends Controller
|
|||
'assets_count',
|
||||
'category',
|
||||
'fieldset',
|
||||
'deleted_at',
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
$assetmodels = AssetModel::select([
|
||||
|
@ -67,7 +69,7 @@ class AssetModelsController extends Controller
|
|||
'models.deleted_at',
|
||||
'models.updated_at',
|
||||
])
|
||||
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues')
|
||||
->with('category', 'depreciation', 'manufacturer', 'fieldset.fields.defaultValues','adminuser')
|
||||
->withCount('assets as assets_count');
|
||||
|
||||
if ($request->input('status')=='deleted') {
|
||||
|
|
|
@ -36,7 +36,6 @@ class AssetModel extends SnipeModel
|
|||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
protected $table = 'models';
|
||||
protected $hidden = ['created_by', 'deleted_at'];
|
||||
protected $presenter = AssetModelPresenter::class;
|
||||
|
||||
// Declare the rules for the model validation
|
||||
|
@ -69,7 +68,6 @@ class AssetModel extends SnipeModel
|
|||
'model_number',
|
||||
'name',
|
||||
'notes',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
use Searchable;
|
||||
|
@ -226,6 +224,18 @@ class AssetModel extends SnipeModel
|
|||
->orderBy('created_at', 'desc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user who created the item
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @return \Illuminate\Database\Eloquent\Relations\Relation
|
||||
*/
|
||||
public function adminuser()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'created_by');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* -----------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue