/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $notify_report = false;
     for ($i = 0; $i < count($request->all()); $i++) {
         if ($request->input($i . '.include')) {
             $this->validate($request, [$i . '.id' => 'required', $i . '.member.id' => 'required|numeric', $i . '.position_id' => 'required|numeric', $i . '.project_id' => 'required|numeric', $i . '.target_id' => 'required|numeric', $i . '.output' => 'required|numeric', $i . '.date_start' => 'required|date', $i . '.date_end' => 'required|date', $i . '.hours_worked' => 'required|numeric', $i . '.daily_work_hours' => 'required|numeric', $i . '.output_error' => 'required|numeric']);
             // check if a report is already created
             if (!$notify_report) {
                 $admin = User::where('role', 'admin')->first();
                 $report = Report::where('id', $request->input($i . '.report_id'))->first();
                 // create a notification
                 $notification = new Notification();
                 $notification->message = 'updated a ';
                 $notification->sender_user_id = $request->user()->id;
                 $notification->receiver_user_id = $admin->id;
                 $notification->subscriber = 'admin';
                 $notification->state = 'main.weekly-report';
                 $notification->event_id = $report->id;
                 $notification->event_id_type = 'report_id';
                 $notification->seen = false;
                 $notification->save();
                 $notify = DB::table('reports')->join('users', 'users.id', '=', 'reports.user_id')->join('projects', 'projects.id', '=', 'reports.project_id')->join('notifications', 'notifications.event_id', '=', 'reports.id')->select('reports.*', 'users.*', DB::raw('LEFT(users.first_name, 1) as first_letter'), 'projects.*', 'notifications.*')->where('notifications.id', $notification->id)->first();
                 // foreach ($query as $key => $value) {
                 //     $notify = $value;
                 // }
                 event(new ReportSubmittedBroadCast($notify));
                 $activity_type = ActivityType::where('action', 'update')->first();
                 $activity = new Activity();
                 $activity->report_id = $report->id;
                 $activity->user_id = $request->user()->id;
                 $activity->activity_type_id = $activity_type->id;
                 $activity->save();
                 // report
                 $create_report = true;
             }
             $old_performance = Performance::where('id', $request->input($i . '.id'))->first();
             // record history of the performance
             $performance_history = new PerformanceHistory();
             $performance_history->activity_id = $activity->id;
             $performance_history->performance_id = $old_performance->id;
             $performance_history->report_id = $old_performance->report_id;
             $performance_history->member_id = $old_performance->member_id;
             $performance_history->position_id = $old_performance->position_id;
             $performance_history->department_id = $old_performance->department_id;
             $performance_history->project_id = $old_performance->project_id;
             $performance_history->target_id = $old_performance->target_id;
             $performance_history->date_start = $old_performance->date_start;
             $performance_history->date_end = $old_performance->date_end;
             $performance_history->daily_work_hours = $old_performance->daily_work_hours;
             $performance_history->output = $old_performance->output;
             $performance_history->hours_worked = $old_performance->hours_worked;
             $performance_history->output_error = $old_performance->output_error;
             $performance_history->average_output = $old_performance->average_output;
             $performance_history->productivity = $old_performance->productivity;
             $performance_history->quality = $old_performance->quality;
             $performance_history->quadrant = $old_performance->quadrant;
             $performance_history->save();
         }
     }
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($topic_uuid, $topics_uid, TopicReply $data)
 {
     $notification = new Notification();
     $this->count = $notification->countNotification($topics_uid);
     $this->author = $topics_uid;
     $this->topic = $topic_uuid;
     $this->data = $data;
 }
 public function addNtf()
 {
     $notification = new Notification();
     $notification->message = 'test';
     $notification->cron = '* * * * * *';
     $notification->receiver_id = 1;
     $notification->save();
     return "added";
 }
Esempio n. 5
0
 public function sentMessageNotification($user)
 {
     $sender = User::findOrFail(Auth::user()->id);
     $notification = new Notification();
     $notification->user_id = $user->id;
     $notification->title = 'You have a new message!!';
     $notification->body = $sender->name . ' has sent you a private message! Go to your inbox to reply now!';
     $notification->save();
 }
 /**
  * Handle the event.
  *
  * @param  BadgeWasEarned  $event
  * @return void
  */
 public function handle(BadgeWasEarned $event)
 {
     $user = $event->user;
     $notification = new Notification();
     $notification->type = "Badge";
     $notification->is_read = false;
     $notification->user_id = $user->id;
     $notification->save();
 }
Esempio n. 7
0
 public function addConnectionNotification($friend)
 {
     $sender = User::findOrFail(Auth::user()->id);
     $notification = new Notification();
     $notification->user_id = $friend->id;
     $notification->title = 'Someone has added you as their connection!';
     $notification->body = $sender->name . ' added you to their connection list, add them back to interact with them if you have not done so already!';
     $notification->save();
 }
Esempio n. 8
0
 /**
  * Create a new event instance.
  *
  * @return void
  *
  * $flg -> increment or decrement
  */
 public function __construct($notify_user, $topics_uuid, $is_upvote)
 {
     $this->user = $notify_user;
     $notification = new Notification();
     $this->count = $notification->countNotification($notify_user);
     $this->is_upvote = $is_upvote;
     //Get the most upvote count*/
     $tp = new Topic();
     $this->upv_cnt = $tp->upvoteTopic($topics_uuid, $is_upvote);
     $this->topic = $topics_uuid;
 }
 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);
 }
Esempio n. 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['body' => 'required|min:5']);
     if ($request->user()->muted) {
         return \Redirect::back()->with('error', 'You are muted.');
     }
     $status = ['body' => $request->body];
     $st = $this->status->publish($status);
     // Create notification with Stream
     $not = new Notification();
     $not->from($request->user())->withType('UserStatusUpdate')->withSubject('A status is posted')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " published a post in his feedline " . link_to_route('show-status', "#" . $st->id, $st->id))->withStream(true)->regarding($st)->deliver();
     return \Redirect::back()->with('message', 'Status updated successfully');
 }
 /**
  * Handle the event.
  *
  * @param  ShameWasUpdated  $event
  * @return void
  */
 public function handle(ShameWasUpdated $event)
 {
     $shame = $event->shame;
     $users = $shame->follows;
     foreach ($users as $user) {
         $notification = new Notification();
         $notification->type = "Shame";
         $notification->is_read = false;
         $notification->user_id = $user->id;
         $notification->shame_id = $shame->id;
         $notification->save();
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $notification = new Notification();
     if (Request::has('text') && Request::input('text') != "") {
         $notification->text = Request::input('text');
         $notification->save();
         return Response::make("Success", 201);
     } else {
         // Bad request, missing parameters
         return Response::make("Please provide a notification.", 400);
     }
 }
 /**
  * Handle the event.
  *
  * @param  CommentWasAdded  $event
  * @return void
  */
 public function handle(CommentWasAdded $event)
 {
     $comment = $event->comment;
     $shame = $comment->shame;
     $users = $shame->follows;
     foreach ($users as $user) {
         $notification = new Notification();
         $notification->type = "Comment";
         $notification->is_read = false;
         $notification->user_id = $user->id;
         $notification->shame_id = $shame->id;
         $notification->comment_id = $comment->id;
         $notification->save();
     }
 }
Esempio n. 14
0
 /**
  * Store a newly created resource in storage.
  *
  * @param NewsRequest $request
  * @return Response
  */
 public function store(NewsRequest $request)
 {
     $slug = str_limit(str_slug($request->title), 50) . "--author-{$request->user()->username}";
     /*$news  = News::where('summary',$slug)->first();
     
             if($news)
             {
                 $slug = str_limit(str_slug($request->title),50)."-".time()."--author-{$request->user()->username}";
             }*/
     $news = $request->user()->news()->create(['title' => $request->title, 'text' => $request->text, 'summary' => $slug, 'is_published' => true, 'news_type' => $request->news_type]);
     // Create notification
     $not = new Notification();
     $not->from($request->user())->withType('NewsCreated')->withSubject('A news is created')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has created a news " . link_to_route('news.show', str_limit($news->title, 100), $news->summary))->withStream(true)->regarding($news)->deliver();
     return redirect()->route('news.show', $news->summary)->with('message', 'News Created');
 }
Esempio n. 15
0
 public function saveNotification($data)
 {
     $notify = new Notification();
     $notification_responce_time = '30';
     $time = date('Y-m-d H:i:s');
     $newtime = strtotime("{$time} + {$notification_responce_time} seconds");
     $expire = date('Y-m-d H:i:s', $newtime);
     $notify->sender_id = $data['sender_id'];
     $notify->reciver_id = $data['reciver_id'];
     $notify->message = $data['message'];
     $notify->type = $data['type'];
     $notify->expired_at = $expire;
     $notify->save();
     return $notify;
 }
 /**
  * @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);
 }
Esempio n. 17
0
 public function storeForTournament($id, Request $request)
 {
     $t = KTournament::findOrFail($id);
     $comment = \Input::get('body');
     if ($comment == '') {
         return \Redirect::back();
     }
     if ($request->user()->muted) {
         return \Redirect::back()->with('error', 'You are muted.');
     }
     $t->comments()->create(['body' => $comment, 'user_id' => Auth::user()->id]);
     // Create notification
     $not = new Notification();
     $not->from($request->user())->withType('UserCommentOnTournament')->withSubject('A comment is done on tournament')->withBody(link_to_route('user.show', $request->user()->displayName(), $request->user()->username) . " has commented on " . link_to_route('tournament.show', $t->name, $t->slug) . " tournament")->withStream(true)->regarding($t)->deliver();
     return \Redirect::back()->with('success', 'Success!');
 }
Esempio n. 18
0
 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(NotifiableEvent $event)
 {
     $notification = Notification::create($event->getData());
     $notification->notifiable()->associate($event->getNotifiable());
     $notification->save();
     $event->getUser()->notifications()->save($notification);
 }
 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);
 }
Esempio n. 21
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, \App\Order $order)
 {
     $me = \Auth::user();
     $client_id = $order->client_id;
     $my_client = $me->clients->where('id', $client_id);
     if (!$my_client->isEmpty()) {
         $status = $request->get('status');
         $orders = $order->client->orders;
         foreach ($orders as $o) {
             if ($status == 1) {
                 $o->waiter()->associate($me);
                 \App\Notification::add($me->toArray(), 'ur_mine', $order->client);
                 foreach ($order->client->waiters()->online()->get() as $waiter) {
                     if ($waiter->id == $me->id) {
                         continue;
                     }
                     \App\Notification::add($order->client->toArray(), 'hes_mine', $waiter);
                 }
             }
             $o->status = $status;
             $o->save();
         }
         return $orders;
     }
 }
Esempio n. 22
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(App\QuestionCategory::class)->create(['name' => 'first category']);
     factory(App\QuestionCategory::class)->create(['name' => 'second category']);
     // Generate users
     factory(App\User::class, 2)->create()->each(function ($user) {
         // Generate trial period
         \App\UserTrialPeriod::create(['user_id' => $user->id, 'trial_period_id' => \App\TrialPeriod::first()->id]);
         // Settings
         $user->settings()->save(factory(App\UserSetting::class)->make(['user_id' => $user->id, 'language_id' => 1]));
         // Generate notifications
         $notifications = \App\Notification::all();
         foreach ($notifications as $notification) {
             $user->notifications()->save(factory(\App\UserNotification::class)->make(['user_id' => $user->id, 'notification_id' => $notification->id]));
         }
         // Bills per user
         $rows = 12;
         // Products per bill
         $productsPerBill = 5;
         for ($i = 0; $i < $rows; $i++) {
             // Generate client
             $client = $user->clients()->save(factory(App\Client::class)->make());
             // Generate bill for that client
             $bill = $user->bills()->save(factory(App\Bill::class)->make(['client_id' => $client->id]));
             // Generate products
             for ($j = 0; $j < $productsPerBill; $j++) {
                 $product = $user->products()->save(factory(App\Product::class)->make());
                 $bill->products()->save(factory(App\BillProduct::class)->make(['product_id' => $product->id]));
                 $applicationProduct = factory(App\ApplicationProduct::class)->create();
                 $bill->applicationProducts()->save(factory(App\BillApplicationProduct::class)->make(['product_id' => $applicationProduct->id]));
             }
         }
     });
 }
Esempio n. 23
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $items = $request->get('items');
     $me = \Auth::user();
     $order = new \App\Order();
     $order->client()->associate($me);
     $my_orders = $me->orders;
     if ($my_orders->isEmpty()) {
         foreach ($me->waiters()->online()->get() as $waiter) {
             \App\Notification::add($me->toArray(), 'serve_me', $waiter);
         }
     } else {
         $my_order = $my_orders->first()->toArray();
         if ($my_order['waiter_id']) {
             $waiter = \App\User::find($my_order['waiter_id']);
             $order->waiter()->associate($waiter);
             \App\Notification::add($me->toArray(), 'serve_me_again', $waiter);
         }
     }
     $order->save();
     foreach ($items as $item) {
         $food = \App\Food::find($item['food']);
         if ($food->category->menu->admin_id == $me->admin_id) {
             $item = new \App\OrderItem($item);
             $item->food()->associate($food);
             $item->order()->associate($order);
             $item->save();
         }
     }
     return $order->load('items.food');
 }
Esempio n. 24
0
 public function processRequest($userId, $eventId, $permit)
 {
     if ($permit == 0) {
         $status = 'declined';
         \DB::table('event_user')->where('event_id', '=', $eventId)->where('user_id', '=', $userId)->delete();
     } elseif ($permit == 1) {
         $status = 'approved';
         \DB::table('event_user')->where('event_id', $eventId)->where('user_id', $userId)->update(array('status' => $status));
         $notification = new Notification();
         $notification->user_id = $userId;
         $notification->text = 'You have been accepted for ';
         $notification->object_id = $eventId;
         $notification->save();
     }
     return redirect('/events/' . $eventId);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $device = Device::findOrFail($id);
     $notifications = Notification::all();
     return View('devices.show', compact('device', 'notifications'));
 }
 public function flag(Request $request)
 {
     $notification = Notification::find($request->input('notification_id'));
     $notification->flagged = true;
     $notification->save();
     return response()->json(['response' => 'success', 'notification' => $notification]);
 }
 public function index()
 {
     $title = "Dashboard";
     $users = User::count();
     $notifications = Notification::count();
     $packages = Package::count();
     return view('admin.dashboard.index', compact('users', 'title', 'notifications', 'packages'));
 }
Esempio n. 28
0
 public function editPost($id, EditPostRequest $request)
 {
     $post = Post::findOrFail($id);
     $post->update(['post' => $request->input('post'), 'editor_id' => \Auth::id(), 'editor_name' => \Auth::user()->name, 'was_edited' => 1, 'edit_reason' => $request->input('edit_reason')]);
     Notification::create(['not_title' => 'Kliknij i przejdź do posta, aby sprawdzić szczegóły', 'not_body' => 'Twój post w artykule został edytowany', 'not_status' => 5, 'not_from_user_name' => \Auth::user()->name, 'user_id' => $post->user['id'], 'not_route' => '' . $request->input('take_uri') . '#post' . $id . '']);
     flash()->success('Udało Ci się edytować post o ID <b>' . $id . '</b>!');
     return redirect('/admin/article/' . $request->input('take_article_id') . '');
 }
Esempio n. 29
0
 public function newAppendNotify(User $fromUser, Topic $topic, Append $append)
 {
     $users = $topic->replies()->with('user')->get()->lists('user');
     // Notify commented user
     Notification::batchNotify('comment_append', $fromUser, $this->removeDuplication($users), $topic, null, $append->content);
     // Notify attented users
     Notification::batchNotify('attention_append', $fromUser, $this->removeDuplication($topic->attentedBy), $topic, null, $append->content);
 }
Esempio n. 30
0
 /**
  * Create log on database
  * @return bool
  */
 public function make()
 {
     if ($this->verifyExistence() === true) {
         return false;
     }
     Notification::Slack(array_merge($this->container, ['site' => $this->site]));
     $this->StorageDriver->insert($this->container);
 }