php - Laravel, converting data from raw query to JSON -


this question has answer here:

hy all, can me converting data return model(based on raw query) json.

so in controller have like:

public function get_index() {     $data = something::getdatafromrawquery();      return view::make('....')->with('data', $data); } 

so question how forward json data view controller?

here query:

$apps = db::query('select a.name,     a.desc,     a.sig,     ar.rate         inner join something_else ar     on (a.id=ar.something_id)     order ar.rate desc'  );   return $apps; 

db::query returns simple array, call json_encode directly on it:

$data = something::getdatafromrawquery();  return view::make('....')->with('data', json_encode($data)); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -