/** * Signs user up. * * @return User|null the saved model or null if saving fails */ public function signup() { if ($this->validate()) { $user = new User(); $user->username = $this->username; $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); $user->status = 0; if ($user->save()) { $notification = new Notification(); $notification->title = 'user'; $notification->message = 'new user, username:'******'model' => 'User', 'id' => $user->id]); if ($notification->save()) { $this->sendEmail($this->email); } else { print_r($notification->getErrors()); exit(0); } return $user; } else { return $user->getErrors(); } } return null; }
/** * Run the database seeds. * * @return void */ public function run() { $notification = new Notification(); $notification->from = 1; $notification->to = 1; $notification->type = 1; $notification->save(); }
/** * Create post * * @param Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View */ public function create(Request $request) { if ($request->isMethod("post")) { $rules = ["title" => "required", "alias" => "required|unique:posts,alias", "content" => "required", 'image' => 'mimes:jpeg,jpg,png']; Validator::make($request->all(), $rules)->validate(); $post = new Post(); $post->title = $request->input("title"); $post->alias = $request->input("alias"); $post->content = $request->input("content"); $post->meta_keys = $request->input("meta_keys"); $post->meta_desc = $request->input("meta_desc"); if (!empty($request->file("image"))) { $generated_string = str_random(32); $file = $request->file("image")->store('uploads'); $new_file = $generated_string . '.' . $request->file("image")->getClientOriginalExtension(); Storage::move($file, 'uploads/' . $new_file); $img = Image::make($request->file('image')); $img->crop(200, 200); $img->save(storage_path('app/public/uploads/' . $new_file)); $img = Image::make($request->file('image')); $img->resize(600, 315); $img->save(storage_path('app/public/uploads/fb-' . $new_file)); $post->image = $new_file; } if ($request->has("category")) { $post->category_id = $request->input("category"); } $post->publish = $request->has("publish"); $post->author_id = Auth::user()->id; $post->save(); if ($request->has("tags")) { foreach ($request->input("tags") as $tag) { $post_tag = new PostTag(); $post_tag->post_id = $post->id; $post_tag->tag_id = $tag; $post_tag->save(); } } $admins = User::getAdmins(); foreach ($admins as $admin) { if ($admin->id != Auth::user()->id) { $notification = new Notification(); $notification->from = Auth::user()->id; $notification->to = $admin->id; $notification->type = 3; $notification->save(); } } return redirect()->route('posts'); } else { $categories = Category::getCategoriesByPublish(); $tags = Tag::getTags(); return view("site.post.create", compact("categories", "tags", "post")); } }
public function postOrder($lang = 'id') { $url_source = Input::get('url_source'); if ($url_source) { $url_source = URL::to('/'); } $promo = Promo::Active()->first(); if (!$promo) { return Redirect::to($url_source); } $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required')); if ($validator->fails()) { return Redirect::to($url_source); } $contact = new PromoOrder(); $contact->name = Input::get('name'); $contact->email = Input::get('email'); $contact->promo_id = Input::get('promo_id'); $contact->save(); $email = Notification::sendEmailGetPromo($contact); if (!$email) { Log::error('Failed sending Promo Order email with reference ID : ' . $contact->id); } if (!$contact->id) { Log::error('Failed updating database promo order from : ' . $contact->name . ' - ' . $contact->email); } restrictPromoPopup(); return Redirect::back(); }
public function update(Request $request, $id) { $notification = \App\Models\Notification::find($id); $notification->fill($request->all()); $notification->save(); return view('notifications', ['notifications' => $notifications]); }
/** * @param $id */ public function actionViewNotification($id) { $notification = Notification::findOne([$id]); $url = $notification->url; $notification->delete(); $this->redirect($url); }
public function postContact($lang = 'id') { $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email'), 'Phone' => Input::get('phone'), 'Address' => Input::get('address'), 'Subject' => Input::get('subject'), 'Message' => Input::get('message')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required', 'Phone' => 'required', 'Address' => 'required', 'Subject' => 'required', 'Message' => 'required')); if ($validator->fails()) { return Redirect::route('site.contact', array('lang' => $lang))->withErrors($validator->errors()); } $contact = new ContactUs(); $contact->name = Input::get('name'); $contact->email = Input::get('email'); $contact->phone = Input::get('phone'); $contact->address = Input::get('address'); $contact->subject = Input::get('subject'); $contact->message = Input::get('message'); $contact->save(); if (!$contact->id) { $errorMessage = "Proses gagal, coba beberapa saat lagi"; if ($lang == 'en') { $errorMessage = "Process failed, please try again later"; } return Redirect::route('site.contact', array('lang' => $lang))->with('error_message', $errorMessage); } $email = Notification::sendEmailContactUs($contact); if (!$email) { Log::error('Failed sending Contact Us email with reference ID : ' . $contact->id); } $successMessage = "Pesan Anda telah terkirim"; if ($lang == 'en') { $successMessage = "Your message has been sent"; } return Redirect::route('site.contact', array('lang' => $lang))->with('success', $successMessage); }
/** * Mark as read all unseen notifications */ public function seen() { $notifications = Notification::getNotificationsBySeen(); foreach ($notifications as $notification) { $notification->seen = 1; $notification->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { Notification::truncate(); // Notification::create([ // 'user_id' => 4, // 'message' => 'Jenny has confirmed your project!' // ]); }
public function run() { DB::table('notifications')->delete(); $collection = [['type_id' => 1, 'user_id' => 2, 'message' => 'New comment on selling with ADC'], ['type_id' => 3, 'user_id' => 2, 'message' => 'New message from George'], ['type_id' => 1, 'user_id' => 2, 'message' => 'New comment on selling with ADC', 'status' => 'complete'], ['type_id' => 4, 'user_id' => 2, 'message' => 'Watched auction closing'], ['type_id' => 5, 'user_id' => 2, 'message' => 'Watchlist inventory received.']]; foreach ($collection as $record) { Notification::create($record); } }
public function deleted($model) { try { $noti = Notification::where("objectID", $model["post_id"])->where('sender_id', $model["user_id"])->delete(); } catch (Exception $e) { echo $e->getMessage(); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $notification = Notification::whereId($id)->first(); if (empty($notification)) { return $this->saveResponse(false); } return $this->saveResponse($notification->delete()); }
/** * Handle the command. * * @param CreateNotificationCommand $command * @return void */ public function handle(CreateNotificationCommand $command) { $notification = Notification::create(['notified' => 0, 'alarm' => $command->alarm, 'shop_id' => $command->shop_id]); if (!empty($notification)) { return $notification; } return false; }
private function composeUserbar() { view()->composer('layouts.partials.userbar', function ($view) { $user = Auth::user(); $notifications = Notification::with('type')->where('user_id', Auth::id())->where('status', 'pending')->latest()->get(); $messages = Message::where('user_id', Auth::id())->where('status', 'pending')->latest()->get(); $view->with(['user' => $user, 'notifications' => $notifications, 'messages' => $messages]); }); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notification::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'userUpdate' => $this->userUpdate, 'userCreate' => $this->userCreate, 'updateDate' => $this->updateDate, 'createDate' => $this->createDate]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'params', $this->params]); return $dataProvider; }
public function actionSendUpdateNotifi() { $sender = $_POST['owner']; $typeid = $_POST['agendaID']; $type = $_POST['type']; $followmodel = new Follow(); $recive = array(); $recive = $followmodel->getfollowing($sender); for ($i = 0; $i < sizeof($recive); $i++) { $notificationModel = new Notification(); $notificationModel->sender = $sender; $notificationModel->postID = $typeid; $notificationModel->type = $type; $notificationModel->seen = "0 "; $notificationModel->notified = $recive["studentID"][$i]; $notificationModel->save(); } $value = array('status' => "ok"); return json_encode($value); }
public function update($id) { // save updated $record = $this->records->find($id); if (!$record) { Notification::create(Input::all()); return $this->respond($record); } $record->fill(Input::all())->save(); return $this->respond($record); }
/** * Handle the command. * * @param UpdateNotificationCommand $command * @return void */ public function handle(UpdateNotificationCommand $command) { $notification = Notification::whereId($command->id)->first(); if (!empty($notification)) { $notification->notified = $command->notified; $notification->alarm = $command->alarm; if ($notification->save()) { return $notification; } } return false; }
public function messageSent($request) { $this->userInfo = $request; $message_information = []; $message_information['message_from'] = session('active_user_id'); $message_information['message_to'] = Users::where('email', '=', $this->userInfo->userInfo->input('message_to'))->pluck('id'); $message_information['message'] = $this->userInfo->userInfo->input('message'); DB::beginTransaction(); Message::create($message_information); Notification::create(array('msg_from_user_id' => session('active_user_id'))); DB::commit(); }
/** * User activation * * @param $token * @return \Illuminate\Http\RedirectResponse */ public function activation($token) { $user = User::getUserByActivationToken($token); if (!empty($user)) { $user->approve = 1; $user->activation_token = ""; $user->save(); $admins = User::getAdmins(); foreach ($admins as $admin) { $notification = new Notification(); $notification->from = $user->id; $notification->to = $admin->id; $notification->type = 2; $notification->save(); } $notification = new Notification(); $notification->from = 1; $notification->to = $user->id; $notification->type = 4; $notification->save(); } return redirect()->route('home'); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Notification::find()->where(['shared_id' => Yii::$app->user->id]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'type_id' => $this->type_id, 'status' => $this->status, 'date' => $this->date]); $query->andFilterWhere(['like', 'shared_id', $this->shared_id])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
public function reviewed($notificationId, Request $request) { $notification = Notification::findOrFail($notificationId); if ($notification->user_id != $this->user->id) { if ($request->ajax()) { return ['result' => false]; } else { return Redirect::back()->withErrors(['access' => 'You have no right for this']); } } $result = NotificationMapper::reviewed($notification); if ($request->ajax()) { return ['result' => $result]; } else { if ($result) { return Redirect::back()->with(['success' => 'You have no right for this']); } else { return Redirect::back()->withErrors(['general' => 'Something was wrong']); } } }
/** * Execute the console command. * * @return mixed */ public function fire() { $now = Carbon::now(); $model = Delivery::where('delivery_type_id', 2)->whereNull('datepublish')->whereBetween('datestart', [$now->subMinutes(2)->format('Y-m-d H:i:s'), $now->addMinute(3)->format('Y-m-d H:i:s')])->get(); $data = $model->toArray(); $driver = Driver::whereFlagactive(1)->get(); Log::warning($now->format('Y-m-d H:i:s')); Log::warning($now->subMinutes(2)->format('Y-m-d H:i:s')); Log::warning($now->addMinute(3)->format('Y-m-d H:i:s')); Log::info('Cron funcionando'); if (!empty($driver) && count($data) > 0) { foreach ($driver as $value) { foreach ($data as $objDelivery) { Notification::create(array('type_id' => Notification::PUSH, 'platform_id' => Platform::ANDROID, 'user_id' => $value->id, 'app_id' => Config::get('app.APP_ID'), 'token' => \md5(\uniqid(\time())), 'description' => "{\"delivery_id\":\"{$objDelivery['id']}\",\"description\":\"Nuevo delivery\"}", 'appname' => Config::get('app.APP_NAME'), 'dbconfig' => Config::get('app.DB_CONFIG'), 'params' => "{\"delivery_id\":\"{$objDelivery['id']}\",\"description\":\"Nuevo delivery\"}", 'tosend' => $value->uuid, 'to' => 'Test', 'from' => 'Cligo', 'flagsend' => 0, 'flagactive' => 1)); $del = Delivery::find($objDelivery['id']); $del->datepublish = Carbon::now()->format('Y-m-d H:i:s'); $del->save(); Log::info("Notificacion enviada del delivery id: {$objDelivery['id']}"); } } } }
public function viewer($id) { if (Yii::$app->request->get('notify')) { $getid = Yii::$app->request->get('notify'); //$notification = new Notification(); $notify = \app\models\Notification::findOne(['type_id' => $id, 'id' => $getid, 'shared_id' => Yii::$app->user->id]); $notify->status = 1; $notify->save(); } if (Yii::$app->request->get('global')) { $getid = Yii::$app->request->get('global'); //$notification = new Notification(); $notify = \app\models\Notification::find()->where(['type_id' => $id, 'type' => $getid, 'shared_id' => Yii::$app->user->id, 'status' => 0])->all(); for ($i = 0; $i < sizeof($notify); $i++) { $notify[$i]->status = 1; $notify[$i]->save(); } } if (Yii::$app->request->get('external')) { $getid = Yii::$app->request->get('external'); $type = Yii::$app->request->get('type'); //$notification = new Notification(); $notify = \app\models\Notification::find()->where(['type_id' => $getid, 'type' => $type, 'shared_id' => Yii::$app->user->id, 'status' => 0])->all(); for ($i = 0; $i < sizeof($notify); $i++) { $notify[$i]->status = 1; $notify[$i]->save(); } } if (Yii::$app->request->get('wishlist')) { $getid = Yii::$app->request->get('wishlist'); //$notification = new Notification(); $notify = \app\models\Notification::find()->where(['user_id' => $id, 'type' => $getid, 'shared_id' => Yii::$app->user->id, 'status' => 0])->all(); //var_dump($notify); die(); for ($i = 0; $i < sizeof($notify); $i++) { $notify[$i]->status = 1; $notify[$i]->save(); } } }
/** * @return newsfeed generations array- DTR */ public function getNews() { $user = Yii::$app->user->id; $notification = Notification::find()->where(['shared_id' => $user])->orderBy(['date' => SORT_DESC])->all(); foreach ($notification as $news) { if ($news->type == 'event') { return Event::find()->where(['id' => $news->type_id]); } elseif ($news->type == 'activity') { return Activity::find()->where(['id' => $news->type_id]); } elseif ($news->type == 'journal') { return Journal::find()->where(['id' => $news->type_id]); } elseif ($news->type == 'wishlist') { return Wishlist::find()->where(['id' => $news->type_id]); } else { return Photos::find()->where(['id' => $news->type_id]); } } }
/** * Stop the timer (update it). * Return all the projects, * as well as the project that is currently displaying in the project popup * @param Request $request * @return mixed */ public function stopProjectTimer(Request $request) { // Fetch the required data $project = Project::find($request->get('project_id')); $last_timer_id = Timer::where('project_id', $project->id)->max('id'); $timer = Timer::find($last_timer_id); // Update the data (Price will be zero if time is less than 30 seconds) $timer->finish = Carbon::now()->toDateTimeString(); $timer->save(); $timer->calculatePrice(); $message = Auth::user()->name . ' has stopped the timer on the project ' . $project->description . '.'; //Create a notification in the database for the payer, in case they are not currently logged in $notification = new Notification(['message' => $message]); $notification->user()->associate($project->payer->id); $notification->save(); //Pusher $pusher = new Pusher(env('PUSHER_PUBLIC_KEY'), env('PUSHER_SECRET_KEY'), env('PUSHER_APP_ID')); $data = ['payer_id' => $project->payer_id, 'notification' => $notification]; $pusher->trigger('channel', 'stopTimer', $data); // Create the fractal manager // @TODO: You could extract the next two lines to a ServiceProvider $fractal = new Manager(); $fractal->setSerializer(new ArraySerializer()); // Create an item with fractal $resource = new Item($timer, new StopProjectTimerTransformer()); // $this->createItem(Model, transofrmer) // $this->createCollection(Model, transofrmer) // Send a response return response()->json($fractal->createData($resource)->toArray()); // return $this->responseOk($timer); }
public function setAsRead(Request $request) { Notification::where('id', $request['id'])->update(['is_read' => 1]); return "Set notification nr " . $request['id'] . " as read."; }
public function postBuy($lang = 'id') { $product = Product::find(Input::get('product_id')); if (!$product) { return Redirect::route('site.product', array('lang' => $lang)); } $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email'), 'Phone' => Input::get('phone'), 'Address' => Input::get('address')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required', 'Phone' => 'required', 'Address' => 'required')); if ($validator->fails()) { return Redirect::route('site.product.buy', array('lang' => $lang, 'slug' => $product->slug))->withErrors($validator->errors()); } $contact = new ProductOrder(); $contact->name = Input::get('name'); $contact->email = Input::get('email'); $contact->phone = Input::get('phone'); $contact->address = Input::get('address'); $contact->message = Input::get('message'); $contact->product_id = $product->id; $contact->product_name = $product->name_id; if ($lang == 'en') { $contact->product_name = $product->name_en; } $contact->price = $product->price; $contact->save(); $email = Notification::sendEmailBuyProduct($contact); if (!$email) { Log::error('Failed sending Product Purchase email with reference ID : ' . $contact->id); } if (!$contact->id) { $errorMessage = "Proses gagal, coba beberapa saat lagi"; if ($lang == 'en') { $errorMessage = "Process failed, please try again later"; } return Redirect::route('site.product.buy', array('lang' => $lang, 'slug' => $product->slug))->with('error_message', $errorMessage); } $successMessage = "Pesanan Anda telah kami terima, kami akan segera menghubungi anda untuk proses konfirmasi"; if ($lang == 'en') { $successMessage = "We have received your order, we will contact you soon for confirmation"; } return Redirect::route('site.product', array('lang' => $lang))->with('success', $successMessage); }
/** * Delete the notification * @param $id * @return \Illuminate\Http\Response */ public function destroy($id) { $notification = Notification::findOrFail($id); $notification->delete(); return $this->responseNoContent(); }
/** * Display Generator Page * * @param Notification $notification * @return $this */ public function index(Notification $notification) { return view('notifications.index')->with('notifications', $notification->all()); }