Gertjan Brouwer
Gertjan Brouwer

Reputation: 1016

Laravel model create not null violation when value is set

SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "title" violates not-null constraint

is thrown when executing the create function on the product model. This is the code I am executing:

$title = $csvLine[18];
$description = $csvLine[0];
$link = $csvLine[17];

$productTemp = Product::create([
 'title' => $title,
 'description' => $description,
 'link' => $link,
]);

When adding an echo statement inbetween assigning csv values to variable and creating the product, it is not null. But when I create it immediatly throws a null contrains violation.

Upvotes: 0

Views: 1414

Answers (1)

Turbo
Turbo

Reputation: 134

You most likely have not declared title as fillable in the Products model.

Upvotes: 3

Related Questions