Compare commits

...

3 Commits

Author SHA1 Message Date
snipe
adec86f1ef Changed the method name, since it will return an entire collection
Signed-off-by: snipe <snipe@snipe.net>
2023-01-10 12:18:27 -08:00
snipe
46e17f7e77 Adds the filename for the acceptance PDF to asset payload
Signed-off-by: snipe <snipe@snipe.net>
2023-01-10 12:12:08 -08:00
snipe
772d3c1da9 Removed duplicate validation
Signed-off-by: snipe <snipe@snipe.net>
2023-01-10 12:12:04 -08:00
2 changed files with 20 additions and 1 deletions

View File

@@ -190,6 +190,8 @@ class AssetsTransformer
'email'=> ($asset->assigned->email) ? e($asset->assigned->email) : null,
'employee_number' => ($asset->assigned->employee_num) ? e($asset->assigned->employee_num) : null,
'type' => 'user',
'eula_pdf' => e($asset->acceptanceLog->last()->filename),
'signature_file' => e($asset->acceptanceLog->last()->accept_signature),
] : null;
}

View File

@@ -106,7 +106,6 @@ class Asset extends Depreciable
'physical' => 'numeric|max:1|nullable',
'checkout_date' => 'date|max:10|min:10|nullable',
'checkin_date' => 'date|max:10|min:10|nullable',
'supplier_id' => 'exists:suppliers,id|numeric|nullable',
'location_id' => 'exists:locations,id|nullable',
'rtd_location_id' => 'exists:locations,id|nullable',
'asset_tag' => 'required|min:1|max:255|unique_undeleted',
@@ -588,6 +587,24 @@ class Asset extends Depreciable
->withTrashed();
}
/**
* Get the log info for acceptances on this asset.
* To use this as a single record, invoke it using ->last(), for
* example, $asset->lastAcceptedLog->last().
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v6.0.14]
* @return \Illuminate\Database\Eloquent\Relations\Relation
*/
public function acceptanceLog()
{
return $this->hasMany(\App\Models\Actionlog::class, 'item_id')
->where('item_type', '=', self::class)
->where('action_type', '=', 'accepted')
->orderBy('created_at', 'desc')
->withTrashed();
}
/**
* Get the list of checkouts for this asset
*