search

Home  >  Q&A  >  body text

php - When laravel defines the same attribute of model and table, this field cannot be updated.

In order to facilitate the operation of attributes in the model, the fields in the database are directly defined as attribute names.

These fields cannot be updated during update.

This uid field in the database cannot be added.

代言代言2722 days ago805

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-06-13 09:23:48

    Either define the fields in the database as attribute names, or use it in the method instead:

    $this->attributes['uid'] = $uid;

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-13 09:23:48

    You can try to rewrite the __get method in this model. When obtaining variables, search them first from $this->attributes. However, this method is exactly the opposite of what laravel wants to do. It is a limited search. Attribute, if you can’t find it, go to $this->attributes and look for it

    I’m kidding, __get cannot be triggered directly :p

    reply
    0
  • Cancelreply