/** * Execute the console command. * * @return mixed */ public function handle() { $notification = $this->notification->where('slug', $this->argument('notification'))->first(); if (!$notification) { $this->error('Invalid notification provided.'); return 1; } $users = $notification->subscribers; if (!count($users)) { $this->error('No subscribers to send to!'); return 1; } if (method_exists($this, $notification->slug)) { $users = $this->{$notification->slug}($users); } if ($this->option('pretend')) { $this->info('Notification ' . $notification->name . ' would be sent to the following subscribers:'); foreach ($users as $user) { $this->line($user->name . ' <' . $user->email . '>'); } return 0; } foreach ($users as $user) { Mail::queue('emails.notifications.' . $notification->template, ['user' => $user], function ($message) use($user, $notification) { $message->to($user->email, $user->name); $message->subject($notification->subject); }); $this->info('Queued notification for ' . $user->name . ' <' . $user->email . '>'); } return 0; }
public function index() { $logged_user_id = Auth::user()->id; $users = User::find($logged_user_id); $notification = Notification::where('user_id', $logged_user_id)->orderBy('created_at', 'desc')->paginate(5); return View::make('notification')->with('users', $users)->with('notification', $notification); }
public function notifications(View $view) { //Fetch all notifications for this user alone $notifications = Notification::where('user_id', auth()->user()->id)->paginate(3); $data = ['notifications' => $notifications]; $view->with($data); }
/** * @return \Illuminate\View\View */ public function notification() { //Fetch all notifications for this user alone $notifications = Notification::where('user_id', auth()->user()->id)->paginate(10); $data = ['notifications' => $notifications]; return view('frontend.user.notification', $data); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $notifications = Notification::where('user_id', Auth::user()->id)->orderBy('id', 'desc')->paginate(10); $toUpdate = Notification::where('user_id', Auth::user()->id)->where('new', 1)->get(); foreach ($toUpdate as $n) { $n->new = 0; $n->save(); } return view('notifications.index', compact('notifications')); }
public function testNotificationDelete() { $admin = User::find(1); $notification = new Notification(); $notification->title = "Test title 123"; $notification->type = "Alarm test"; $notification->notes = "Test property "; $notification->data = "Test data "; $notification->save(); $savedNotification = Notification::where('title', '=', 'Test title 123')->first(); $this->actingAs($admin)->withSession(['foo' => 'bar'])->visit($this->modelUrl . (string) $savedNotification->id)->press('Delete')->seePageIs($this->modelUrl); }
public static function read($user_id, $unread = true, int $limit = 500, $paginate = false) { if ($unread === true) { $notifications = Notification::where('user_id', $user_id)->where('is_read', 0)->orderBy('id', 'desc'); } else { $notifications = Notification::where('user_id', $user_id)->orderBy('id', 'desc'); } if (is_numeric($paginate) && $paginate > 0) { $notifications = $notifications->paginate($paginate); } else { $notifications = $notifications->limit($limit)->get(); } return $notifications; }
public function compose(View $view) { $array_task = []; $array_alert = []; $array_notification = []; $tasks_count = 0; $alerts_count = 0; $notifications_count = 0; //menus $packages = Package::with('modules')->get(); //datas of the user logged $userAuth = Sentinel::getUser(); $today = Carbon::now(); // tareas $tasks = Task::where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id)->orderBy('created_at', 'DESC')->get(); foreach ($tasks as $task) { if (is_null($task->read)) { array_push($array_task, $task); $tasks_count++; } elseif (!in_array($userAuth->id, unserialize($task->read))) { array_push($array_task, $task); $tasks_count++; } } // alertas $alerts = Task::where('expire_time', '<', $today)->Where(function ($query) use($userAuth) { $query->where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id); })->with('hasAlert')->get(); foreach ($alerts as $alert) { if (is_null($alert->hasAlert[0]->alert_display)) { array_push($array_alert, $alert); $alerts_count++; } elseif (!in_array($userAuth->id, unserialize($alert->hasAlert[0]->alert_display))) { array_push($array_alert, $alert); $alerts_count++; } } // notifications $notifications = Notification::where('user_id', '=', $userAuth->id)->orwhere('role_id', '=', $userAuth->roles[0]->id)->get(); foreach ($notifications as $notification) { if (is_null($notification->read)) { array_push($array_notification, $notification); $notifications_count++; } elseif (!in_array($userAuth->id, unserialize($notification->read))) { array_push($array_notification, $notification); $notifications_count++; } } $view->with(array('packages' => $packages, 'userAuth' => $userAuth, 'alerts' => $array_alert, 'alerts_count' => $alerts_count, 'notifications' => $array_notification, 'notifications_count' => $notifications_count, 'tasks' => $array_task, 'tasks_count' => $tasks_count)); }
/** * @return $this|\Illuminate\View\View */ public function getNotifications() { // $user = Sentinel::getUser(); $user_id = $user->id; $array_notification = []; // notifications $notifications = Notification::where('user_id', '=', $user->id)->orwhere('role_id', '=', $user->roles[0]->id)->get(); foreach ($notifications as $notification) { if (is_null($notification->status)) { array_push($array_notification, $notification); } elseif (!in_array($user->id, unserialize($notification->status))) { array_push($array_notification, $notification); } } return view('notifications.notifications.index', compact('array_notification', 'user_id')); }
/** * 更新消息 * * @return void */ public function store() { // get params & validate $id = Request::get('id'); $message = Request::get('message'); $durationAt = Request::get('duration_at'); $state = Request::get('state'); $redirectUrl = Request::get('_redirect_url'); $rules = ['message' => 'required|max:500', 'duration_at' => 'required|date', 'state' => 'required|in:0,1']; $validator = Validator::make(Request::all(), $rules); if ($validator->fails()) { return Redirect::to($redirectUrl)->with('error', '保存失败~'); } // save $data = ['message' => $message, 'duration_at' => $durationAt, 'state' => $state]; if ($id) { Notification::where('id', $id)->update($data); } else { Notification::create($data); } // redirect return Redirect::to($redirectUrl)->with('success', '保存成功~'); }
/** * Bootstrap the application services. * * @return void */ public function boot() { view()->composer('includes-update.header', function ($view) { $thanksCount = 0; $followCount = 0; if (Auth::user()->identifier == 1 || Auth::user()->identifier == 3) { $user = Induser::where('id', '=', Auth::user()->induser_id)->first(); $favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']); $thanksCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.thanks'); $linksCount = Connections::where('user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->orWhere('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 1)->count('id'); $linkrequestCount = Connections::where('connection_user_id', '=', Auth::user()->induser_id)->where('status', '=', 0)->count('id'); $groupCount = Groups_users::where('user_id', '=', Auth::user()->induser_id)->count('id'); $postCount = Postjob::where('individual_id', '=', Auth::user()->induser_id)->count('id'); $profilePer = 0; if (Auth::user()->induser->fname != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->lname != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->email != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->mobile != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->dob != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->city != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->fb_page != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->in_page != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->gender != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->about_individual != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->education != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->experience != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->working_status != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->working_at != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->role != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->linked_skill != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->resume != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->prefered_location != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->prefered_jobtype != null) { $profilePer = $profilePer + 1; } if (Auth::user()->induser->profile_pic != null) { $profilePer = $profilePer + 1; } $profilePer = round($profilePer / 20 * 100); } else { if (Auth::user()->identifier == 2 || Auth::user()->identifier == 3) { $user = Corpuser::where('id', '=', Auth::user()->corpuser_id)->first(); $followCount = Follow::where('corporate_id', '=', 1)->orWhere('individual_id', '=', 1)->count('id'); $linksCount = ""; $linkrequestCount = ""; $groupCount = ""; $postCount = Postjob::where('corporate_id', '=', Auth::user()->corpuser_id)->count('id'); $favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']); $profilePer = 0; if (Auth::user()->corpuser->firm_name != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->username != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->firm_type != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->emp_count != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->working_as != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->slogan != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->firm_email_id != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->logo_status != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->about_firm != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->firm_address != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->operating_since != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->linked_skill != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->website_url != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->firm_phone != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->industry != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->role != null) { $profilePer = $profilePer + 1; } if (Auth::user()->corpuser->city != null) { $profilePer = $profilePer + 1; } $profilePer = round($profilePer / 17 * 100); } } $view->with('session_user', $user)->with('favourites', $favourites)->with('thanksCount', $thanksCount)->with('followCount', $followCount)->with('profilePer', $profilePer)->with('linkrequest', $linkrequestCount)->with('linkCount', $linksCount)->with('groupCount', $groupCount)->with('postCount', $postCount); }); view()->composer('includes-update.header', function ($view) { if (Auth::user()->identifier == 1 || Auth::user()->identifier == 2 || Auth::user()->identifier == 3) { $applications = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.apply', '=', 1)->orderBy('postactivities.id', 'desc')->take(5)->get(['postactivities.id', 'postjobs.unique_id', 'postactivities.apply', 'postactivities.apply_dtTime', 'postactivities.user_id', 'postactivities.post_id']); $thanks = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->take(5)->get(); $favourites = Postactivity::with('user')->where('fav_post', '=', 1)->where('user_id', '=', Auth::user()->id)->orderBy('id', 'desc')->get(['id', 'fav_post', 'fav_post_dtTime', 'user_id', 'post_id']); $thanksCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.thanks', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.thanks'); $applicationsCount = Postactivity::with('user', 'post')->join('postjobs', 'postjobs.id', '=', 'postactivities.post_id')->where('postjobs.individual_id', '=', Auth::user()->induser_id)->where('postactivities.apply', '=', 1)->orderBy('postactivities.id', 'desc')->sum('postactivities.apply'); $notifications = Notification::with('fromUser', 'toUser')->where('to_user', '=', Auth::user()->id)->orderBy('id', 'desc')->take(5)->get(); $notificationsCount = Notification::where('to_user', '=', Auth::user()->id)->where('view_status', '=', 0)->count(); } $view->with('applications', $applications)->with('thanks', $thanks)->with('favourites', $favourites)->with('thanksCount', $thanksCount)->with('applicationsCount', $applicationsCount)->with('notifications', $notifications)->with('notificationsCount', $notificationsCount); }); }
/** * Function that gets number of notifications. * * @return Response */ public function notificationNumber() { // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(array()); } $notifications = Notification::where('UserId', '=', Auth::user()->Id)->orderBy('Created', 'DES')->take(30)->get(); $unloaded = 0; foreach ($notifications as $notification) { if (!$notification->Loaded) { $unloaded++; } } // Return response. $response['state'] = 'Success'; $response['number'] = $unloaded; return response()->json($response); }
/** * Edit notification message. * * @param EditNotificationMessageRequest $request * @param AjaxResponse $response * @return mixed */ public function editMessage(EditNotificationMessageRequest $request, AjaxResponse $response) { Notification::where('id', $request->get('notification_id'))->update(['message' => $request->get('notification_message')]); $response->setSuccessMessage(trans('notifications.notification_message_updated')); return response($response->get())->header('Content-Type', 'application/json'); }
public function downvote($id) { if (Request::ajax()) { $post = Post::find($id); $_upvote_handle = Vote::where('object_id', '=', Auth::id())->where('type', '=', 'upvote')->where('post_id', '=', $id)->first(); if ($_upvote_handle) { $_upvote_handle->delete(); $_notification_handle = Notification::where('type', '=', 'post')->where('object_id', '=', $id)->where('sender_id', '=', Auth::id())->where('user_id', '=', $post->author_id)->first(); $_notification_handle->delete(); } $post->newVote()->withType('downvote')->regarding(Auth::user())->deliver(); $user = Auth::user(); $post_author = User::find($post->author_id); $post_author->newNotification()->withType('post')->withSender($user->id)->withSubject($user->name . ' ' . $user->surname . ' downvoted your post.')->withBody('"' . $post->body . '"')->regarding($post)->deliver(); return array('data1' => $post->votes()->type('downvote')->get()->count(), 'data2' => $post->votes()->type('upvote')->get()->count()); } }
public function seen($id) { $notification = Notification::where('id', $id)->first(); $notification->seen = true; $notification->save(); }
public function RemoveCount($id) { $notificationCount = Notification::where('id', '=', $id)->update(['view_status' => 1]); $notificationCount->save(); return 'success'; }
//// event(new BookHasCreated('This is the new notification', time(), 'http://www.google.gr', Auth::user()->hash)); // event(new BookHasCreated( // 'Δημιουργία βιβλίου', // Carbon::now()->format('d-m-Y'), // 'http://library.gr/cPanel/products/6988045D0D/edit', // Auth::user()->myAdministratorHash() // )); // return 'done'; //}); Route::get('notifications', function () { $notifications = Auth::user()->adminNotifications(); return $notifications; }); Route::get('notification/makeRead/{barcode}', function ($barcode) { // ΕΧΩ ΑΜΦΙΒΟΛΙΑ ΓΙΑ ΤΟ GET OR POST Notification::where('barcode', $barcode)->delete(); }); //Route::get('products/unpublished', ['middleware'=> 'acl:show_my_unpublished','uses'=> 'BooksController@unpublished']); //Route::get('unpublished/{barcode?}/edit', 'BooksController@editUnpublished'); Route::resource('unpublished', 'Admin\\UnpublishedController'); /* * ********************************* * D A S H B O A R D R O U T E S * * ********************************* */ Route::group(['prefix' => 'cPanel', 'as' => 'Admin::'], function () { Route::get('/', ['as' => 'home', 'uses' => 'Admin\\AdminController@main']); Route::get('cPanel/users-table', ['as' => 'allUsers', 'uses' => 'Admin\\AdminController@allUsers']); Route::group(['prefix' => 'unpublished', 'as' => 'Unpublished::'], function () { Route::get('/', ['as' => 'index', 'uses' => 'Admin\\UnpublishedController@allUnpublished']); Route::post('/', ['as' => 'index.post', 'uses' => 'Admin\\UnpublishedController@postUnpublished']);
public function countNotification($user) { $notification = Notification::where('recipient', $user)->where('read', 0)->count(); return $notification; }
public function index() { $notifications = Notification::where('user_id', Auth::user()->id)->get(); return response($notifications); }
<script type="text/javascript"> $(document).ready(function() { $('#hamburger_menu').click(function () { $('#desnimeni').toggleClass('open'); }); }); </script> <div class="container"> @yield('content') </div> @if(\Auth::user()) <?php $notifications = \App\Notification::where('to', '=', \Auth::user()->id)->get(); ?> @foreach($notifications as $notification) <script> toastr.options.showMethod = 'slideDown'; toastr.options.timeOut = 15000; toastr.options.onclick =function(){window.location="{{URL::to('/chat')}}";}; toastr.info("{{ \App\User::findOrFail($notification->from)->username }} sent you a new message {{ $notification->created_at }}", null, {"positionClass": "toast-bottom-left"}); </script> <?php $notification->delete(); ?> @endforeach <script> function notificationz(data) {
public function getIndex() { $user = \Auth::user(); $notifications = Notification::where('enabled', true)->get(); return view('front.pages.profile')->with(['user' => $user, 'notifications' => $notifications])->render(); }
public function store_like(Request $request) { $num_like = $this->user->likes()->where('product_id', $request->product_id)->count(); $product = Product::find($request->product_id); if ($num_like == 0) { if ($this->user->id != $product->author->id) { $notification = new Notification(); $notification->product_id = $request->product_id; $notification->actor_id = $this->user->id; $notification->receiver_id = $product->author->id; $notification->type = 0; $notification->save(); $data = array("message" => $notification->actor->name . " đã thích bài viết của bạn", "link" => url('bai-tap-colorme?id=' . $notification->product_id), 'created_at' => format_date_full_option($notification->created_at), "receiver_id" => $notification->receiver_id); $publish_data = array("event" => "notification", "data" => $data); Redis::publish('colorme-channel', json_encode($publish_data)); } $product->rating += 1; $like = new Like(); $like->product_id = $request->product_id; $like->liker_id = $this->user->id; $like->save(); $like_id = $like->id; } else { $like_id = $this->user->likes()->where('product_id', $request->product_id)->first()->id; $like = Like::find($like_id); $like->delete(); $like_id = -1; $product->rating -= 1; Notification::where('product_id', $product->id)->where('actor_id', $this->user->id)->first()->delete(); } $total_likes = $product->likes()->count(); $product->save(); $return_data = new \stdClass(); $return_data->total_likes = $total_likes; $return_data->like_id = $like_id; return json_encode($return_data); }
<?php use App\Notification; use App\Worker; use App\Branch; $notifications = Notification::where('UserId', '=', Auth::user()->Id)->orderBy('Created', 'DES')->take(300)->get(); $unseen = 0; foreach ($notifications as $notification) { $notification->Loaded = true; $notification->save(); if (!$notification->Seen) { $unseen++; } } ?> <div class="dropdown"> <a class="notification-bell" data-toggle="dropdown" href="#"> <i class="icon-bell"></i> <p id="notification-total"> @if($unseen > 0) {{ $unseen }} @endif </p> </a> {{ Worker::find(Auth::user()->TypeId)->branch->Name }} <ul class="dropdown-menu" id="notifications" role="menu" aria-labelledby="dLabel"> <div id="notification-heading"> <h4 id="menu-title">Notificaciones</h4> </div>
/** * Execute the console command. * * @return mixed */ public function handle() { $deleted = Notification::where('created_at', '<=', Carbon::now()->subHours(6))->delete(); Log::info(sprintf('Notifications deleted %d.', $deleted)); }
/** * Update targeted users group for given $notificationId. * * @param string $group * @param int $notificationId */ private static function _updateTargetGroup($group, $notificationId) { Notification::where('id', $notificationId)->update(['targeted_user_id' => TargetedUser::where('name', $group)->first()->id]); }
public function clearNotifications(Request $request) { $username = $request->username; try { $id = User::where('username', $username)->get()[0]->id; Notification::where('user_id2', $id)->where('readnotification', 0)->update(['readnotification' => 1]); return response()->json(['status' => 200, 'done' => true], 200); } catch (QueryException $e) { return response()->json(['status' => 200], 200); } }
/** * unlike a visitor's profile handles POST request. * * @param object $request * * * @return json */ public function unlike(Request $request) { $unlikedUsername = $request->unlikedUsername; $gotunLikedUsername = $request->gotunLikedUsername; try { $result1 = Likes::where('user1', $unlikedUsername)->where('user2', $gotunLikedUsername)->get(); $result2 = Likes::where('user1', $gotunLikedUsername)->where('user2', $unlikedUsername)->get(); if ($result1 !== null && $result2 !== null) { Likes::where('user1', $unlikedUsername)->where('user2', $gotunLikedUsername)->delete(); $user_id1 = User::where('username', $unlikedUsername)->get()[0]->id; $user_id2 = User::where('username', $gotunLikedUsername)->get()[0]->id; Notification::where('user_id1', $user_id1)->where('user_id2', $user_id2)->where('content', 'like')->delete(); return response()->json(['status' => 200], 200); } else { return response()->json(['status' => 200], 200); } } catch (Illuminate\Database\QueryException $e) { return response()->json(['status' => 200], 200); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function rejectBookRequest($requestId) { $request = \App\RequestBookClubBook::findOrFail($requestId); if (!$request) { flash()->warning('Request already processed. '); return redirect()->back(); } \App\Notification::where('request_id', $requestId)->first()->delete(); $notification = $request->requestee->notifications()->create(['text' => 'Your request for ' . $request->book->title . ' from BookClub ' . $request->bookclub->name . ' was rejected or canceled.', 'url' => route('notifications.destroy', 1), 'is_read' => false]); $notification->url = route('notifications.destroy', $notification->id); $notification->save(); // dd($notification); $request->delete(); //generate Notification later extract and make use of events flash('Request Rejected succesfully.'); return redirect()->back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $shame = Shame::findOrFail($id); if (Auth::check() && Auth::user()->id == $shame->user_id) { $shame->tags()->detach(); $shame->upvotes()->detach(); $shame->follows()->detach(); $notifications = Notification::where('shame_id', '=', $id)->get(); foreach ($notifications as $notification) { $notification->delete(); } $comments = Comment::where('shame_id', '=', $id)->with('upvotes')->get(); foreach ($comments as $comment) { $comment->upvotes()->detach(); $comment->delete(); } $shame->delete(); } return redirect()->route('shames.index'); }
public function postDrop() { Notification::where('to', '=', \Auth::user()->id)->delete(); }