Use statics for location, supplier, etc

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-05-28 18:02:22 +01:00
parent 14c78d9065
commit 1c1729854e

View file

@ -221,13 +221,30 @@ class ActionlogsTransformer
*/ */
public function changedInfo(array $clean_meta) public function changedInfo(array $clean_meta)
{ $location = Location::withTrashed()->get(); {
$supplier = Supplier::withTrashed()->get(); static $location = false;
$model = AssetModel::withTrashed()->get(); static $supplier = false;
$status = Statuslabel::withTrashed()->get(); static $model = false;
$company = Company::get(); static $status = false;
static $company = false;
if ($location === false) {
$location = Location::select('id', 'name')->withTrashed()->get();
}
if ($supplier === false) {
$supplier = Supplier::select('id', 'name')->withTrashed()->get();
}
if ($model === false) {
$model = AssetModel::select('id', 'name')->withTrashed()->get();
}
if ($status === false) {
$status = Statuslabel::select('id', 'name')->withTrashed()->get();
}
if ($company === false) {
$company = Company::select('id', 'name')->get();
}
if(array_key_exists('rtd_location_id',$clean_meta)) { if(array_key_exists('rtd_location_id',$clean_meta)) {
$oldRtd = $location->find($clean_meta['rtd_location_id']['old']); $oldRtd = $location->find($clean_meta['rtd_location_id']['old']);