mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Use notifiables for slack audit notification
This commit is contained in:
parent
3518ea7e7d
commit
761371509d
|
@ -529,7 +529,11 @@ class AssetsController extends Controller
|
||||||
$asset->next_audit_date = $request->input('next_audit_date');
|
$asset->next_audit_date = $request->input('next_audit_date');
|
||||||
if ($asset->save()) {
|
if ($asset->save()) {
|
||||||
$log = $asset->logAudit(request('note'),request('location_id'));
|
$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')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,7 @@ trait Loggable
|
||||||
public function logAudit($note, $location_id)
|
public function logAudit($note, $location_id)
|
||||||
{
|
{
|
||||||
$log = new Actionlog;
|
$log = new Actionlog;
|
||||||
|
$location = Location::find($location_id);
|
||||||
if (static::class == LicenseSeat::class) {
|
if (static::class == LicenseSeat::class) {
|
||||||
$log->item_type = License::class;
|
$log->item_type = License::class;
|
||||||
$log->item_id = $this->license_id;
|
$log->item_id = $this->license_id;
|
||||||
|
@ -146,6 +147,7 @@ trait Loggable
|
||||||
$params = [
|
$params = [
|
||||||
'item' => $log->item,
|
'item' => $log->item,
|
||||||
'admin' => $log->user,
|
'admin' => $log->user,
|
||||||
|
'location' => ($location) ? $location->name : '',
|
||||||
'note' => $note
|
'note' => $note
|
||||||
];
|
];
|
||||||
Setting::getSettings()->notify(new AuditNotification($params));
|
Setting::getSettings()->notify(new AuditNotification($params));
|
||||||
|
|
|
@ -56,8 +56,9 @@ class AuditNotification extends Notification
|
||||||
'By' => '<'.$admin_user->present()->viewUrl().'|'.$admin_user->present()->fullName().'>'
|
'By' => '<'.$admin_user->present()->viewUrl().'|'.$admin_user->present()->fullName().'>'
|
||||||
];
|
];
|
||||||
array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note'];
|
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);
|
->fields($fields);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,10 +70,7 @@ class AuditNotification extends Notification
|
||||||
*/
|
*/
|
||||||
public function toMail($notifiable)
|
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!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue