Answer the question
In order to leave comments, you need to log in
Why doesn't Eloquent in Laravel translate model properties from camelCase to snake_case?
Actually, the question is what. You need to make a couple of simple edits in someone else's application.
Deployed a local copy at home. In all models, properties are written in camel case, and columns in tables are written in snake case.
And every time I try to write / update, I get errors that there are no such columns in the database.
For example, here is the model
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'userId',
'descIntroductionId',
'isBlessed',
'gender',
'firstName',
'lastName',
'imageFileName',
'deceasedAt',
'phone',
'funeralAt',
'includeHebrewDate',
'includeCivilDate',
'descCemeteryId',
'descShivaId',
'shivaAddress',
'descMournersId',
'obituaryImageFileName',
'landingHash',
];
Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'isBlessed' in 'field list' (SQL: insert into `obituaries` (`isBlessed`, `gender`, `firstName`, `lastName`, `deceasedAt`, `phone`, `funeralAt`....
Answer the question
In order to leave comments, you need to log in
logical options 3.
1. Some PDO settings
2. Some settings of the Base
3. In the vendor some kind of transformation for the fields was done by hand
What needs to be checked.
1. requests. Are they in the code in camel case or snake case?
2. responses (model fields). They are in the code in camel case or snake case
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question