public function deleteNotify($id)
 {
     if (Notification::where('user_id', Auth::user()->id)->where('id', $id)->exists()) {
         $noty = Notification::find($id);
         $noty->delete();
     }
 }
Esempio n. 2
0
 public function ajax_notification()
 {
     $notice = Notification::where('user_id', '=', Auth::user()->id)->where('is_read', '=', 0)->get();
     foreach ($notice as $value) {
         $value->is_read = 1;
         $value->save();
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $notifications = Notification::where('show_from', '<', Carbon::now()->addMonth())->where('show_until', '>', Carbon::now()->subMonth())->orderby('important', 'desc')->orderby('updated_at', 'desc')->get();
     // $notifications = Notification::where('show_from', '<', Carbon::now())->where('show_until', '>', Carbon::now())->orderby('important', 'desc')->orderby('updated_at', 'desc')->get();
     $data['notifications'] = $notifications;
     // return View::make('notifications.dashboard')->with($data);
     return View::make('notifications.index')->with($data);
 }
Esempio n. 4
0
 public function index()
 {
     $notifications = Notification::where('user', '=', Auth::User()->id)->orderBy('id', 'desc')->take(5)->get();
     $count_notification = Notification::where('user', '=', Auth::User()->id)->where('read', '=', 0)->count();
     $user_details = array('surname' => Auth::User()->surname, 'name' => Auth::User()->name, 'avatar' => Auth::User()->avatar);
     $sidebar_adverts = DB::table('adverts')->join('advertisers', 'advertisers.id', '=', 'adverts.advertiser')->where('advertisers.id', '=', Auth::User()->advertiser)->select('adverts.name')->get();
     return View::make('profile')->with('user', $user_details)->with('notifications', $notifications)->with('sidebar_adverts', $sidebar_adverts)->with('count_notification', $count_notification);
 }
 public function getNotifications()
 {
     $notifications = Notification::where('user_id', '=', Auth::user()->id)->get();
     $validNotifications = Notification::getValidNotifications();
     $selectedNotifications = [];
     foreach ($notifications as $n) {
         $selectedNotifications[] = $n->event;
     }
     return View::make('dashboard.notifications', compact('selectedNotifications', 'validNotifications'));
 }
 public function markread(Request $request)
 {
     //$id = Auth::User()->id;
     $id = 24;
     $notifications = Notification::where('user_id', '=', $id)->get();
     foreach ($notifications as $notification) {
         $notification->is_read = 0;
         $notification->save();
     }
 }
Esempio n. 7
0
 public function sysnotify()
 {
     if (!Auth::check()) {
         Redirect::intended('/');
     }
     $notifications = Notification::where('type', '<>', 'new_reply')->where('user_id', '=', Auth::user()->id)->get();
     $userID = Auth::user()->id;
     $notifications->sysNotifyCount = Notification::WithNoType('new_reply')->ToWhom($userID)->count();
     $notifications->repliesCount = Notification::WithType('new_reply')->ToWhom($userID)->count();
     return View::make('account.notify', compact('notifications'));
 }
Esempio n. 8
0
 public function getAdvert($advert)
 {
     $notifications = Notification::where('user', '=', Auth::User()->id)->orderBy('id', 'desc')->take(5)->get();
     $count_notification = Notification::where('user', '=', Auth::User()->id)->where('read', '=', 0)->count();
     $user_details = array('surname' => Auth::User()->surname, 'name' => Auth::User()->name, 'avatar' => Auth::User()->avatar);
     $sidebar_adverts = DB::table('adverts')->join('advertisers', 'advertisers.id', '=', 'adverts.advertiser')->where('advertisers.id', '=', Auth::User()->advertiser)->select('adverts.name')->get();
     // dd($adverts);
     /*MAIN BODY CONTENT*/
     $advert_id = DB::table('adverts')->where('name', '=', $advert)->select('id')->first();
     $count_visits = DB::table('visits')->where('advert', '=', $advert_id->id)->sum('visits');
     $deals = DB::table('deals')->where('advert', '=', $advert_id->id)->get();
     $total_count_codes = 0;
     $sold_count_codes = 0;
     $remained_count_codes = 0;
     $total_profit = 0;
     $total_cooments = 0;
     $deals_details = array();
     $total_codes = 0;
     $sold_codes = 0;
     $remained_codes = 0;
     $ccomments = 0;
     if (count($deals) == 0) {
     }
     foreach ($deals as $key => $deal) {
         $total_codes = DB::table('codes')->where('deal', '=', $deal->id)->get();
         $sold_codes = DB::table('codes')->where('deal', '=', $deal->id)->where('available', '=', 0)->select('updated_at')->get();
         $remained_codes = DB::table('codes')->where('deal', '=', $deal->id)->where('available', '=', 1)->select('updated_at')->get();
         $ccomments = DB::table('comments')->where('deal', '=', $deal->id)->get();
         $total_cooments = $total_cooments + count($ccomments);
         $total_profit = $total_profit + $deal->price * count($sold_codes);
         $total_count_codes = $total_count_codes + count($total_codes);
         $sold_count_codes = $sold_count_codes + count($sold_codes);
         $remained_count_codes = $remained_count_codes + count($remained_codes);
     }
     $coupons_status = array('total' => $total_count_codes, 'sold' => $sold_count_codes, 'remained' => $remained_count_codes, 'profit' => $total_profit, 'comments' => $total_cooments);
     $deals_details[] = array('deals' => $deals, 'comments' => $ccomments, 'codes' => $total_codes);
     //dd($s_coupons);
     //dd($deals_details);
     return View::make('index')->with('user', $user_details)->with('notifications', $notifications)->with('count_notification', $count_notification)->with('s_coupon_sold', $sold_codes)->with('visits', $count_visits)->with('coupons_status', $coupons_status)->with('deals_details', $deals_details)->with('sidebar_adverts', $sidebar_adverts);
 }
Esempio n. 9
0
 /**
  *	API PUT Route to update a user's notification settings.
  *
  *	@param User $user
  *
  *	@return Response::json
  *
  * @todo There has to be a more efficient way to do this... We should probably only send changes from Angular.  We can also separate the array matching into helper functions
  */
 public function putNotifications(User $user)
 {
     if (Auth::user()->id !== $user->id) {
         return Response::json($this->growlMessage("You do not have permissions to edit this user's notification settings", "error"));
     }
     //Grab notification array
     $notifications = Input::get('notifications');
     //Retrieve valid notification events
     $validNotifications = Notification::getUserNotifications();
     $events = array_keys($validNotifications);
     //Loop through each notification
     foreach ($notifications as $notification) {
         //Ensure this is a known user event.
         if (!in_array($notification['event'], $events)) {
             return Response::json($this->growlMessage("Unable to save settings.  Unknown event: " . $notification['event'], "error"));
         }
         //Grab this notification from the database
         $model = Notification::where('user_id', '=', $user->id)->where('event', '=', $notification['event'])->first();
         //If we don't want that notification (and it exists), delete it
         if ($notification['selected'] === false) {
             if (isset($model)) {
                 $model->delete();
             }
         } else {
             //If the entry doesn't already exist, create it.
             //Otherwise, ignore ( there was no change )
             if (!isset($model)) {
                 $model = new Notification();
                 $model->user_id = $user->id;
                 $model->event = $notification['event'];
                 $model->type = "email";
                 $model->save();
             }
         }
     }
     return Response::json($this->growlMessage("Settings saved successfully.", "success"));
 }
 public function pull()
 {
     if (!Auth::isLogged(App::$instance)) {
         die(json_encode([]));
     }
     // not auth
     //set time barrier
     if (!$this->isCanBePulled()) {
         die(json_encode([]));
     }
     // not time come
     $startThere = date_create()->modify("-120 seconds");
     $readed = $this->sesRead();
     //define last access time
     $this->putLastRequestTime();
     //get notices
     $notifications = Notification::where("created_at", ">", $startThere)->where("created_at", "<", date_create())->whereNotIn("id", $readed['filtered'])->whereIn("to", [0, App::$instance->user->id])->take(5)->get();
     //humanize
     if (count($notifications)) {
         foreach ($notifications as $notice) {
             $notice->humanized = new stdClass();
             $notice->humanized->created_at = date_create($notice->created_at)->format("d.m.Y H:i:s");
         }
     }
     //mark as collected
     if (count($notifications)) {
         foreach ($notifications as $notice) {
             $readed['raw'][] = [$notice->id, date_create()->format("Y-m-d H:i:s")];
         }
         $this->sesWrite($readed['raw']);
     }
     if (ST::isAjaxRequest()) {
         print json_encode($notifications);
     } else {
         return $notifications;
     }
 }
Esempio n. 11
0
 public function sendsms()
 {
     foreach (Notification::where('status', 'peding')->get() as $send) {
     }
 }
Esempio n. 12
0
File: User.php Progetto: alisha/seed
 public function numberOfUnreadMessages()
 {
     return count(Notification::where('user_id', '=', $this->id)->where('has_read', '=', '0')->get());
 }
 public function getNotificationList()
 {
     $input = Input::all();
     $user = Auth::user();
     $notifications = Notification::where('user_id', $user['id'])->orderBy('id', 'DESC')->get();
     $returnArray = array();
     $i = 0;
     foreach ($notifications as $notification) {
         //print_r($notification->user_id);
         $msg = "new message";
         $filterImage = "filter-msg.png";
         if ($notification->type == "newlike") {
             $msg = "new like";
             $filterImage = "filter-likes.png";
         }
         if ($notification->type == "newcomment") {
             $msg = "new comment";
             $filterImage = "filter-comments.png";
         }
         if ($notification->type == "newgroupmember") {
             $msg = "new team member";
             $filterImage = "filter-new-roller.png";
         }
         if ($notification->type == "missionpending") {
             $msg = "mission pending";
         }
         $user = DB::select('select * from users where id = ?', array($notification->source_user_id));
         if ($user) {
             $returnArray[$i]['id'] = $notification->id;
             $returnArray[$i]['user_id'] = $notification->user_id;
             $returnArray[$i]['source_user_id'] = $notification->source_user_id;
             $returnArray[$i]['type'] = $notification->type;
             $returnArray[$i]['source_id'] = $notification->source_id;
             $returnArray[$i]['message'] = $notification->message;
             $returnArray[$i]['title'] = $msg;
             $returnArray[$i]['filterImage'] = $filterImage;
             $returnArray[$i]['isRead'] = $notification->isRead;
             $returnArray[$i]['source_id'] = $notification->source_id;
             $returnArray[$i]['updated_at'] = $notification->updated_at;
             $returnArray[$i]['created_at'] = $notification->created_at;
             $returnArray[$i]['type'] = $notification->type;
             //$returnArray[$i]['userarray'] = $user;
             $returnArray[$i]['src_user_pic'] = base64_decode($user[0]->picture);
             $returnArray[$i]['username'] = $user[0]->firstname . " " . $user[0]->lastname;
             //print_r(base64_decode($user[0]->picture));
         }
         DB::table('notifications')->where('id', $notification->id)->update(array('isRead' => 1));
         $i++;
     }
     return $returnArray;
 }
Esempio n. 14
0
 public function getNotifications()
 {
     $notifications = Notification::where('user_id', '=', Auth::user()->id)->get();
     $validNotifications = Notification::getValidNotifications();
     $selectedNotifications = [];
     foreach ($notifications as $n) {
         $selectedNotifications[] = $n->event;
     }
     return Response::json(compact('selectedNotifications', 'validNotifications'));
 }
Esempio n. 15
0
 public function notifications()
 {
     // notifications that are about this project, its bids,
     // or its collaborators.
     $project = $this;
     return Notification::where(function ($query) use($project) {
         $query->where('payload_type', '=', 'bid');
         $query->where_in('payload_id', $project->bids()->lists('id') ?: array(''));
     })->or_where(function ($query) use($project) {
         $query->where('payload_type', '=', 'project');
         $query->where('payload_id', '=', $project->id);
     })->get();
 }
Esempio n. 16
0
 public function destroy($id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorOrAdminPermissioinRequire($topic->user_id);
     //删除文章
     $topic->delete();
     //该文章相关的通知删除
     Notification::where('user_id', '=', $topic->user_id)->where('topic_id', '=', $topic->id)->delete();
     //该文章的回复删除
     Reply::where('topic_id', '=', $topic->id)->delete();
     Flash::success(lang('Operation succeeded.'));
     $url = Request::getRequestUri();
     if (stripos($url, 'account') == false) {
         return Redirect::route('topics.index');
     } else {
         return Redirect::route('ac_topices');
     }
 }
Esempio n. 17
0
 public function requestToDelete($id = null)
 {
     try {
         $type = Input::get('type');
         if ($type == 0) {
             $post = Post::find($id);
             if ($post) {
                 $notification = Notification::where('user_id', $post->user_id)->where('type', 4)->where('post_id', $post->id)->first();
                 if ($notification) {
                     $notification->like = $notification->like + 1;
                     $notification->seen = 0;
                     $notification->updated_at = Carbon::now();
                     $notification->save();
                 } else {
                     $notification = new Notification();
                     $notification->user_id = $post->user_id;
                     $notification->type = 4;
                     $notification->post_id = $post->id;
                     $notification->like = 1;
                     $notification->seen = 0;
                     $notification->created_at = Carbon::now();
                     $notification->updated_at = Carbon::now();
                     $notification->save();
                     // return 'ok';
                 }
                 return 'true';
             }
         } elseif ($type == 1) {
             $comment = Comment::find($id);
             if ($comment) {
                 $notification = Notification::where('user_id', $comment->user_id)->where('type', 5)->where('post_id', $comment->post_id)->where('dislike', $comment->id)->first();
                 if ($notification) {
                     $notification->like = $notification->like + 1;
                     $notification->seen = 0;
                     $notification->created_at = Carbon::now();
                     $notification->updated_at = Carbon::now();
                     $notification->save();
                 } else {
                     $notification = new Notification();
                     $notification->user_id = $comment->user_id;
                     $notification->type = 5;
                     $notification->post_id = $comment->post_id;
                     $notification->like = 1;
                     $notification->dislike = $comment->id;
                     $notification->seen = 0;
                     $notification->created_at = Carbon::now();
                     $notification->updated_at = Carbon::now();
                     $notification->save();
                 }
                 return 'true';
             }
         }
     } catch (Exception $e) {
     }
     return 'false';
 }
 /**
  * [filterResults description]
  * @return [type] [description]
  */
 public function filterResults()
 {
     $data = Input::all();
     $data['view'] = isset($data['view']) ? $data['view'] : 'day';
     $data['date'] = isset($data['date']) ? $data['date'] : date('Y-m-d');
     $data['next'] = isset($data['next']) ? $data['next'] : 0;
     $data['prev'] = isset($data['prev']) ? $data['prev'] : 0;
     $data['type'] = isset($data['type']) ? $data['type'] : 'all';
     /*
     	FILTROS DE EXIBIÇÃO
     */
     switch ($data['view']) {
         // DAY
         default:
             $date = Carbon::createFromFormat('Y-m-d', $data['date_from'])->addDays($data['next'])->subDays($data['prev']);
             $notifications = Notification::where('date', $date->format('Y-m-d'))->where('user_id', Auth::id())->orderBy('date')->get();
             break;
         case 'week':
             $date = Carbon::createFromFormat('Y-m-d', $data['date_from'])->addWeeks($data['next'])->subWeeks($data['prev']);
             $notifications = Notification::where('date', '>=', $date->startOfWeek()->format('Y-m-d'))->where('date', '<=', $date->endOfWeek()->format('Y-m-d'))->where('user_id', Auth::id())->orderBy('date')->get();
             break;
         case 'range':
             $notifications = Notification::where('date', '>=', $data['date_from'])->where('date', '<=', $data['date_to'])->where('user_id', Auth::id())->orderBy('date')->get();
             break;
         case 'month':
             $view = "notifications.views.month";
             $date = Carbon::createFromFormat('Y-m-d', $data['date_from'])->addMonths($data['next'])->subMonths($data['prev']);
             $notifications = Notification::where('date', '>=', $date->startOfMonth()->format('Y-m-d'))->where('date', '<=', $date->endOfMonth()->format('Y-m-d'))->where('user_id', Auth::id())->orderBy('date', 'DESC')->get();
             $title = strftime("%B de %Y", strtotime($date));
             break;
     }
     // FILTERS
     if (isset($data['filter_order']) and $data['filter_order'] == 'desc') {
         $notifications->sortByDesc('date');
         // sort using collection method
         $labels['filter_order'] = '<i class="fa fa-chevron-down"></i>';
     } else {
         $notifications->sortBy('date');
         // sort using collection method
         $labels['filter_order'] = '<i class="fa fa-chevron-up"></i>';
     }
     if ($data['filter_done']) {
         $notifications = $notifications->filter(function ($transaction) use($data) {
             if ($transaction->done == $data['filter_done']) {
                 return $transaction;
             }
         });
         // LABELS
         switch ($data['filter_done']) {
             case 1:
                 $labels['filter_done'] = 'efetivadas';
                 break;
             case 0:
                 $labels['filter_done'] = 'não efetivadas';
                 break;
         }
     }
     if ($data['filter_type']) {
         $notifications = $notifications->filter(function ($transaction) use($data) {
             if ($transaction->type == $data['filter_type']) {
                 return $transaction;
             }
         });
         // LABELS
         switch ($data['filter_type']) {
             case 'receita':
                 $labels['filter_type'] = 'receitas';
                 break;
             case 'despesa':
                 $labels['filter_type'] = 'despesas';
                 break;
         }
     }
 }
Esempio n. 19
0
    // 	}else{
    // 		echo "<br/> Criei a tabela pra você!";
    // 	}
    // };
    if (Confide::user()) {
        $configs = User::find(Confide::user()->id)->settings;
        foreach ($configs as $config) {
            if (Config::has($config->setting_type . '.' . $config->setting_name)) {
                if (json_decode($config->setting_value)) {
                    $config->setting_value = json_decode($config->setting_value, 'T_ARRAY');
                }
                Config::set($config->setting_type . '.' . $config->setting_name, $config->setting_value);
            }
        }
    }
    $notifications = Notification::where('status', 0)->get();
    $notifications = $notifications->filter(function ($notification) {
        $date = Carbon::createFromFormat('Y-m-d H:i:s', $notification->date);
        if ($date->isToday() || $date->isPast()) {
            return $notification;
        }
    });
    if ($notifications) {
        Session::put('notifications', $notifications);
    }
});
App::after(function ($request, $response) {
    //
});
/*
|--------------------------------------------------------------------------
Esempio n. 20
0
 /**
  * Send a reply
  *
  * @param int 	$id
  * @return Response
  */
 public function reply($id)
 {
     $chat = Chat::findOrfail($id);
     $chat->last_reply = date("Y-m-d H:i:s");
     $chat->save();
     $reply = new Reply();
     $reply->text = Input::get('text');
     $reply->chat_id = $chat->id;
     $reply->user_id = Auth::user()->id;
     $reply->save();
     //Set up notifications for this chat
     foreach ($chat->user()->get() as $user) {
         $reply->notification()->save($user);
     }
     $notification = Notification::where('user_id', '=', Auth::user()->id)->where('reply_id', '=', $reply->id)->firstOrFail();
     $notification->has_read = 1;
     $notification->save();
     return Redirect::to('/community/chats/' . $id)->with('flash_chat', 'Your chat has been sent!')->with('alert_class', 'alert-success');
 }
Esempio n. 21
0
 public function isRead()
 {
     $notification = Notification::where('reply_id', '=', $this->id)->where('user_id', '=', Auth::user()->id)->first();
     return $notification->has_read == 1 ? 1 : 0;
 }
Esempio n. 22
0
 public function podoffNotification()
 {
     $notifications = Notification::where('user_id', '=', Auth::user()->staff_user_id)->orderBy('created_at', 'DESC')->get();
     return View::make('notifications.podoff', compact('notifications'));
 }
Esempio n. 23
0
 function NotifyDelete($nid)
 {
     if (Auth::check()) {
         //            $info=Auth::user()->notifications()->where('user_id','=',Auth::user()->id)->andwhere('id','=',$nid)->get();
         $info = Notification::where('user_id', '=', Auth::user()->id)->where('id', '=', $nid)->first();
         if (is_null($info)) {
             return "false";
         }
         //查看 该同志ID 是否属于目前登录用户。
         $info->delete();
         return "true";
     }
 }
 public function onNewActivityVote($vote_type, $activity, $user)
 {
     //Notify the user if he's subscribed to updates
     $notice = Notification::where('user_id', '=', $activity['user_id'])->where('event', '=', MadisonEvent::NEW_ACTIVITY_VOTE)->get();
     switch ($vote_type) {
         case 'like':
             $intro = 'Congrats';
             break;
         case 'dislike':
             $intro = 'Oops';
             break;
         default:
             $intro = 'Hey';
             break;
     }
     //If the user has subscribed to activity votes
     if (isset($notice)) {
         $notification = $this->processNotices($notice, MadisonEvent::NEW_ACTIVITY_VOTE);
         $this->doNotificationActions($notification, array('data' => array('intro' => $intro, 'vote_type' => $vote_type, 'activity' => $activity->toArray(), 'user' => $user->toArray()), 'subject' => 'A user has voted on your activity!', 'from_email_address' => static::FROM_EMAIL_ADDRESS, 'from_email_name' => static::FROM_EMAIL_NAME));
     }
 }
Esempio n. 25
0

<header class="main-header">
    <a href="index2.html" class="logo">
        <span class="logo-mini"><b>POWER</b></span>
          <span class="logo-lg"><b>POWER</b></span>
        </a>
        <nav class="navbar navbar-static-top" role="navigation">
          <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
          </a>
          <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
			<?php 
$pod_down_notifications = Notification::where('user_id', '=', Auth::user()->staff_user_id)->orderBy('created_at', 'DESC')->get();
$pod_down_unseen = Notification::where('user_id', '=', Auth::user()->staff_user_id)->where('notification_status', '=', 0)->count();
$pod_up_notifications = PodUpNotification::where('user_id', '=', Auth::user()->staff_user_id)->orderBy('created_at', 'DESC')->get();
$pod_up_unseen = PodUpNotification::where('user_id', '=', Auth::user()->staff_user_id)->where('notification_status', '=', 0)->count();
?>
              <li class="dropdown messages-menu">
                <a href="#" id="podoff_notification" class="dropdown-toggle " data-toggle="dropdown">
                  <i class="fa fa-bell-o"></i>
                  <span id="sharad_off" class="label label-danger">{{ $pod_down_unseen }}</span>
                </a>
			
                <ul class="dropdown-menu">
                  <li class="header"></li>
                  <li>
                    <ul class="menu">
					@foreach($pod_down_notifications as $notification)
                      <li>