Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rajucs/cea745d625be736e1ac0b19eba48f1aa to your computer and use it in GitHub Desktop.
Save rajucs/cea745d625be736e1ac0b19eba48f1aa to your computer and use it in GitHub Desktop.
Illuminate\Database\Eloquent\MassAssignmentException
Add [_token] to fillable property to allow mass assignment on [App\Model\Customer].
Solution:
you need to fill the model
From:
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
protected $table = 'customers';
protected $fillable = [
];
}
To:
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
protected $table = 'customers';
protected $fillable = [
'name',
'email',
'number',
'address',
'postcode',
'upazilla_id',
'district_id',
'division_id',
'country',
'created_by_id'
];
}
@YercoZunigaLagos
Copy link

u save me <3

@antoniojobs
Copy link

Você também me salvou S2.

@WeinnySoares
Copy link

My solution was different, I added protected $guarded = ['id']; in the first line of the model

@jesccy
Copy link

jesccy commented Apr 25, 2024

My solution was different, I added protected $guarded = ['id']; in the first line of the model

Same worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment