public function postNewsPost() { $posted = Input::get(); $update = new Update(); $update->message = $posted['message']; $update->date = $posted['date']; $update->save(); return Redirect::to('admin/news')->with('success', 'New update has been posted'); }
public function run() { // $faker = Faker::create(); // foreach(range(1, 10) as $index) // { // Update::create([ // ]); // } $updates = new Update(); $updates->pitch_id = 1; $updates->update = "We are half way to our sales goal! We are so proud of everyone's involvement. Tell your friends. More is on the way."; $updates->user_id = 1; $updates->save(); $updates = new Update(); $updates->pitch_id = 1; $updates->update = "We will be showing a new video this week showing our brewery facility. Get excited."; $updates->user_id = 1; $updates->save(); }
$json = array('error' => 'Your update title cannot be empty.'); exit(json_encode($json)); } // update can't be empty if ($message == '') { $json = array('error' => 'Your update message cannot be empty.'); exit(json_encode($json)); } // get acceptedID $accepted = Accepted::getByUserID(Session::getUserID(), $task->getID()); // update status $accepted->setStatus($status); $accepted->save(); // create the update $update = new Update(array('creator_id' => Session::getUserID(), 'accepted_id' => $accepted->getID(), 'project_id' => $project->getID(), 'title' => $title, 'message' => $message)); $update->save(); // save uploaded files to database foreach ($_POST['file'] as $stored => $orig) { $stored = Filter::text($stored); $orig = Filter::text($orig); Upload::saveToDatabase($orig, $stored, Upload::TYPE_UPDATE, $update->getID(), $project->getID()); } // log it $logEvent = new Event(array('event_type_id' => 'create_update', 'user_1_id' => Session::getUserID(), 'project_id' => $project->getID(), 'item_1_id' => $update->getID(), 'item_2_id' => $accepted->getID(), 'item_3_id' => $task->getID(), 'data_1' => $update->getTitle(), 'data_2' => $update->getMessage())); $logEvent->save(); // we're done here Session::setMessage('You created a new update for this task.'); $json = array('success' => '1', 'successUrl' => Url::update($update->getID())); echo json_encode($json); } elseif ($action == 'edit-update') { // validate update
public function postupdate($id) { $update = new Update(); $update->user_id = Auth::user()->user_id; $update->pitch_id = $id; $update->update = Input::get('updateText'); $update->save(); return Redirect::action('PitchesController@show', [$id]); }
/** * Checks if the timestamp of this update has already been * processed, if yes then we will exit, otherwise we will add * it to the database. * * @return void */ protected function checkUpdate() { // If the next update is expected at another timestamp then // we will exit the program and wait for a valid timestamp. if (Cache::has('vatsim.nextupdate') && Carbon::now()->lt(Cache::get('vatsim.nextupdate'))) { Log::info('Exit before next update ' . Cache::get('vatsim.nextupdate')); exit(0); } // If the update already exists with the current timestamp // then we would want to exit the program as we do not want // any duplicate position reports if (!is_null(Update::whereTimestamp($this->updateDate)->first())) { Log::info('Exit already exists ' . $this->updateDate); exit(0); } // Otherwise the new update time will be added to the database $update = new Update(); $update->timestamp = $this->updateDate; $update->save(); // Store the update ID in a class variable for position reports $this->updateId = $update->id; // Store the next update timestamp in the database Cache::forever('vatsim.nextupdate', $this->nextUpdate); }