<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;

use App\Models\GameDetail;
use Illuminate\Http\Request;

class ResultPublishController extends Controller
{
    public function index($id)
    {
        @$game = GameDetail::findorfail($id);
        return view('admin.result_publish.index', compact('game'));
    }

    public function create()
    {
        $gameDetails = GameDetail::all();
        return view('admin.result_publish.create', compact('gameDetails'));
    }

    public function store(Request $request)
    {
        if ($request->ajax()) {
            // Perform validation on the request data if needed
    
            // Save the data to your desired storage/database
            // For example, you can iterate over the received data array and save each row to the database
    
            // Return a JSON response indicating the status and message
            return response()->json([
                'status' => 'ok',
                'message' => $request->all()
            ]);
        }
        return response()->json([
            'status' => 'error',
            'message' => 'Invalid request'
        ]);
    }
    
}
