Crud: What Are Fake Cols/Fields For? (Add Documentation)

Created on 1 Dec 2016  路  2Comments  路  Source: Laravel-Backpack/CRUD

The docs do not state what fake columns and fields are for, or show example of using them.

  1. Fake Fields Trait
  2. Fake Columns Trait

I also don't see the CRUD library using either of these traits in a meaningful way.

Side Note

I originally wanted a "fake field" on the create method of a crud I've created. It polls a remote resource via ajax and updates several db column fields based on the response. This field doesn't correspond to any one column, so I needed a way to create a crud field that is ignored.

Looks like an HTML crud field is the best way for this?

question

Most helpful comment

Hi @zschuessler ,

You can create a field that is ignored by the CRUD's store/update just like you would any other field. The only difference would be NOT to include it in the $fillable property on your model. If you're using $guarded, then it should be guarded.

Fake fields are used in a very specific fashion: they show up on the front-end, but instead of being stored in their own column, they're all bundled into an array and stored as JSON in an "extras" column. It's a handy way to add unimportant fields without creating migrations. It's mostly used in the PageManager package. Each page template can have a bunch of fields, of different types, but they're mostly just text, so it's not important for them to be in a normal form in a relational DB. You can read more about fake fields here.

Cheers!

All 2 comments

Hi @zschuessler ,

You can create a field that is ignored by the CRUD's store/update just like you would any other field. The only difference would be NOT to include it in the $fillable property on your model. If you're using $guarded, then it should be guarded.

Fake fields are used in a very specific fashion: they show up on the front-end, but instead of being stored in their own column, they're all bundled into an array and stored as JSON in an "extras" column. It's a handy way to add unimportant fields without creating migrations. It's mostly used in the PageManager package. Each page template can have a bunch of fields, of different types, but they're mostly just text, so it's not important for them to be in a normal form in a relational DB. You can read more about fake fields here.

Cheers!

Awesome, thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexanderWM picture AlexanderWM  路  3Comments

sokvebolkol picture sokvebolkol  路  3Comments

sonoftheweb picture sonoftheweb  路  3Comments

packytagliaferro picture packytagliaferro  路  3Comments

jorgepires picture jorgepires  路  3Comments