[BE] ArcadeCRUDController — admin CRUD for arcade games & payout config

Open
#474 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
laravel, php
Domain
backend

Research direction

Use ProductCRUDController as the reference for the CRUDController pattern, and add the new /arcadeGames entry to the admin Route::resources array in routes/web.php. The ArcadeGame model (#460) and arcade_games table (#458) are prerequisites, and neither is linked here, so check they exist first. Done means GET /admin/arcadeGames renders, invalid payout_config JSON fails validation, and slug uniqueness per edition holds on create and update.

Written by the indexing model from the issue text.

Description

backend gamification P1

Context & Objective

Create ArcadeCRUDController — the admin backend for managing arcade games. Admins can create game entries per edition, toggle them on/off, adjust wager limits, and edit the payout_config JSON to tune multipliers without a code deployment.

This controller follows the exact same CRUDController extension pattern as ProductCRUDController.

Files to Create / Modify

  • Create: app/Http/Controllers/ArcadeCRUDController.php
  • Modify: routes/web.php — add '/arcadeGames' => ArcadeCRUDController::class to the admin Route::resources array

Technical Requirements

class ArcadeCRUDController extends CRUDController
{
    protected string $model = ArcadeGame::class;
    protected string $view  = 'ArcadeGames';

    protected array $rules = [
        'edition_id'    => 'required|exists:editions,id',
        'slug'          => 'required|string|max:64',
        'name'          => 'required|string|max:255',
        'is_active'     => 'boolean',
        'is_pvp'        => 'boolean',
        'min_wager'     => 'required|integer|min:1',
        'max_wager'     => 'required|integer|min:1|gte:min_wager',
        'daily_win_cap' => 'nullable|integer|min:1',
        'payout_config' => 'required|json',   // validated as a JSON string
    ];

    protected function updateRules($old): array
    {
        // Slug must be unique per edition, excluding this record
        return array_merge($this->rules, [
            'slug' => [
                'required', 'string', 'max:64',
                Rule::unique('arcade_games')->where('edition_id', request('edition_id'))
                    ->ignore($old->id),
            ],
        ]);
    }

    protected function storeRules(): array
    {
        return array_merge($this->rules, [
            'slug' => [
                'required', 'string', 'max:64',
                Rule::unique('arcade_games')->where('edition_id', request('edition_id')),
            ],
        ]);
    }

    protected function with(): array
    {
        return ['editions' => Edition::all()];
    }

    protected function created(array $new): ?array
    {
        // payout_config arrives as a JSON string; decode before storing
        $new['payout_config'] = json_decode($new['payout_config'], true);
        return $new;
    }

    protected function updated($old, array $new): ?array
    {
        $new['payout_config'] = json_decode($new['payout_config'], true);
        return $new;
    }
}

Register in routes/web.php:

Route::resources([
    ...existing...
    '/arcadeGames' => ArcadeCRUDController::class,
    ...
]);

Acceptance Criteria

  • GET /admin/arcadeGames renders the admin index page
  • Create with valid JSON payout_config succeeds; invalid JSON returns validation error
  • Slug unique-per-edition constraint is enforced on create and update
  • payout_config is stored as a proper JSONB value (not a string) in the database
  • is_active and is_pvp fields are handled as booleans (checkboxes in FE)
  • All existing admin middleware (can:admin) applies via the route group

Dependencies

  • #458 (arcade_games table)
  • #460 (ArcadeGame model)
Dominant language
Vue
Stars
12
Forks
1
Avg merge
3d 34m
Merged PRs (30d)
2

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from semanadeinformatica/website

All issues in semanadeinformatica/website

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.