Пример #1
0
 /**
  * DELETE /api/accounts/{accounts}
  * @param DeleteAccountRequest $deleteAccountRequest
  * @param Account $account
  * @return Response
  */
 public function destroy(DeleteAccountRequest $deleteAccountRequest, Account $account)
 {
     try {
         $account->delete();
         return response([], Response::HTTP_NO_CONTENT);
     } catch (\Exception $e) {
         //Integrity constraint violation
         if ($e->getCode() === '23000') {
             $message = 'Account could not be deleted. It is in use.';
         } else {
             $message = 'There was an error';
         }
         return response(['error' => $message, 'status' => Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST);
     }
 }
Пример #2
0
 public function delete_account()
 {
     try {
         $account = new Account();
         $account->user_id = auth()->user()->id;
         $account->name = Request::input('name');
         $account->delete($account);
     } catch (PDOException $e) {
         die($e->getMessage());
     }
 }