Answer the question
In order to leave comments, you need to log in
Why does Laravel throw an error on assignment?
Good evening. I am not new to Laravel, after using 5.2 for a long time I decided to try 5.3. Decided to make a simple application. Created a migration
Schema::create('news', function (Blueprint $table) {
$table->increments('id');
$table->string('content');
$table->timestamps();
});
class News extends Model
{
protected $primaryKey = ['id'];
protected $fillable = [
'content', 'created_at', 'updated_at',
];
}
$news = new News();
$news->content = $request->input('content');
$news = new News();
$news->content = "test";
Answer the question
In order to leave comments, you need to log in
Problem solved.
protected $primaryKey = 'id';
not
protected $primaryKey = ['id'];
Noticed it right away)
decided to try 5.3
By the way, created_at and updated_at can be omitted from fillable. And the error is clearly somewhere in the code, but from what is presented it is not visible
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question