Hacker News new | ask | show | jobs
by moneyrich1 4775 days ago
one that got me was in a controller you can:

     return Model::Find('asdf=1');
and it outputs a json serialized array as html. so your ajax action is like one line of code, yay. or you can $row = Model::Find('asdf=1'); and manipulate in php from there.

http://www.youtube.com/watch?v=QSt9rBa_oUM this guys series on laravel is really good.

1 comments

> and it outputs a json serialized array as html

Actually, it renders a raw JSON response - a single object of 'unguarded' attributes (all by default) for the model with Content-Type: application/json set. It has nothing to do with HTML.

Your syntax is invalid too. To do what you want you'd actually call

    return Model::where('asdf', 1)->first();