/**
  * Update the specified resource in storage.
  *
  * @param $userId
  * @param $id
  * @return Response
  * @throws AccessDenied
  * @throws BadRequest
  */
 public function update($userId, $id)
 {
     $user = $this->getAvailableUser($userId);
     if (!($timerow = Timerow::find($id))) {
         throw new BadRequest(sprintf('%s timerow not found', $id));
     }
     if ($timerow->user->id != $user->id) {
         throw new AccessDenied("You can't update this row");
     }
     $timerow->update(MyInput::all());
     $this->response($timerow);
 }
Пример #2
0
 public function login()
 {
     $data = MyInput::all();
     if (Auth::attempt($data)) {
         $user = Auth::user();
         $user->api_token = md5(uniqid());
         $user->save();
         $user->hours;
         $user->timerows;
         return $this->response(['token' => $user->api_token, 'user' => $user]);
     } else {
         throw new AccessDenied('Incorrect email or password');
     }
 }