From ca82fa0b8a49d4656f20d4c295d42ba64f166bf4 Mon Sep 17 00:00:00 2001 From: Sujit Prasad Date: Tue, 14 Jun 2016 19:57:06 +0530 Subject: [PATCH] final commit --- .../Common/NotificationController.php | 36 ++- app/Http/routes.php | 3 +- resources/views/notifications-all.blade.php | 8 +- .../default1/admin/layout/admin.blade.php | 280 +++++++++--------- .../default1/agent/layout/agent.blade.php | 4 +- .../default1/client/layout/client.blade.php | 15 +- 6 files changed, 186 insertions(+), 160 deletions(-) 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" -