<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\UserEloquent;

class VideoGameController extends Controller
{

   public function addgame(Request $request){

        if (!$request->has(['name','url','desc'])){
            return redirect('formgame')->with('message',"Some post data are missing");
        }
        
        $game = new VideoGame;
        $game->name = $request->input('name');
        $game->url = $request->input('url');
        $game->desc = $request->input('desc');

        try {
            // On crée l'utilisateur dans la BDD
            $game->save();
        }
        catch (\Illuminate\Database\QueryException $e) {
            return redirect('gamelist')->with('message','problem');
        }
    } 
}
