1

インストールしました: https://github.com/barryvdh/laravel-debugbar composer を使用します。

インストール手順に従いましたが、完了しました。

しかし、PDO mysql クエリを確認するにはどうすればよいですか? HTML/ビューのレンダリングなしで、RESTful api を構築しています。

用途があるかどうかはわかりませんが、私のコードの例をいくつか示します。

    // the controller
    public function feed($exclude = null) {

        $feed = $this->item->feed()->with('attributes', 'images', 'user');

        if($exclude)
            $feed->whereNotIn('id', explode(',', $exclude));
        return ['items' => $this->itemTransformer->transformCollection($feed->get()->toArray())]; // woud like to debug this query
    }

    // the router
    Route::get('items/feed/{exclude?}', ['protected' => true, 'uses' => 'ItemsController@feed']);
4

2 に答える 2

0

簡単:

    public function feed($exclude = null) {

        $feed = $this->item->feed()->with('attributes', 'images', 'user');

        if($exclude)
            $feed->whereNotIn('id', explode(',', $exclude));

        $items = ['items' => $this->itemTransformer->transformCollection($feed->get()->toArray())];

        echo json_encode($items); // echo instead of return. Will trigger HTML to render and
    }
于 2014-11-13T21:31:24.797 に答える