sqlite - Laravel: PHP Artisan Tinker 'SQLSTATE[23000]' error -
so going through series of intro videos laravel , @ database migration part , struggling few things...
i have a) no idea means or referring first foray real command prompt usage , b) how fix it.
any appreciated.
regards.
edit-1: here migration file...
<?php use illuminate\database\schema\blueprint; use illuminate\database\migrations\migration; class createcardstable extends migration { /** * run migrations. * * @return void */ public function up() { schema::create('cards', function (blueprint $table) { $table->increments('id'); $table->string('title'); $table->timestamps(); }); } /** * reverse migrations. * * @return void */ public function down() { schema::drop('cards'); } }
edit 2: here command prompt, working answer below, original laracast tutorial.
it means have supply user-id schema dictates card belongs user. add ['user_id'=>some user id]
array.
alternatively, create cards
relation on user
-model:
class user extends \illuminate\database\eloquent\model { public function cards() { return $this->hasmany(card::class); } }
this way, can create card (assuming have user variable, fx. calling user::first()
, user::find($id)
etc.):
$user->cards()->create([...])
Comments
Post a Comment