diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 3c8ddbbd21..e753f9fb15 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -529,7 +529,11 @@ class AssetsController extends Controller $asset->next_audit_date = $request->input('next_audit_date'); if ($asset->save()) { $log = $asset->logAudit(request('note'),request('location_id')); - return response()->json(Helper::formatStandardApiResponse('success', ['asset_tag'=> e($asset->asset_tag), 'note'=> e($request->input('note')), 'next_audit_date' => Helper::getFormattedDateObject($log->calcNextAuditDate())], trans('admin/hardware/message.audit.success'))); + return response()->json(Helper::formatStandardApiResponse('success', [ + 'asset_tag'=> e($asset->asset_tag), + 'note'=> e($request->input('note')), + 'next_audit_date' => Helper::getFormattedDateObject($log->calcNextAuditDate()) + ], trans('admin/hardware/message.audit.success'))); } } diff --git a/app/Models/Loggable.php b/app/Models/Loggable.php index c698e2cc06..da9899ec02 100644 --- a/app/Models/Loggable.php +++ b/app/Models/Loggable.php @@ -131,6 +131,7 @@ trait Loggable public function logAudit($note, $location_id) { $log = new Actionlog; + $location = Location::find($location_id); if (static::class == LicenseSeat::class) { $log->item_type = License::class; $log->item_id = $this->license_id; @@ -146,6 +147,7 @@ trait Loggable $params = [ 'item' => $log->item, 'admin' => $log->user, + 'location' => ($location) ? $location->name : '', 'note' => $note ]; Setting::getSettings()->notify(new AuditNotification($params)); diff --git a/app/Notifications/AuditNotification.php b/app/Notifications/AuditNotification.php index ffd668f38d..20d3b4a090 100644 --- a/app/Notifications/AuditNotification.php +++ b/app/Notifications/AuditNotification.php @@ -56,8 +56,9 @@ class AuditNotification extends Notification 'By' => '<'.$admin_user->present()->viewUrl().'|'.$admin_user->present()->fullName().'>' ]; array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note']; + array_key_exists('location', $this->params) && $fields['Location'] = $this->params['location']; - $attachment->title($item->name, $item->present()->viewUrl()) + $attachment->title($item->present()->name, $item->present()->viewUrl()) ->fields($fields); }); } @@ -69,10 +70,7 @@ class AuditNotification extends Notification */ public function toMail($notifiable) { - return (new MailMessage) - ->line('The introduction to the notification.') - ->action('Notification Action', 'https://laravel.com') - ->line('Thank you for using our application!'); + } /**