diff --git a/app/Http/Controllers/Common/NotificationController.php b/app/Http/Controllers/Common/NotificationController.php index 635b8e2ed..c281878e2 100644 --- a/app/Http/Controllers/Common/NotificationController.php +++ b/app/Http/Controllers/Common/NotificationController.php @@ -7,12 +7,11 @@ use App\Model\helpdesk\Notification\Notification; use App\Model\helpdesk\Notification\UserNotification; use App\User; -class NotificationController extends Controller -{ +class NotificationController extends Controller { + public $user; - public function __construct() - { + public function __construct() { $user = new User(); $this->user = $user; } @@ -22,8 +21,7 @@ class NotificationController extends Controller * * @return response */ - public static function getNotifications() - { + public static function getNotifications() { $notifications = UserNotification::join('notifications', 'user_notification.notification_id', '=', 'notifications.id') ->join('notification_types', 'notifications.type_id', '=', 'notification_types.id') ->where('user_notification.user_id', '=', \Auth::user()->id) @@ -32,14 +30,13 @@ class NotificationController extends Controller return $notifications; } - public function create($model_id, $userid_created, $type_id, $forwhome = []) - { + public function create($model_id, $userid_created, $type_id, $forwhome = []) { try { if (empty($forwhome)) { $forwhome = $this->user->where('role', '!=', 'user')->get()->toArray(); } - //dd($forwhome); - //system notification + //dd($forwhome); + //system notification $notification = new Notification(); $UN = new UserNotification(); @@ -52,8 +49,16 @@ class NotificationController extends Controller } } - public function markRead($id) - { + public function markAllRead($id) { + $markasread = UserNotification::where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get(); + foreach ($markasread as $mark) { + $mark->is_read = '1'; + $mark->save(); + } + return 1; + } + + public function markRead($id) { $markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->where('is_read', '=', '0')->get(); foreach ($markasread as $mark) { $mark->is_read = '1'; @@ -63,15 +68,13 @@ class NotificationController extends Controller return 1; } - public function show() - { + public function show() { $notifications = $this->getNotifications(); return view('notifications-all', compact('notifications')); } - public function delete($id) - { + public function delete($id) { $markasread = UserNotification::where('notification_id', '=', $id)->where('user_id', '=', \Auth::user()->id)->get(); foreach ($markasread as $mark) { $mark->delete(); @@ -79,4 +82,5 @@ class NotificationController extends Controller return 1; } + } diff --git a/app/Http/routes.php b/app/Http/routes.php index 78c66ffb6..5b8e74b90 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -33,6 +33,7 @@ Route::group(['middleware' => 'roles', 'middleware' => 'auth', 'middleware' => ' //Notification marking Route::post('mark-read/{id}', 'Common\NotificationController@markRead'); + Route::post('mark-all-read/{id}', 'Common\NotificationController@markAllRead'); Breadcrumbs::register('notification.list', function ($breadcrumbs) { $breadcrumbs->parent('dashboard'); $breadcrumbs->push('All Notifications', route('notification.list')); @@ -676,7 +677,7 @@ Route::get('/change-file-permission', ['as' => 'change-permission', 'uses' => 'I |============================================================= | Cron Job links |============================================================= - | These links are for cron job execution + | These links are for cron job execution | */ Route::get('readmails', ['as' => 'readmails', 'uses' => 'Agent\helpdesk\MailController@readmails']); diff --git a/resources/views/notifications-all.blade.php b/resources/views/notifications-all.blade.php index 029cd2b4c..67ac2fde1 100644 --- a/resources/views/notifications-all.blade.php +++ b/resources/views/notifications-all.blade.php @@ -122,7 +122,7 @@ class="active" -   +   {!! $notification->message !!} {{ $notification -> created_at }} @@ -139,7 +139,7 @@ class="active" -   +   {!! $notification->message !!} {{ $notification -> created_at }} @@ -156,7 +156,7 @@ class="active" model_id)->first(); ?> -   +   {!! $notification->message !!} with id "{!!$ticket_number->ticket_number!!}" {{ $notification -> created_at }} @@ -168,7 +168,7 @@ class="active" model_id)->first(); ?> -   +   {!! $notification->message !!} with id "{!!$ticket_number->ticket_number!!}" {{ $notification -> created_at }} diff --git a/resources/views/themes/default1/admin/layout/admin.blade.php b/resources/views/themes/default1/admin/layout/admin.blade.php index fec612d3f..5dd6e432b 100644 --- a/resources/views/themes/default1/admin/layout/admin.blade.php +++ b/resources/views/themes/default1/admin/layout/admin.blade.php @@ -42,19 +42,17 @@ @yield('HeadInclude') - @@ -71,15 +69,15 @@ - + @if($replacetop==0) {!! Lang::get('lang.home') !!} @endif - - + + id)->where('is_read', '0')->get(); ?> @@ -90,97 +88,95 @@ {!! count($noti) !!} - - + + - × - Alert! - - - + × + Alert! + + + - You have {!! count($noti) !!} notifications. Mark all as read. - - - @foreach($notifications as $notification) - user_id)->first(); ?> - @if($notification->type == 'registration') - @if($notification->is_read == 1) -   + You have {!! count($noti) !!} notifications. Mark all as read. + + + @foreach($notifications as $notification) + user_id)->first(); ?> + @if($notification->type == 'registration') + @if($notification->is_read == 1) +   {!! $notification->message !!} - - @else -   + + @else +   {!! $notification->message !!} - - @endif - @else - - model_id)->first(); ?> - @if($notification->is_read == 1) -   - - {!! $notification->message !!} with id "{!!$ticket_number->ticket_number!!}" - - - @else -   - - {!! $notification->message !!} with id "{!!$ticket_number->ticket_number!!}" - - - @endif - @endif - @endforeach - - - - - - - View all - - - - - - - @if(Auth::user()) - - - - {!! Auth::user()->first_name." ".Auth::user()->last_name !!} - @endif - - - - - @if(Auth::user()) - - - {!! Auth::user()->first_name !!}{!! " ". Auth::user()->last_name !!} - {{Auth::user()->role}} - - + @endif - - - - - {!! Lang::get('lang.profile') !!} - - - {!! Lang::get('lang.sign_out') !!} - - - + @else + + model_id)->first(); ?> + @if($notification->is_read == 1) +   + + {!! $notification->message !!} with id "{!!$ticket_number->ticket_number!!}" + + + @else +   + + {!! $notification->message !!} with id "{!!$ticket_number->ticket_number!!}" + + + @endif + @endif + @endforeach + + + + + + View all + + + + + + + @if(Auth::user()) + + + + {!! Auth::user()->first_name." ".Auth::user()->last_name !!} + @endif + + + + + @if(Auth::user()) + + + {!! Auth::user()->first_name !!}{!! " ". Auth::user()->last_name !!} - {{Auth::user()->role}} + + + @endif + + + + + {!! Lang::get('lang.profile') !!} + + + {!! Lang::get('lang.sign_out') !!} + + + + @@ -310,7 +306,8 @@ {!! Lang::get('lang.Updates') !!} - first(); + first(); if ($update->current_version == $update->new_version) { ?> @@ -329,7 +326,7 @@ @endif - + @@ -388,7 +385,7 @@ - + + diff --git a/resources/views/themes/default1/agent/layout/agent.blade.php b/resources/views/themes/default1/agent/layout/agent.blade.php index 7fde8f84e..7097652ff 100644 --- a/resources/views/themes/default1/agent/layout/agent.blade.php +++ b/resources/views/themes/default1/agent/layout/agent.blade.php @@ -102,9 +102,7 @@ {!! count($noti) !!} - + × diff --git a/resources/views/themes/default1/client/layout/client.blade.php b/resources/views/themes/default1/client/layout/client.blade.php index a728fa6af..0693b95b7 100644 --- a/resources/views/themes/default1/client/layout/client.blade.php +++ b/resources/views/themes/default1/client/layout/client.blade.php @@ -172,7 +172,7 @@ {!! Form::close() !!} - + @@ -184,7 +184,7 @@ - + @if(Session::has('success')) @@ -192,6 +192,13 @@ {{Session::get('success')}} @endif + @if(Session::has('warning')) + + + × + {!! Session::get('warning') !!} + + @endif @if(Session::has('fails')) @if(Session::has('check')) @@ -219,7 +226,7 @@ - + first(); @@ -250,7 +257,7 @@ {!!$footer2->title!!} - {!! $footer2->value !!} + {!! $footer2->value !!}
- {!! Auth::user()->first_name !!}{!! " ". Auth::user()->last_name !!} - {{Auth::user()->role}} - -
+ {!! Auth::user()->first_name !!}{!! " ". Auth::user()->last_name !!} - {{Auth::user()->role}} + +
{!! $footer2->value !!}