php - Laravel, converting data from raw query to JSON -
this question has answer here:
- how pass javascript variables php? 12 answers
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
Post a Comment