/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id, $transaction_id) { $account = Bank_account::find($id); if (!$account) { return response()->json(['message' => 'This account does not exist', 'code' => 404], 404); } $transaction_id = $account->activities->find($transaction_id); if (!$transaction_id) { return response()->json(['message' => 'This transaction does not exist for this account', 'code' => 404], 404); } return response()->json(['data' => $transaction_id], 200); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $account = Bank_account::find($id); if (!$account) { return response()->json(['message' => 'This account does not exist', 'code' => 404], 404); } $transactions = $account->activities; // return $account; if (sizeof($transactions) > 0) { return response()->json(['message' => 'You have done transactions on this account, and therefore cannot delete it', 'code' => 409], 409); } $account->delete(); return response()->json(['message' => 'This account has been deleted.', 'code' => 409], 409); }