public function fire($job, $data) { $content = Content::findOrFail($data['id']); $content->autoThumbnail(); $job->delete(); Pusher::trigger('content-' . $content->getKey(), 'loaded-thumbnail', ['url' => $content->getThumbnailPath()]); }
public function makeBackup() { $serial_num = BACKUP_LOG::max('serial_num'); $newSerial_num = sprintf('%08d', $serial_num + 1); $currentSerialNum = BACKUP_LOG::find($serial_num); $currentSerialNum->serial_num = $newSerial_num; $currentSerialNum->save(); //shell_exec("ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock"); shell_exec('/Applications/MySQLWorkbench.app/Contents/MacOS/mysqldump -u' . env('DB_USERNAME') . ' -p' . env('DB_PASSWORD') . ' ' . env('DB_DATABASE') . ' > ' . env('BACKUP_PATH') . $newSerial_num . "_user_backup_`date`" . '.sql'); // TODO: put this in the constants file $path = storage_path() . "/app/Backups/"; // Search for the required file. Returns matching files. $sqldump = File::glob($path . $newSerial_num . '_*.sql'); $newNotification = new Notifications(); // TODO: Remove magic numbers // TODO: Put messages inside the constants file if ($sqldump == false) { $newNotification->notification = "Backup Failed!"; $newNotification->body = "User generated Backup failed."; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'failed_notification', ['message' => 'User generated Backup failed.']); } else { $newNotification->notification = "Backup successful!"; $newNotification->body = 'Backup #' . $newSerial_num . ' created.'; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'new_backup_notification', ['message' => 'Backup #' . $newSerial_num . ' created.']); } }
public function onNewNotification(Notification $notification) { foreach ($notification->targets as $target) { $channelName = 'private-u-' . $target->user_id; $notification = ['id' => $notification->hashId(), 'type' => $notification->getTypeDescription(), 'title' => $notification->title, 'img' => $notification->getThumbnailPath(), 'url' => $notification->getURL(true)]; Pusher::trigger($channelName, 'new-notification', $notification); } }
public function saveMessage() { if (Request::ajax()) { $data = Input::all(); $message = new Message(); $message->author = $data["author"]; $message->message = $data["message"]; $message->save(); Pusher::trigger('chat', 'message', ['message' => $message]); } }
/** * This function is to store the reservation details to db. * After storing the details this function redirects to the My Reservation view. * * @return \Illuminate\Http\RedirectResponse */ public function hallReservation() { try { //set the timezone date_default_timezone_set("Asia/Colombo"); $customer_email = Auth::user()->email; $customer_id = Customer::where('email', $customer_email)->value('cus_id'); $customer_name = Customer::where('email', $customer_email)->value('name'); $hall_name = HALL::where('hall_id', session('hall_selected'))->value('title'); $event_date = session('event_date'); //create instance of the HALL_RESERVATION model $hall_reservation = new HALL_RESERVATION(); $hall_reservation->reserve_date = session('event_date'); $hall_reservation->time_slot = session('timeSlot'); $hall_reservation->total_amount = session('total_payable'); $hall_reservation->cus_id = $customer_id; $hall_reservation->hall_id = session('hall_selected'); $hall_reservation->status = 'PENDING'; $hall_reservation->save(); //retrieve the reservation id of the last saved reservation $res_id = $hall_reservation->hall_reservation_id; //delete the reservation details since already stored in the db Session::forget(['event_date', 'total_payable', 'hall_selected', 'CanPay']); //create an array in order to send the mail view with reservation details $data = array('res_id' => $res_id, 'hall_name' => $hall_name, 'event_date' => $event_date, 'name' => $customer_name); $job = new SendEmail($data, $customer_email, "initial_reservation_mail"); $this->dispatch($job); //send a initial mail /* Mail::send('emails.InitialRoomReservationMail', $data, function ($message)use($customer_email) { $message->from(env('MAIL_FROM'), env('MAIL_NAME')); $message->to($customer_email)->subject('Welcome to Amalya Reach!'); });*/ //pusher $newNotification = new Notifications(); $newNotification->notification = "New Reservation"; $newNotification->body = "Room Reservation has been made"; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'Reservation', ['message' => 'New Hall Reservation has been made']); return redirect('myreserv')->with(['hreserv_status' => 'Reservation has been successfully made']); } catch (\Exception $e) { abort(500, $e->getMessage()); } }
/** * Show Notification * * @return \Illuminate\Http\Response */ public function ShowNotification(Request $request) { $newNotification = new Notifications(); $newNotification->title = $request->input('title'); $newNotification->body = $request->input('message'); $newNotification->icon = $request->input('icon'); $newNotification->link = $request->input('link'); $newNotification->for = $request->input('for'); $newNotification->readStatus = '0'; $newNotification->save(); $message = $request->input('message'); $icon = $request->input('icon'); $link = $request->input('link'); $title = $request->input('title'); $for = $request->input('title'); Pusher::trigger('notifications', 'success_notification', ['message' => $message, 'icon' => $icon, 'link' => $icon, 'title' => $title, 'for' => $for]); //return $request->input('message'); }
/** * This function store the room reservation details to db and clears the session * * @param Request $request * @return \Illuminate\Http\RedirectResponse */ public function roomReservation(Request $request) { //set the timezone date_default_timezone_set("Asia/Colombo"); //get the customer details currently logged in $customer_email = Auth::user()->email; $customer_id = Customer::where('email', $customer_email)->value('cus_id'); $customer_name = Customer::where('email', $customer_email)->value('name'); //convert the dates to date time insatance and get the difference $datetime1 = new DateTime(session('check_in')); $datetime2 = new DateTime(session('check_out')); $interval = $datetime1->diff($datetime2); //get the requested reservation details from the session $no_of_guests = session('adults') + session('kids'); //formt the number of nights $no_of_nights = $interval->format('%d%') + config('constants.ADD_ONE_NIGHT'); //call the saveReservationDetails function to save the reservation details to the database $res_id = $this->saveReservationDetails(session('check_in'), session('check_out'), $no_of_nights, $customer_id); //insert the the details to the RES_RMTYPE_CNT_RATE table foreach (session('room_types') as $room_type) { DB::table('RES_RMTYPE_CNT_RATE')->insert(['room_reservation_id' => $res_id, 'room_type_id' => $room_type, 'rate_code' => session('rate_code' . $room_type), 'count' => session('no_of_rooms' . $room_type)]); } //create an array with reservation details in ordr to send to the mail view $data = array('res_id' => $res_id, 'check_in' => session('check_in'), 'check_out' => session('check_out'), 'nights' => $no_of_nights, 'no_of_rooms' => session('rooms'), 'guests' => $no_of_guests, 'name' => $customer_name); //observer design pattern is used here, but this is design pattern is no use full /*$sub = new ReservationRoom(); $sub->attach(new ReservationTask()); $sub->clearSession();*/ //clear session $this->clearRoomSession("Full"); //call the mailfunction send an email $this->sendInitialMail($data, $customer_email); //send an pusher notification to the admin //remove the magic values $newNotification = new Notifications(); $newNotification->notification = "New Reservation"; $newNotification->body = "Room Reservation has been made"; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'Reservation', ['message' => 'New Room Reservation has been made']); return redirect('myreserv')->with(['reserv_status' => 'Room_Reservation']); }
/** * Execute the job. * * @return void */ public function handle() { $client = new \GuzzleHttp\Client(['cookies' => true, 'timeout' => 20.0, 'connect_timeout' => 20.0, 'verify' => false, 'headers' => ['User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2398.0 Safari/537.36', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding' => 'gzip, deflate, sdch', 'Accept-Language' => 'en-US,en;q=0.8', 'Dnt' => '1', 'Pragma' => 'no-cache', 'Cache-Control' => 'no-cache', 'Host' => 'ais-cs.ucsc.edu', 'Origin' => 'https://ais-cs.ucsc.edu', 'Connection' => 'keep-alive', 'DNT' => 1]]); $counter = 0; do { $decrypted = Crypt::decrypt($this->user->gold_password); $login = $client->request('POST', 'https://ais-cs.ucsc.edu/psc/csprd/EMPLOYEE/PSFT_CSPRD/c/SA_LEARNER_SERVICES.SSR_SSENRL_CART.GBL?cmd=login&languageCd=ENG', ['form_params' => ['timezoneOffset' => 480, 'Submit' => 'Sign In', 'userid' => $this->user->cruz_id, 'pwd' => $decrypted]]); $html = new \Htmldom(); $html->load($login->getBody()); $classes = []; $rows = $html->find('table.PSLEVEL2GRIDWBO a.PSHYPERLINK'); foreach ($rows as $row) { $classes[] = $row->plaintext; } $counter += 1; } while (count($classes) == 0 && $counter != 10); $class_name = []; $class_number = []; foreach ($classes as $indice => $value) { //DAN DID THIS $findPosition = strpos($classes[$indice], '('); $subString = rtrim(substr($classes[$indice], 0, $findPosition - 1)); $class_name[$indice] = $subString; $findPosition = strpos($classes[$indice], '('); $subString = substr($classes[$indice], $findPosition + 1, 5); $class_number[$indice] = $subString; } //echo 'classes:' . count($class_name); $pusher_data = []; foreach ($class_name as $indice => $value) { $class = SchoolClass::where('class_id', $class_number[$indice])->first(); if (!$class) { $class = SchoolClass::create(['class_name' => $class_name[$indice], 'class_id' => $class_number[$indice]]); } UserClass::create(['user_id' => $this->user->id, 'class_id' => $class->id, 'priority' => 1]); $pusher_data[] = ['class_name' => $class->class_name, 'class_id' => $class->id, 'user_id' => $this->user->id, 'priority' => 1]; } LaravelPusher::trigger('user' . $this->user->id, 'register', ['message' => $pusher_data]); }
/** * save a customer inwuiry and send an email to admin email which is hardcoded * * @param Request $request */ public function saveinquiry(Request $request) { $inq = new Inquiry(); $inq->name = $request->input('fullname'); $inq->company = $request->input('company'); $inq->email = $request->input('email'); $inq->message = $request->input('message'); $inq->status = '1'; $inq->save(); // save notification to DB and to pusher $newNotification = new Notifications(); $newNotification->notification = "New Customer Inquiry!"; $newNotification->body = 'New Customer Inquiry has been made.'; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'new_backup_notification', ['message' => 'New Customer Inquiry has been made.']); // get admin's email $email = User::where('role', 'admin')->first()->email; Mail::send('emails.inquiry', ['inq' => $inq], function ($message) use($email) { $message->from(env('MAIL_FROM'), env('MAIL_NAME')); //$message->to("*****@*****.**")->subject('Amalaya Reach Inquiry'); $message->to($email)->subject('Amalaya Reach Inquiry'); }); }
public function bar() { $messages = '{"name":"Joe","message":"Hello world!"}'; dd(Pusher::trigger('test_channel', 'my-event', ['message' => 'Test passed'])); }
/** * Return user if exists; create and return if doesn't * * @param $user * @return User */ private function findOrCreateUser($user, $provider) { $authUser = User::where('email', $user->email)->first(); if ($authUser) { Session::put('user_role', $authUser->role); return $authUser; } else { Session::put('user_role', 'customer'); /** * Random Generated Password for Social Logged Users * * @var string */ $pwd = str_random(8); $providerName = "Social Media"; switch ($provider) { case 'facebook': $providerName = "Facebook"; break; case 'google': $providerName = "Google+"; break; default: $providerName = "Social Media"; break; } $mailData = ['name' => $user->name, 'pwd' => $pwd, 'provider' => $providerName, 'email' => $user->email]; $newNotification = new Notifications(); $title = "New user registered!"; $message = $user->name . ' just registered using ' . $providerName . '.'; $icon = "fa-user"; $link = 'dashboard/users'; $for = "admin"; $newNotification->title = $title; $newNotification->body = $message; $newNotification->icon = $icon; $newNotification->link = $link; $newNotification->for = $for; $newNotification->readStatus = '0'; $newNotification->save(); Pusher::trigger('notifications', 'success_notification', ['message' => $message, 'icon' => $icon, 'link' => $link, 'title' => $title, 'for' => $for]); //Send Welcome Email Mail::send('emails.register-success-social', $mailData, function ($message) use($user) { $message->to($user->email)->subject('Welcome to PlanMyEvent.me'); }); return User::create(['name' => $user->name, 'email' => $user->email, 'password' => bcrypt($pwd), 'provider_id' => $user->id, 'avatar' => $user->avatar, 'provider' => $provider, 'provider_id' => $user->id, 'role' => 'customer']); } }
/** * This function submits the changes made in event progress * * @param string POST data (from event progress update) * * @return if successful, 'Events Assigned To Me' page for Team Member */ public function EditProgress() { $input = Request::all(); $iName = $input['EventID']; $user_id = \Auth::user()->id; $iPercentage = array(); $iStatus = array(); $iTaskID = array(); if (isset($_POST['doneprogress'])) { $today = Carbon::today()->toDateString(); $em = Quote_Requests::select('*')->where('id', $iName)->first(); $mailData = ['EventID' => $iName, 'EventType' => $em->EventType, 'DueDate' => $em->DueDate, 'CompletedOn' => $today, 'FirstName' => $em->UserName]; //send email to customer Mail::send('emails.event-complete', $mailData, function ($message) use($em) { $message->to($em->Email, 'Test')->subject('Your Event Is Ready!'); }); //send a notification to customer $newNotification = new Notifications(); $newNotification->title = 'Event Complete'; $newNotification->body = $em->EventType . ' planning is complete'; $newNotification->icon = 'icon'; $newNotification->link = 'dashboard/events/progresscustomer?EventID=' . $iName; $newNotification->readStatus = '0'; $newNotification->save(); $message = $em->EventType . ' planning is complete'; $icon = 'icon'; $link = 'dashboard/events/progresscustomer?EventID=' . $iName; $title = 'Event Complete'; Pusher::trigger('notifications', 'success_notification', ['message' => $message, 'icon' => $icon, 'link' => $icon, 'title' => $title]); return redirect('dashboard/events/myevents')->with('message', 'You Completed The Event'); } else { foreach ($input['percentage'] as $x) { $iPercentage[] = $x; } foreach ($input['status'] as $y) { $iStatus[] = $y; } foreach ($input['taskid'] as $z) { $iTaskID[] = $z; } foreach ($input['taskid'] as $z => $value) { $today = Carbon::today()->toDateString(); Event_Tasks::where('EventID', $iName)->where('id', $iTaskID[$z])->update(['Percentage' => $iPercentage[$z], 'Status' => $iStatus[$z], 'LastUpdated' => $today]); } return redirect('dashboard/events/myevents')->with('message', 'Record Added Successfully'); } }
public function PushAttack($pos, $status) { $game = Game::find(Session::get('gameid')); if (Session::get('player') == '1') { $channel = "{$game->player2id}"; //canal envios al jugador 2 } else { $channel = "{$game->player1id}"; //canal envios al jugador 1 } PusherLaravel::trigger($channel, 'attackme', ['position' => $pos, 'stat' => $status]); // ataque al oponente }
/** * @param int $pos * @return Response */ public function pusher($pos) { //dd($pusher); PusherLaravel::trigger('my-channel', 'my-event', ['message' => "holi"]); //PusherLaravel::trigger('toplayer2', 'actualizar', ['message' => $pos]); //dd($pusher); //$pusher = App::make('pusher'); //dd($pusher); //$pusher->trigger( 'test-channel', // 'test-event', // array('text' => 'Preparing the Pusher Laracon.eu workshop!')); //$pusher->trigger('toplayer2', 'actualizar', array('message' => $pos)); //Pusher::trigger('my-channel', 'my-event', ['message' => "hola"]); return json_encode($pos); }
public function resetmatch() { \DB::table('coments')->truncate(); PusherLaravel::trigger('post_channel', 'reset', 'new match inc'); return redirect()->route('coments.index'); }