mercredi 15 août 2018

How to change column name in laravel?

I am a beginner of laravel. Now, I would like to retrieve data from database using this code:

$data = Model::select('col1', 'col2', 'col3')->get();

and return $data to another view.

However, I would like to change the name of the columns. For example, changing col1 to column_1 before returning the array to the view. How can I change the column names? I am now using laravel 5.5. Thank you very much!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire