fabianpnke
1 week ago
120
7
Laravel

Field doesn't have a default value, even if specified

Posted 1 week ago by fabianpnke

Hi all,

can someone help me out? I want to create an Eloquent Model, but Laravel is keeping throwing this error.

Even if I have specified the 'concert_id'....

\App\Seat::create([
  'concert_id' => 1,
  'x_pos' => 1,
  'x' => 1,
  'y_pos' => 1,
  'y' => 1,
  'way' => false,
  'cart' => null,
  'available' => true,
  'locked' => false,
  'wheelchair' => false,
  'wheelchair_optional' => false,
  'price' => 1200,
  'color' => '#00AE00',
]);
Illuminate/Database/QueryException with message 'SQLSTATE[HY000]: General error: 1364 Field 'concert_id' doesn't have a default value (SQL: insert into `seats` (`updated_at`, `created_at`) values (2020-03-26 20:38:36, 2020-03-26 20:38:36))'

Many thanks, Fabian

Please sign in or create an account to participate in this conversation.