コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  *
  * @author Bertrand Kintanar <*****@*****.**>
  */
 public function run()
 {
     DB::table('users')->delete();
     $users = $this->users();
     foreach ($users as $user) {
         User::create($user);
     }
 }
コード例 #2
0
 /**
  * Delete User.
  *
  * @SWG\Delete(
  *     path="/users/profile/{user_id}",
  *     tags={"Users"},
  *     summary="Delete User",
  *     @SWG\Response(response="200", description="Success",
  *         @SWG\Schema(
  *             title="data",
  *             type="object",
  *             @SWG\Property(property="status", type="string", default="Record successfully deleted.", description="Status message from server"),
  *             @SWG\Property(property="user", ref="#/definitions/User"),
  *         )
  *     ),
  *     @SWG\Response(response="500", description="Could not delete data",
  *         @SWG\Schema(
  *             title="data",
  *             type="object",
  *             @SWG\Property(property="error", type="string", default="could_not_delete_data"),
  *         )
  *     ),
  *     @SWG\Parameter(
  *         name="user_id",
  *         in="path",
  *         description="USER_ID to delete",
  *         required=true,
  *         type="integer",
  *         default=8
  *     )
  * )
  *
  * @param Request $request
  *
  * @return mixed
  *
  * @author Donna Borja <*****@*****.**>
  */
 public function destroy(Request $request)
 {
     // check if user exists
     $user = $this->user->whereId($request->user_id)->first();
     if (!$user) {
         return API::response()->array(['status' => USER_DOES_NOT_EXIST])->statusCode(500);
     }
     // update users table
     try {
         $this->user->whereId($request->user_id)->delete();
     } catch (Exception $e) {
         return API::response()->array(['status' => USER_DELETE_FAIL])->statusCode(500);
     }
     return API::response()->array(['status' => USER_DELETE_SUCCESS, 'user' => $user])->statusCode(200);
 }
コード例 #3
0
 /**
  * @param UserRequest $request
  *
  * @return \Illuminate\Http\JsonResponse
  *
  * @author Bertrand Kintanar <*****@*****.**>
  */
 public function register(UserRequest $request)
 {
     $newUser = ['email' => $request->get('email'), 'password' => bcrypt($request->get('password'))];
     $user = User::create($newUser);
     $token = JWTAuth::fromUser($user);
     return response()->json(compact('token'));
 }