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

@ -52,7 +52,7 @@ class ActionlogsTransformer
static $custom_fields = false;
if ($custom_fields === false) {
$custom_fields = CustomField::all();
$custom_fields = CustomField::all();
}
if ($actionlog->filename!='') {
@ -221,13 +221,30 @@ class ActionlogsTransformer
*/
public function changedInfo(array $clean_meta)
{ $location = Location::withTrashed()->get();
$supplier = Supplier::withTrashed()->get();
$model = AssetModel::withTrashed()->get();
$status = Statuslabel::withTrashed()->get();
$company = Company::get();
{
static $location = false;
static $supplier = false;
static $model = false;
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)) {
$oldRtd = $location->find($clean_meta['rtd_location_id']['old']);