Exemplo n.º 1
0
function updateStatus($id, $password)
{
    $app = Slim\Slim::getInstance();
    $json = decodeJsonOrFail($app->request->getBody());
    $user = User::with('status', 'groups')->findOrFail($id);
    // authenticate
    if ($user->password !== $password) {
        throw new Exception();
    }
    $statusId = $json['status_id'];
    $statusMessage = $json['status_message'];
    $status = Status::findOrFail($statusId);
    $user->status()->associate($status);
    $user->status_message = $statusMessage;
    $user->save();
    $statusChange = new StatusChange();
    $statusChange->user()->associate($user);
    $statusChange->status()->associate($status);
    $statusChange->status_message = $statusMessage;
    $statusChange->save();
    echo $user->toJson();
    //sendSyncMessage($user->id, true);
}
Exemplo n.º 2
0
 public function getCurrentStatus()
 {
     return $this->statusChange->checkStatus($this->observer);
 }