P
P
Pavel2018-11-14 15:09:16
Laravel
Pavel, 2018-11-14 15:09:16

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',
    ];

and here are the columns
5bec0f5d641fe898561518.png
and the error when inserting data
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`....

I myself have never written like that - the saints have always been identical to the names of the columns. And it works in production. Where am I missing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vism, 2018-11-14
@vism

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 question

Ask a Question

731 491 924 answers to any question