Open tabacitu opened 4 years ago
(one could argue that we should make the attributes camelCase
...)
That means it would be pretty simple to do this for Fields. Just make those 2 fields support both camelCase and snake_case.
searchLogic
, visibleInModal
, visibleInTable
, visibleInExport
, visibleInShow
, searchLogic
, orderLogic
, function_name
and function_parameters
, but it could be made to support both camelCase and snakeCase, inside the blade file;This one is more tricky. For consistency between fields and columns, we should probably turn searchLogic
into search_logic
at the CrudPanel level. Either way, for those who have heavily customized their admin panels, or created custom columns, or overwritten their search() method, this will be a breaking change...
Unless we make fields attributes snake_case, but column attributes camelCase, which... could be introduced as a non-breaking change, but... it would fix one inconsistency with another inconsistency.
No snake_case as far as I can tell.
No snake_case as far as I can tell.
All in all, it doesn't look like it'd be too difficult to make camelCase methods a thing in fluent syntax, for everything except Columns. But... what do we do about Columns?!
The fluent objects set whatever method you call as an attribute on that field/column/etc, even if that method doesn't exist on the object itself. So we've kept it simple - whatever method you call on the fluent object, that's the exact name of the attribute that will be set on the field. This makes it 100% backwards-compatible. For example, call
CRUD::field('category')->inline_create(true)
and it will setinline_create
totrue
.But it's ugly. And inconsistent. Sure, it makes sense, but... it's odd to have snake_case methods inside a fluent API - its not very Laravely and it's a little inconsistent with other parts of Backpack (ex - the CrudPanel object).
I wonder if there's a way to allow people do
CRUD::field('category')->inlineCreate(true)
without a breaking change. What if we turn the attribute fromcamelCase
tosnake_case
, by default, before we set it? This could be as simple as:The way I see it:
snake_case
camelCase
datePickerOptions([])
will be available in the field as$field['date_picker_options']
Thoughts anyone? Am I the only one that hates writing snake_case fluent methods? (apart from @tumf87 of course, who reported this)