public function store(Request $req, JsonResponse $res) { $type = $req->json('data.type'); $attrs = $req->json('data.attributes'); $game = $this->game->create($attrs); return new JsonResponse(['data' => $this->serializeGame($game)]); }
/** * Run the database seeds. * * @return void */ public function run() { DB::statement("TRUNCATE TABLE games RESTART IDENTITY CASCADE"); $games = [['name' => 'Donkey Kong'], ['name' => 'Mario Kart']]; foreach ($games as $game) { Game::create($game); } }
public function testGameDelete() { Game::create(['name' => $this->gameName]); Game::create(['name' => $this->gameNameTwo]); $this->json('DELETE', 'games/1'); $this->assertResponseStatus(204); $this->assertEquals(1, Game::count()); }
public function setUp() { parent::setUp(); $this->game = Game::create($this->gameAttrs); $this->gameTwo = Game::create($this->gameAttrsTwo); }