47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Auth;
|
|
use App\Models\User;
|
|
|
|
class GameController extends Controller
|
|
{
|
|
public function luckyWheel()
|
|
{
|
|
$game_data = [
|
|
['id' => '1', 'label' => 'Giải 1'],
|
|
['id' => '2', 'label' => 'Giải 2'],
|
|
['id' => '3', 'label' => 'Giải 3'],
|
|
['id' => '4', 'label' => 'Giải 4'],
|
|
['id' => '5', 'label' => 'Giải 5'],
|
|
['id' => '6', 'label' => 'Giải 6']
|
|
];
|
|
if (Auth::check()) {
|
|
if (Auth::user()->prize != '') {
|
|
$game_data_user = json_decode(Auth::user()->prize);
|
|
$id = 1;
|
|
$game_data = [];
|
|
foreach ($game_data_user as $game_data_item) {
|
|
$game_data[] = [
|
|
'id' => $id,
|
|
'label' => $game_data_item
|
|
];
|
|
$id++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return view('frontend.game.luckywheel')->with('game_data', $game_data);
|
|
}
|
|
|
|
public function updatePrize(Request $request)
|
|
{
|
|
$user_obj = User::find(Auth::user()->id);
|
|
$user_obj->prize = json_encode($request->prizes);
|
|
$user_obj->save();
|
|
return response()->json(['success' => 'Thành công']);
|
|
}
|
|
}
|