Well i guess thats because mass assignment exception is turned off during seeding
turn it on in your seeder class, and i guess it should fix you up
Country::reguard();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
As I understand with the $fillable array in the model I should be able to insert a new data in the database without problems.
My model Country.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
protected $fillable = ['id', 'name', 'iso_code'];
}
My code:
$data = Array(
"id" => 13,
"name" => "Denmark",
"iso_code" => "DNK",
"flag" => "https://soccerama.pro/images/countries//13.png"
);
Country::create($data);
What I want is to simply ignore the "flag" value of di array, but I get the following error in MySQL.
Column not found: 1054 Unknown column 'flag' in 'field list'
I know that I could simply instance a new Country and then assign each value, but it is kind of boring and long to write in other cases.
Any tips?
Edit:
Already edited.. Found out that in a Controller it works, but not in a Seeder. So the question is, how can I do it inside a seeder?
Well i guess thats because mass assignment exception is turned off during seeding
turn it on in your seeder class, and i guess it should fix you up
Country::reguard();
Please or to participate in this conversation.