I don't know if it will fix your problem but you don't need the parenthesis after Game.
$game = new Game
I'm not sure if it will give you the answers you need but if you throw http://laravel.io/bin/zwW4r into your routes file you should be able to see what is being sent to your DB. I would start there to make sure the sql you intend is being sent. If it is then I would try var_dump-ing the game object before saving. If that doesn't solve it let us know, I'll do some testing to help if I can.
The code you have doesn't insert anything twice, so there are 2 things I can think of:
Hi kulkarp,
Did you define the app/config/database.php file?
Did you create the database and the migrations for it?
@jarektkaczyk Thank you the response.
Even I thought the same thing - visiting page twice, but I am sure that isn't the case. No, I am not even sure how to define event listener in php/laravel, so no I haven't done anything like that.
Hi kulkarp,
Did you define the app/config/database.php file?
Did you create the database and the migrations for it?
@codeATbusiness yes, I have defined database.php. I created the database manually, but the single table and alterations to it using migrations.
try to use a diferrent path
Route::get('/add', function(){
$game = new Game();
$game->name = 'Assasins Creed';
$game->description = "Assasins Vs Templars";
$game->save();
});
does it still add it two times?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community