lundi 18 février 2019

How to add a fake attribute in Select Query with get() in PHP Laravel

$citizenship_2012 = Citizenship::select('provinces', 'year2012 AS measure')->get();

I wanna join the following column with above select query and return as json output in Laravel?

$years = Schema::getColumnListing('citizenships'); // citizenships table

$year_2012= 'category:'.'"'.$years[2].'"';

in Blade file: var datasetChart = <?php echo preg_replace('/"([a-zA-Z]+[a-zA-Z0-9_]*)":/','$1:',$citizenship_2012); ?>;



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire