A free open source IT asset/license management system
Notification rework (#3103)
Daniel Meltzercafafe851cb4
diff --git a/app/Http/Controllers/AccessoriesController.php b/app/Http/Controllers/AccessoriesController.phpindex 9f55487893..01d297bf93 100755--- a/app/Http/Controllers/AccessoriesController.php+++ b/app/Http/Controllers/AccessoriesController.php@@ -3,9 +3,7 @@ namespace App\Http\Controllers;use App\Helpers\Helper;use App\Models\Accessory;-use App\Models\Actionlog;use App\Models\Company;-use App\Models\Setting;use App\Models\User;use Auth;use Carbon\Carbon;@@ -261,49 +259,17 @@ class AccessoriesController extends Controller}// Update the accessory data- $accessory->assigned_to = e(Input::get('assigned_to'));+ $accessory->assigned_to = e(Input::get('assigned_to'));- $accessory->users()->attach($accessory->id, array(- 'accessory_id' => $accessory->id,- 'created_at' => Carbon::now(),- 'user_id' => Auth::user()->id,- 'assigned_to' => e(Input::get('assigned_to'))));+ $accessory->users()->attach($accessory->id, [+ 'accessory_id' => $accessory->id,+ 'created_at' => Carbon::now(),+ 'user_id' => Auth::id(),+ 'assigned_to' => $request->get('assigned_to')+ ]);$logaction = $accessory->logCheckout(e(Input::get('note')));- $admin_user = Auth::user();- $settings = Setting::getSettings();-- if ($settings->slack_endpoint) {-- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked Out:',- 'value' => 'Accessory <'.route('accessories.show', $accessory->id).'|'.$accessory->name.'> checked out to <'.route('users.show', $user->id).'|'.$user->present()->fullName().'> by <'.route('users.show', $admin_user->id).'|'.$admin_user->present()->fullName().'>.'- ],- [- 'title' => 'Note:',- 'value' => e(Input::get('note'))- ],- ]- ])->send('Accessory Checked Out');- } catch (Exception $e) {-- }-- }-DB::table('accessories_users')->where('assigned_to', '=', $accessory->assigned_to)->where('accessory_id', '=', $accessory->id)->first();$data['log_id'] = $logaction->id;@@ -315,8 +281,7 @@ class AccessoriesController extends Controller$data['expected_checkin'] = '';$data['note'] = $logaction->note;$data['require_acceptance'] = $accessory->requireAcceptance();--+ // TODO: Port this to new mail notificationsif (($accessory->requireAcceptance()=='1') || ($accessory->getEula())) {Mail::send('emails.accept-accessory', $data, function ($m) use ($user) {@@ -380,46 +345,9 @@ class AccessoriesController extends Controller$return_to = e($accessory_user->assigned_to);$logaction = $accessory->logCheckin(User::find($return_to), e(Input::get('note')));- $admin_user = Auth::user();// Was the accessory updated?if (DB::table('accessories_users')->where('id', '=', $accessory_user->id)->delete()) {-- $settings = Setting::getSettings();-- if ($settings->slack_endpoint) {--- $slack_settings = [- 'username' => e($settings->botname),- 'channel' => e($settings->slack_channel),- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked In:',- 'value' => class_basename(strtoupper($logaction->item_type)).' <'.route('accessories.show', $accessory->id).'|'.e($accessory->name).'> checked in by <'.route('users.show', $admin_user->id).'|'.e($admin_user->present()->fullName()).'>.'- ],- [- 'title' => 'Note:',- 'value' => e($logaction->note)- ],-- ]- ])->send('Accessory Checked In');-- } catch (Exception $e) {-- }-- }-if (!is_null($accessory_user->assigned_to)) {$user = User::find($accessory_user->assigned_to);}diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.phpindex 842803d260..a64de53d18 100755--- a/app/Http/Controllers/AssetsController.php+++ b/app/Http/Controllers/AssetsController.php@@ -421,13 +421,14 @@ class AssetsController extends Controller}/**- * Validate and process the form data to check out an asset to a user.- *- * @author [A. Gianotto] [<[email protected]>]- * @param int $assetId- * @since [v1.0]- * @return Redirect- */+ * Validate and process the form data to check out an asset to a user.+ *+ * @author [A. Gianotto] [<[email protected]>]+ * @param AssetCheckoutRequest $request+ * @param int $assetId+ * @return Redirect+ * @since [v1.0]+ */public function postCheckout(AssetCheckoutRequest $request, $assetId){@@ -453,9 +454,8 @@ class AssetsController extends Controller} else {$expected_checkin = '';}-if ($asset->checkOutToUser($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), e(Input::get('name')))) {- // Redirect to the new asset page+// Redirect to the new asset pagereturn redirect()->to("hardware")->with('success', trans('admin/hardware/message.checkout.success'));}@@ -488,13 +488,15 @@ class AssetsController extends Controller/**- * Validate and process the form data to check an asset back into inventory.- *- * @author [A. Gianotto] [<[email protected]>]- * @param int $assetId- * @since [v1.0]- * @return Redirect- */+ * Validate and process the form data to check an asset back into inventory.+ *+ * @author [A. Gianotto] [<[email protected]>]+ * @param AssetCheckinRequest $request+ * @param int $assetId+ * @param null $backto+ * @return Redirect+ * @since [v1.0]+ */public function postCheckin(AssetCheckinRequest $request, $assetId = null, $backto = null){// Check if the asset exists@@ -525,51 +527,7 @@ class AssetsController extends Controller}// Was the asset updated?if ($asset->save()) {-- if ($request->input('checkin_at') == Carbon::now()->format('Y-m-d')) {- $checkin_at = Carbon::now();- } else {- $checkin_at = $request->input('checkin_at').' 00:00:00';- }- $logaction = $asset->createLogRecord('checkin', $asset, $admin, $user, null, e(Input::get('note')), $checkin_at);-- $settings = Setting::getSettings();-- if ($settings->slack_endpoint) {-- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked In:',- 'value' => class_basename(- strtoupper($logaction->item_type))- .' asset <'.route('hardware.show', $asset->id).'|'.e($asset->present()->name())- .'> checked in by <'.route('users.show',Auth::user()->id)- .'|'.e(Auth::user()->present()->fullName()).'>.'- ],- [- 'title' => 'Note:',- 'value' => e($logaction->note)- ],-- ]- ])->send('Asset Checked In');-- } catch (Exception $e) {-- }-- }+ $logaction = $asset->logCheckin($user, e(request('note')));$data['log_id'] = $logaction->id;$data['first_name'] = $user->first_name;diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.phpindex f8d4b65275..a9553536de 100644--- a/app/Http/Controllers/ComponentsController.php+++ b/app/Http/Controllers/ComponentsController.php@@ -295,43 +295,7 @@ class ComponentsController extends Controller'asset_id' => $asset_id]);- $logaction = $component->logCheckout(e(Input::get('note')), $asset_id);-- $settings = Setting::getSettings();-- if ($settings->slack_endpoint) {-- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked Out:',- 'value' => class_basename(strtoupper($logaction->item_type))- .' <'.route('components.show', ['component' => $component->id]).'|'.$component->name- .'> checked out to <'.route('hardware.show', $asset->id).'|'.$asset->present()->name()- .'> by <'.route('users.show', $admin_user->id).'|'.$admin_user->present()->fullName().'>.'- ],- [- 'title' => 'Note:',- 'value' => e($logaction->note)- ],- ]- ])->send('Component Checked Out');-- } catch (Exception $e) {-- }- }-+ $component->logCheckout(e(Input::get('note')), $asset_id);return redirect()->route('components.index')->with('success', trans('admin/components/message.checkout.success'));}diff --git a/app/Http/Controllers/ConsumablesController.php b/app/Http/Controllers/ConsumablesController.phpindex f1c2862f30..a99992b157 100644--- a/app/Http/Controllers/ConsumablesController.php+++ b/app/Http/Controllers/ConsumablesController.php@@ -8,6 +8,7 @@ use App\Models\Company;use App\Models\Consumable;use App\Models\Setting;use App\Models\User;+use App\Notifications\CheckoutNotification;use Auth;use Config;use DB;@@ -267,43 +268,6 @@ class ConsumablesController extends Controller]);$logaction = $consumable->logCheckout(e(Input::get('note')));-- $settings = Setting::getSettings();-- if ($settings->slack_endpoint) {-- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked Out:',- 'value' => 'Consumable <'.route('consumables.show', $consumable->id).'|'.$consumable->name- .'> checked out to <'.route('users.show', $user->id).'|'.$user->fullName()- .'> by <'.route('users.show', $admin_user->id).'|'.$admin_user->fullName().'>.'- ],- [- 'title' => 'Note:',- 'value' => e($logaction->note)- ],- ]- ])->send('Consumable Checked Out');-- } catch (Exception $e) {-- }- }-- $consumable_user = DB::table('consumables_users')->where('assigned_to', '=', $consumable->assigned_to)->where('consumable_id', '=', $consumable->id)->first();-$data['log_id'] = $logaction->id;$data['eula'] = $consumable->getEula();$data['first_name'] = $user->first_name;diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.phpindex 19c6dd213a..d63145fdec 100755--- a/app/Http/Controllers/LicensesController.php+++ b/app/Http/Controllers/LicensesController.php@@ -2,6 +2,7 @@namespace App\Http\Controllers;use Assets;+use Illuminate\Support\Facades\Session;use Input;use Lang;use App\Models\License;@@ -9,18 +10,13 @@ use App\Models\Asset;use App\Models\User;use App\Models\Actionlog;use DB;-use Redirect;use App\Models\LicenseSeat;-use App\Models\Depreciation;use App\Models\Company;-use App\Models\Setting;-use App\Models\Supplier;use Validator;use View;use Response;use Slack;use Config;-use Session;use App\Helpers\Helper;use Auth;use Gate;@@ -350,7 +346,6 @@ class LicensesController extends Controller$licenseSeat = LicenseSeat::find($seatId);$assigned_to = e($request->input('assigned_to'));$asset_id = e($request->input('asset_id'));- $user = Auth::user();$this->authorize('checkout', $licenseSeat);@@ -414,53 +409,6 @@ class LicensesController extends Controller$data['license_id'] =$licenseSeat->license_id;$data['note'] = $request->input('note');- $license = License::find($licenseSeat->license_id);- $settings = Setting::getSettings();-- // Update the asset data- if ($request->input('assigned_to') == '') {- $slack_msg = 'License <'.route('licenses.show', $license->id).'|'.$license->name- .'> checked out to <'.route('hardware.show',$asset->id) .'|'.$asset->present()->name()- .'> by <'.route('users.show', $user->id).'|'.$user->present()->fullName().'>.';- } else {- $slack_msg = 'License <'.route('licenses.show', $license->id).'|'.$license->name- .'> checked out to <'.route('users.show', $user->id).'|'.$is_assigned_to->present()->fullName()- .'> by <'.route('users.show', $user->id) .'|'.$user->present()->fullName().'>.';- }-- if ($settings->slack_endpoint) {- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked Out:',- 'value' => $slack_msg- ],- [- 'title' => 'Note:',- 'value' => e($request->input('note'))- ],---- ]- ])->send('License Checked Out');-- } catch (Exception $e) {-- }-- }-// Redirect to the new asset pagereturn redirect()->route("licenses.index")->with('success', trans('admin/licenses/message.checkout.success'));}@@ -541,51 +489,15 @@ class LicensesController extends Controller$licenseSeat->assigned_to = null;$licenseSeat->asset_id = null;- $user = Auth::user();-// Was the asset updated?if ($licenseSeat->save()) {- $licenseSeat->logCheckin($return_to, e($request->input('note')));-- $settings = Setting::getSettings();-- if ($settings->slack_endpoint) {- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked In:',- 'value' => 'License: <'.route('licenses.show', $license->id).'|'.$license->name- .'> checked in by <'.route('users.show', $user->id).'|'.$user->present()->fullName().'>.'- ],- [- 'title' => 'Note:',- 'value' => e($request->input('note'))- ],-- ]- ])->send('License Checked In');-- } catch (Exception $e) {-- }-- }-+ $licenseSeat->logCheckin($return_to, e(request('note')));if ($backTo=='user') {return redirect()->route("users.show", $return_to->id)->with('success', trans('admin/licenses/message.checkin.success'));}- redirect()->route("licenses.show", $licenseSeat->license_id)->with('success', trans('admin/licenses/message.checkin.success'));+ return redirect()->route("licenses.show", $licenseSeat->license_id)->with('success', trans('admin/licenses/message.checkin.success'));}+// Redirect to the license page with errorreturn redirect()->route("licenses.index")->with('error', trans('admin/licenses/message.checkin.error'));}diff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex b7abe88de8..4aca40fb53 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -105,13 +105,10 @@ class Asset extends Depreciable$this->assigneduser()->associate($user);- if($name != null)- {+ if($name != null) {$this->name = $name;}- $settings = Setting::getSettings();-if ($this->requireAcceptance()) {$this->accepted="pending";}@@ -119,19 +116,11 @@ class Asset extends Depreciableif ($this->save()) {-- // $action, $admin, $user, $expected_checkin = null, $note = null, $checkout_at = null- $log = $this->createLogRecord('checkout', $this, $admin, $user, $expected_checkin, $note, $checkout_at);-+ $this->logCheckout($note);if ((($this->requireAcceptance()=='1') || ($this->getEula())) && ($user->email!='')) {$this->checkOutNotifyMail($log->id, $user, $checkout_at, $expected_checkin, $note);}-- if ($settings->slack_endpoint) {- $this->checkOutNotifySlack($settings, $admin, $note);- }return true;-}return false;@@ -161,43 +150,6 @@ class Asset extends Depreciable}- public function checkOutNotifySlack($settings, $admin, $note = null)- {-- if ($settings->slack_endpoint) {-- $slack_settings = [- 'username' => $settings->botname,- 'channel' => $settings->slack_channel,- 'link_names' => true- ];-- $client = new \Maknz\Slack\Client($settings->slack_endpoint, $slack_settings);-- try {- $client->attach([- 'color' => 'good',- 'fields' => [- [- 'title' => 'Checked Out:',- 'value' => 'HARDWARE asset <'.route('hardware.show', $this->id).'|'.$this->present()->name()- .'> checked out to <'.route('users.show', $this->assigned_to).'|'.$this->assigneduser->present()->fullName()- .'> by <'.route('users.show', Auth::user()->id).'|'.$admin->present()->fullName().'>.'- ],- [- 'title' => 'Note:',- 'value' => e($note)- ],- ]- ])->send('Asset Checked Out');-- } catch (Exception $e) {- LOG::error($e);- }- }-- }-public function getDetailedNameAttribute(){@@ -214,38 +166,6 @@ class Asset extends Depreciable}- public function createLogRecord($action, $asset, $admin, $user, $expected_checkin = null, $note = null, $checkout_at = null)- {-- $logaction = new Actionlog();- $logaction->item_type = Asset::class;- $logaction->item_id = $this->id;- $logaction->target_type = User::class;- // On Checkin, this is the user that previously had the asset.- $logaction->target_id = $user->id;- $logaction->note = $note;- $logaction->user_id = $admin->id;- if ($checkout_at!='') {- $logaction->created_at = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', date('Y-m-d H:i:s', strtotime($checkout_at)));- } else {- $logaction->created_at = \Carbon\Carbon::now();- }-- if ($action=="checkout") {- if ($user) {- $logaction->location_id = $user->location_id;- }- } else {- // Update the asset data to null, since it's being checked in- $logaction->location_id = null;- }- $logaction->user()->associate($admin);- $log = $logaction->logaction($action);-- return $logaction;- }--/*** Set depreciation relationship*/diff --git a/app/Models/Loggable.php b/app/Models/Loggable.phpindex cba9b125dd..baf2086cb4 100644--- a/app/Models/Loggable.php+++ b/app/Models/Loggable.php@@ -6,6 +6,8 @@ use App\Models\Actionlog;use App\Models\Asset;use App\Models\CheckoutRequest;use App\Models\User;+use App\Notifications\CheckinNotification;+use App\Notifications\CheckoutNotification;use Illuminate\Support\Facades\Auth;trait Loggable@@ -55,6 +57,14 @@ trait Loggable$log->note = $note;$log->logaction('checkout');+ $params = [+ 'item' => $log->item,+ 'target' => $log->target,+ 'admin' => $log->user,+ 'note' => $note+ ];+ Setting::getSettings()->notify(new CheckoutNotification($params));+return $log;}@@ -80,6 +90,13 @@ trait Loggable$log->user_id = Auth::user()->id;$log->logaction('checkin from');+ $params = [+ 'item' => $log->item,+ 'admin' => $log->user,+ 'note' => $note+ ];+ Setting::getSettings()->notify(new CheckinNotification($params));+return $log;}diff --git a/app/Models/Setting.php b/app/Models/Setting.phpindex aefa882865..133620b7c1 100755--- a/app/Models/Setting.php+++ b/app/Models/Setting.php@@ -2,11 +2,13 @@namespace App\Models;use Illuminate\Database\Eloquent\Model;+use Illuminate\Notifications\Notifiable;use Watson\Validating\ValidatingTrait;use Schema;class Setting extends Model{+ use Notifiable;protected $injectUniqueIdentifier = true;use ValidatingTrait;@@ -143,4 +145,16 @@ class Setting extends Model}return $result;}++ /**+ * The url for slack notifications.+ * Used by Notifiable trait.+ * @return mixed+ */+ public function routeNotificationForSlack()+ {+ // At this point the endpoint is the same for everything.+ // In the future this may want to be adapted for individual notifications.+ return $this->slack_endpoint;+ }}diff --git a/app/Notifications/CheckinNotification.php b/app/Notifications/CheckinNotification.phpnew file mode 100644index 0000000000..bfbad40d21--- /dev/null+++ b/app/Notifications/CheckinNotification.php@@ -0,0 +1,96 @@+<?php++namespace App\Notifications;++use App\Models\Setting;+use Illuminate\Bus\Queueable;+use Illuminate\Notifications\Messages\SlackMessage;+use Illuminate\Notifications\Notification;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Notifications\Messages\MailMessage;++class CheckinNotification extends Notification+{+ use Queueable;+ /**+ * @var+ */+ private $params;++ /**+ * Create a new notification instance.+ *+ * @param $params+ */+ public function __construct($params)+ {+ //+ $this->params = $params;+ }++ /**+ * Get the notification's delivery channels.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function via($notifiable)+ {+ $notifyBy = [];+ if(Setting::getSettings()->slack_endpoint) {+ $notifyBy[] = 'slack';+ }+ $item = $this->params['item'];+ if (+ (method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))+ || (method_exists($item, 'getEula') && ($item->getEula()))+ ) {+ $notifyBy[] = 'mail';+ }+ return $notifyBy;+ }++ public function toSlack($notifiable)+ {+ return (new SlackMessage)+ ->success()+ ->content(class_basename(get_class($this->params['item'])) . " Checked In")+ ->attachment(function ($attachment) use ($notifiable) {+ $item = $this->params['item'];+ $admin_user = $this->params['admin'];+ $fields = [+ 'By' => '<'.$admin_user->present()->viewUrl().'|'.$admin_user->present()->fullName().'>',+ ];+ array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note'];++ $attachment->title($item->name, $item->present()->viewUrl() )+ ->fields($fields);+ });+ }+ /**+ * Get the mail representation of the notification.+ *+ * @param mixed $notifiable+ * @return \Illuminate\Notifications\sMessages\MailMessage+ */+ 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!');+ }++ /**+ * Get the array representation of the notification.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function toArray($notifiable)+ {+ return [+ //+ ];+ }+}diff --git a/app/Notifications/CheckoutNotification.php b/app/Notifications/CheckoutNotification.phpnew file mode 100644index 0000000000..c0fbc5c384--- /dev/null+++ b/app/Notifications/CheckoutNotification.php@@ -0,0 +1,101 @@+<?php++namespace App\Notifications;++use App\Models\Setting;+use App\Models\SnipeModel;+use Illuminate\Bus\Queueable;+use Illuminate\Notifications\Messages\SlackMessage;+use Illuminate\Notifications\Notification;+use Illuminate\Contracts\Queue\ShouldQueue;+use Illuminate\Notifications\Messages\MailMessage;++class CheckoutNotification extends Notification+{+ use Queueable;+ /**+ * @var+ */+ private $params;++ /**+ * Create a new notification instance.+ *+ * @param $params+ */+ public function __construct($params)+ {+ //+ $this->params = $params;+ }++ /**+ * Get the notification's delivery channels.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function via($notifiable)+ {+ $notifyBy = [];+ if(Setting::getSettings()->slack_endpoint) {+ $notifyBy[] = 'slack';+ }+ $item = $this->params['item'];++ if (+ (method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))+ || (method_exists($item, 'getEula') && ($item->getEula()))+ ) {+ $notifyBy[] = 'mail';+ }+ return $notifyBy;+ }++ public function toSlack($notifiable)+ {++ return (new SlackMessage)+ ->success()+ ->content(class_basename(get_class($this->params['item'])) . " Checked Out")+ ->attachment(function ($attachment) use ($notifiable) {+ $item = $this->params['item'];+ $admin_user = $this->params['admin'];+ $target = $this->params['target'];+ $fields = [+ 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',+ 'By' => '<'.$admin_user->present()->viewUrl().'|'.$admin_user->present()->fullName().'>'+ ];+ array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note'];++ $attachment->title($item->name, $item->present()->viewUrl() )+ ->fields($fields);+ });+ }+ /**+ * Get the mail representation of the notification.+ *+ * @param mixed $notifiable+ * @return \Illuminate\Notifications\Messages\MailMessage+ */+ 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!');+ }++ /**+ * Get the array representation of the notification.+ *+ * @param mixed $notifiable+ * @return array+ */+ public function toArray($notifiable)+ {+ return [+ //+ ];+ }+}diff --git a/app/Presenters/AccessoryPresenter.php b/app/Presenters/AccessoryPresenter.phpindex 56d1992be3..0e8b5c7997 100644--- a/app/Presenters/AccessoryPresenter.php+++ b/app/Presenters/AccessoryPresenter.php@@ -159,4 +159,13 @@ class AccessoryPresenter extends Presenter{return (string) link_to_route('accessories.show', $this->name, $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('accessories.show', $this->id);+ }}diff --git a/app/Presenters/AssetModelPresenter.php b/app/Presenters/AssetModelPresenter.phpindex 23268a3d11..299bb272df 100644--- a/app/Presenters/AssetModelPresenter.php+++ b/app/Presenters/AssetModelPresenter.php@@ -115,4 +115,13 @@ class AssetModelPresenter extends Presenter}return '';}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('models.show', $this->id);+ }}diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.phpindex 56596c6144..9d3760ef54 100644--- a/app/Presenters/AssetPresenter.php+++ b/app/Presenters/AssetPresenter.php@@ -56,9 +56,11 @@ class AssetPresenter extends Presenter}} else {- if (Gate::allows('checkin', $this->model)) {- $inout = '<a href="' . route('checkin/hardware',- $this->model->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';+ if (!empty($this->model->assigned_to)) {+ if (Gate::allows('checkin', $this->model)) {+ $inout = '<a href="' . route('checkin/hardware',+ $this->model->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';+ }}}@@ -202,6 +204,14 @@ class AssetPresenter extends Presenter}}+ /**+ * Helper for notification polymorphism.+ * @return mixed+ */+ public function fullName()+ {+ return $this->name();+ }/*** Returns the date this item hits EOL.* @return false|string@@ -247,4 +257,13 @@ class AssetPresenter extends Presenterdate_add($date, date_interval_create_from_date_string($this->warranty_months . ' months'));return date_format($date, 'Y-m-d');}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('hardware.show', $this->id);+ }}diff --git a/app/Presenters/CategoryPresenter.php b/app/Presenters/CategoryPresenter.phpindex 2c50720a9f..0ce206612e 100644--- a/app/Presenters/CategoryPresenter.php+++ b/app/Presenters/CategoryPresenter.php@@ -45,4 +45,13 @@ class CategoryPresenter extends Presenter{return (string) link_to_route('categories.show', $this->name, $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('categories.show', $this->id);+ }}diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.phpindex 3b5e472176..df523d5f5d 100644--- a/app/Presenters/CompanyPresenter.php+++ b/app/Presenters/CompanyPresenter.php@@ -17,4 +17,13 @@ class CompanyPresenter extends Presenter{return (string) link_to_route('companies.show', $this->name, $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('companies.show', $this->id);+ }}diff --git a/app/Presenters/ComponentPresenter.php b/app/Presenters/ComponentPresenter.phpindex 439f7bc782..e2517f29c7 100644--- a/app/Presenters/ComponentPresenter.php+++ b/app/Presenters/ComponentPresenter.php@@ -68,4 +68,12 @@ class ComponentPresenter extends Presenter{return (string) link_to_route('components.show', $this->name, $this->id);}+ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('components.show', $this->id);+ }}diff --git a/app/Presenters/ConsumablePresenter.php b/app/Presenters/ConsumablePresenter.phpindex be8f09931c..cd91ce9d2c 100644--- a/app/Presenters/ConsumablePresenter.php+++ b/app/Presenters/ConsumablePresenter.php@@ -66,4 +66,13 @@ class ConsumablePresenter extends Presenter{return (string)link_to_route('consumables.show', $this->name, $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('consumables.show', $this->id);+ }}diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.phpindex a761864558..d76deff97e 100644--- a/app/Presenters/LicensePresenter.php+++ b/app/Presenters/LicensePresenter.php@@ -84,4 +84,13 @@ class LicensePresenter extends Presenter{return (string) link_to('/licenses/'.$this->id, mb_strimwidth($this->serial, 0, 50, "..."));}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('licenses.show', $this->id);+ }}diff --git a/app/Presenters/LocationPresenter.php b/app/Presenters/LocationPresenter.phpindex 214a301b9a..5b751f6b48 100644--- a/app/Presenters/LocationPresenter.php+++ b/app/Presenters/LocationPresenter.php@@ -55,4 +55,13 @@ class LocationPresenter extends Presenter{return (string)link_to_route('locations.show', $this->name, $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('locations.show', $this->id);+ }}diff --git a/app/Presenters/ManufacturerPresenter.php b/app/Presenters/ManufacturerPresenter.phpindex e695b55cb9..5922952289 100644--- a/app/Presenters/ManufacturerPresenter.php+++ b/app/Presenters/ManufacturerPresenter.php@@ -50,4 +50,13 @@ class ManufacturerPresenter extends Presenter{return (string) link_to_route('manufacturers.show', $this->name, $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('manufacturers.show', $this->id);+ }}diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.phpindex 0d17aa2836..6806de68c8 100644--- a/app/Presenters/UserPresenter.php+++ b/app/Presenters/UserPresenter.php@@ -138,4 +138,13 @@ class UserPresenter extends Presenter{return (string) link_to_route('users.show', $this->fullName(), $this->id);}++ /**+ * Url to view this item.+ * @return string+ */+ public function viewUrl()+ {+ return route('users.show', $this->id);+ }}diff --git a/resources/views/licenses/checkout.blade.php b/resources/views/licenses/checkout.blade.phpindex cd8e7896a9..05b3de5502 100755--- a/resources/views/licenses/checkout.blade.php+++ b/resources/views/licenses/checkout.blade.php@@ -27,7 +27,7 @@<div class="box box-default"><div class="box-header with-border">- <h3 class="box-title"> {{ $licenseseat->license->name }}</h3>+ <h3 class="box-title"> {{ $licenseSeat->license->name }}</h3></div><div class="box-body">@@ -37,7 +37,7 @@<div class="form-group"><label class="col-sm-2 control-label">{{ trans('admin/hardware/form.name') }}</label><div class="col-md-6">- <p class="form-control-static">{{ $licenseseat->license->name }}</p>+ <p class="form-control-static">{{ $licenseSeat->license->name }}</p></div></div>@@ -45,7 +45,7 @@<div class="form-group"><label class="col-sm-2 control-label">{{ trans('admin/hardware/form.serial') }}</label><div class="col-md-10">- <p class="form-control-static" style="word-wrap: break-word;">{{ $licenseseat->license->serial }}</p>+ <p class="form-control-static" style="word-wrap: break-word;">{{ $licenseSeat->license->serial }}</p></div></div>@@ -55,7 +55,7 @@</label><div class="col-md-10">- {{ Form::select('asset_id', $asset_list , Input::old('asset_id', $licenseseat->asset_id), array('class'=>'select2', 'style'=>'min-width:600px')) }}+ {{ Form::select('asset_id', $asset_list , Input::old('asset_id', $licenseSeat->asset_id), array('class'=>'select2', 'style'=>'min-width:600px')) }}{!! $errors->first('asset_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}</div></div>@@ -67,7 +67,7 @@</label><div class="col-md-9">- {{ Form::select('assigned_to', $users_list , Input::old('assigned_to', $licenseseat->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }}+ {{ Form::select('assigned_to', $users_list , Input::old('assigned_to', $licenseSeat->assigned_to), array('class'=>'select2', 'style'=>'min-width:350px')) }}{!! $errors->first('assigned_to', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}<p class="help-block">@@ -82,7 +82,7 @@<div class="form-group {{ $errors->has('note') ? 'error' : '' }}"><label for="note" class="col-md-2 control-label">{{ trans('admin/hardware/form.notes') }}</label><div class="col-md-7">- <textarea class="col-md-6 form-control" id="note" name="note">{{ Input::old('note', $licenseseat->note) }}</textarea>+ <textarea class="col-md-6 form-control" id="note" name="note">{{ Input::old('note', $licenseSeat->note) }}</textarea>{!! $errors->first('note', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}</div></div>