question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove underscores from column names in setFromDb()

See original GitHub issue

I find myself having to re-write the fields and columns for very basic crud models, just because the titles of the columns have underscores in them. For instance, this is a model that simply has text fields, so the setFromDb() function would be entirely sufficient, but I will need to write all the addColumns() and addFields() functions in order to remove the underscores:

screen shot 2017-04-27 at 10 18 30 am

Would there be any issues caused by labeling these columns and fields with removed underscores?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jsiebachcommented, Sep 6, 2017

@tabacitu I think that would be non breaking and be a good change. I do however like @lloy0076 solution better - a callable function would let me customize the names of all of my columns, without having to re-write all of the fields and columns. There are probably people out there who use snake case for their column names (no friends of mine, to be sure!) who may have different logic for their app. With a callable we could do something like:


$this->crud->setFromDb(function($column){
	$fieldmap = [
		'id' => 'ID',
		'phone_number' => 'Phone Number',
		'email' => 'Email Address'
	];

	return $fieldmap[$column];
});

This avoids all of the fields and columns being manually added, and adds a ton of flexibility. You could even set column titles using application logic if you wanted, ie. using the Crud/Settings package.

0reactions
tabacitucommented, Feb 12, 2018

Yup, I think #688 is a good fix for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove underscore from column names of an R data ...
How to remove underscore from column names of an R data frame? - When we import data from outside sources then the header...
Read more >
How to remove underscores from column names within plots?
One useful answer below is to rename the resulting data frame to replace the underscores with spaces. Another I just thought of is...
Read more >
Show Operation :: 4.1 Docs - Backpack for Laravel
Inside this method, it uses setFromDb() to try to magically figure out all attributes you would like shown for this Model, and shows...
Read more >
Remove underscore for headertext columns - MSDN - Microsoft
I am using this linq query to fetch columns from my DB. protected void Page_Load(object sender, EventArgs e) { string CS = ConfigurationManager....
Read more >
All changes - LiveAgent Changelog
[Fix] Call to a member function getConversationId() on null, ... [Fix] Remove useless field "Confirm message" from pre-chat edit dialog (#7941) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found