I’ve built a backend-only wallet service using Laravel 8, and it’s fully containerized with Docker. The project handles two user roles (Players and Backoffice Agents) and provides JWT-based authentication, Redis caching, and a CI/CD pipeline.
I want to make sure my code structure, database schema, and API design follow best practices and are scalable.
The full project is available here for reference: https://github.com/sirinberhus/wallet-app
I’d really appreciate any feedback, tips, or suggestions to make this backend more robust, secure, and maintainable.
class BoPromotionController extends Controller
{
public function getPromotions()
{
$promotions = Promotion::with('rewards')->paginate(10);
return PromotionResource::collection($promotions);
}
public function createPromotion(CreatePromotionRequest $request, PromotionService $promotionService)
{
$validatedData = $request->validated();
try {
$promotion = $promotionService->create($validatedData);
return response()->json([
'message' => 'Promotion and rewards created successfully',
'promotion' => $promotion->load('rewards') // load rewards relationship
]);
} catch (Exception $e) {
return response()->json([
'error' => 'Failed to create promotion',
'details' => $e->getMessage(),
], 500); //internal server error
}
}
-
1\$\begingroup\$ Welcome to Code Review! If you would like more code than just the two methods reviewed then please expand the code here. For more information Please see this meta post. Links to code hosted on third-party sites are permissible, but the most relevant excerpts must be embedded in the question itself. A stack snippet could also be used to embed the code. \$\endgroup\$Sᴀᴍ Onᴇᴌᴀ– Sᴀᴍ Onᴇᴌᴀ ♦2025年09月05日 23:04:55 +00:00Commented 2 days ago