Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.15k stars 891 forks source link

Fake fields trying to be inserted in DB fields that does not exists #1734

Closed passodeluz closed 5 years ago

passodeluz commented 5 years ago

Bug report

What I did:

Created fake columns like the docs explain, several fields, to store in another json field. CRUD example [ 'name' => 'host', 'label' => 'Host', 'hint' => 'Endereço de conexão(IP)', 'type' => 'text', 'allows_null' => false, 'fake' => true, 'store_in' => 'local_options', 'tab' => 'Configurações', ] MODEL protected $fillable = [ 'name', 'api_monitor_id', 'api_monitor_options', 'local_options', 'customer_id', 'monitor_type', 'protocol_rtsp', 'type_rtsp', 'protocol_http', 'type_http', 'protocol', 'type', 'host', 'port', 'path', 'muser', 'mpass', ]; protected $casts = [ 'api_monitor_options' => 'array', 'local_options' => 'array' ]; protected $fakeColumns = ['local_options'];

What I expected to happen:

To save the fake fields only in the json column (local_options) and to edit it separated in each field input when updating the record.

What happened:

If fields are al in fillable, the system raises error telling me that MySql did not find the fake field in the database...if I remove the fields from fillable, it not brings the data to make the update, letting the fake fields blank.

What I've already tried to fix it:

I tried to make this configurations and it was not 100% good. But, I remember it was working before.

Backpack, Laravel, PHP, DB version:

backpack/base 1.0.2 backpack/crud 3.5.9 laravel/framework v5.7.15 php 7.2.12 mysql 8

passodeluz commented 5 years ago

My mistake, I found that the laravel/backpack was passing in a code that I was not expecting and removing fields...I have to adjust my code to not remove when saving the record, just before save.