/** * Execute the console command. * * @return mixed */ public function handle() { require_once './vendor/twilio/sdk/Services/Twilio.php'; // Get Current TimeStamp $date = new DateTime(); $date = $date->format('Y-m-d H:i:00'); // Get Reminders With TimeStamp $reminders = Reminder::where('reminder', '=', $date)->get(); // Loop Through Reminders foreach ($reminders as $reminder) { // Get User for Reminder $user = User::where('id', '=', $reminder->user_id)->first(); if ($user->textsent < $user->textlimit) { $user->textsent++; // Send Text to User with Reminder Text $account_sid = Config::get('twilio.sid'); $auth_token = Config::get('twilio.token'); $client = new \Services_Twilio($account_sid, $auth_token); $client->account->messages->create(array('To' => $user->telephone, 'From' => Config::get('twilio.from'), 'Body' => $reminder->text)); $reminder->sent = true; $user->save(); } } $reminders->save(); return "Sent Texts"; }
/** * Execute the console command. * * @return mixed */ public function handle() { // This would be a great place to remove code and // put into a package, so that the command simply // calls the package function. // Get unsent reminders $remindersToSend = Reminder::where('fires_at', '<=', new \DateTime('now'))->where('fired_at', '=', NULL)->get(); // Send each reminder foreach ($remindersToSend as $reminder) { echo 'Sending text: ' . $reminder->message . "\n"; // Send text message reminder $account_sid = env('TWILIO_ACCOUNT_SID', ''); // Your Twilio account sid $auth_token = env('TWILIO_AUTH_TOKEN', ''); // Your Twilio auth token $client = new \Services_Twilio($account_sid, $auth_token); $message = $client->account->messages->sendMessage(env('TWILIO_PHONE_NUMBER', ''), env('TEST_RECEIVE_PHONE_NUMBER', ''), $reminder->message); /* echo 'Sent from ' . env('TWILIO_PHONE_NUMBER', '') . '<br/>'; print $message->sid; */ // Record that we have sent this reminder $reminder->fired_at = new \DateTime('now'); $reminder->save(); } }
/** * Execute the console command. * * @return mixed */ public function handle() { // Get Current TimeStamp $date = new DateTime(); $diff = new DateInterval('PT1H'); $date = $date->sub($diff); $date = $date->format('Y-m-d H:i:00'); // Get Reminders With TimeStamp $reminders = Reminder::where('reminder', '=', $date)->get(); // Loop Through Reminders foreach ($reminders as $reminder) { // Get User for Reminder $user = User::where('id', '=', $reminder->user_id)->first(); $user->textsent--; $user->save(); } $reminders->delete(); return "Sent Texts"; }
/** * Execute the console command. * * @return mixed */ public function handle() { $reminders = Reminder::where('utcReminderDate', '<=', \Carbon\Carbon::now()->format('Y-m-d H:i'))->get(); foreach ($reminders as $reminder) { $data = array('title' => $reminder->title, 'date' => $reminder->userReminderDate, 'description' => $reminder->description, 'name' => $reminder->user->firstname); Mail::send('emails.reminder', $data, function ($message) use($reminder) { $message->to($reminder->user->email, $reminder->user->firstname . ' ' . $reminder->user->lastname); $message->subject('A Friendly Remindr'); }); $moveReminder = new SentReminders(); $moveReminder->id = $reminder->id; $moveReminder->memberid = $reminder->memberid; $moveReminder->title = $reminder->title; $moveReminder->userReminderDate = $reminder->userReminderDate; $moveReminder->utcReminderDate = $reminder->utcReminderDate; $moveReminder->description = $reminder->description; $moveReminder->save(); Reminder::destroy($reminder->id); } }
public function getIcs() { $alarms = Alarm::where('closed', '=', false)->orderBy('date1', 'asc')->get(); $reminders = Reminder::where('active', '=', true)->orderBy('expiry', 'asc')->get(); return view('export.ics', ['alarms' => $alarms, 'reminders' => $reminders]); }
/** * Function that deletes a reminder for worker. * * @return Response */ public function deleteReminder() { // Validate Input. $validator = Validator::make(Input::all(), array('reminderId' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'Informacion incompleta!']); } // 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()); } // Get the reminder. $reminder = Reminder::find(Input::get('reminderId')); $reminder->delete(); // Return response. $response['state'] = 'Success'; return response()->json($response); }
<?php use App\Reminder; use App\Worker; use App\User; // Get the worker. $worker = Worker::find(Auth::user()->TypeId); // Now get the Reminders of the worker. $reminders = Reminder::where('WorkerId', '=', $worker->Id)->get(); ?> <ul class="news-items"> @foreach($reminders as $reminder) <li id='reminder-{{ $reminder->Id }}'> <div class="news-item-date"><span class="news-item-day">{{ date('d', strtotime($reminder->Date))}}</span> <span class="news-item-month">{{ date('M', strtotime($reminder->Date))}}</span></div> <div class="news-item-detail" style="width:100%;padding-left:15px;"><p class="news-item-preview">{{ $reminder->Note }}</p> </div> </li> @endforeach </ul>
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Reminder::destroy($id); flash()->success('Remindr was successfully deleted.'); }
public function destroy($id) { $note = Reminder::find($id); $note->delete(); return Response::json('Note Deleted', 200); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Reminder::destroy($id); flash()->success('Your remindr was successfully deleted.'); return redirect('/remindr'); }
public function update(Request $request, $id) { $a = Alarm::findOrFail($id); $action = $request->input('action', 'update'); switch ($action) { case 'mail': $recipients = $request->input('recipient'); $message = $request->input('message'); Mail::send('emails.reminder', ['alarm' => $a, 'mailmessage' => $message], function ($m) use($recipients, $a) { foreach ($recipients as $r) { $m->to($r); } $m->subject('Avviso: ' . $a->simpleName()); }); break; case 'remind': $r = new Reminder(); $r->alarm_id = $a->id; $r->active = true; $r->notes = $request->input('notes', ''); $interval = $request->input('reminder-offset'); $r->expiry = date('Y-m-d', strtotime('+1 ' . $interval)); $r->save(); break; case 'close': $a->closed = true; $a->closer_id = Auth::user()->id; $a->save(); $a->history()->update(['active' => false]); $a->reIterate(); break; case 'update': $a->date1 = $request->input('date1'); $a->notes = $request->input('notes', ''); $a->save(); $path = $a->filesPath(); if ($request->has('existing_attachments')) { $saved = $request->input('existing_attachments'); } else { $saved = []; } $existing = array_diff(scandir($path), ['.', '..']); foreach ($existing as $e) { if (array_search($e, $saved) === false) { unlink($path . '/' . $e); } } if ($request->hasFile('attachments')) { foreach ($request->file('attachments') as $file) { $file->move($path, $file->getClientOriginalName()); } } break; } return redirect(url('/alarms')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $reminders = Reminder::with('symbol')->get(); return response()->json($reminders); }