Php Laravel 5 json响应数组

Php Laravel 5 json响应数组,php,laravel,Php,Laravel,我遵循了关于Laravel和AngularJS的教程,试图将公共函数转换为laravel5。代码如下: public function store() { Comment::create(array( 'author' => Input::get('author'), 'text' => Input::get('text') )); return Response::json(a

我遵循了关于
Laravel
AngularJS
的教程,试图将
公共函数
转换为laravel5。代码如下:

public function store()
    {
        Comment::create(array(
            'author' => Input::get('author'),
            'text' => Input::get('text')
        ));

        return Response::json(array('success' => true));
    }
我用这个转换了它:

public function store()
    {
        Comment::create(array(
            'author' => Request::get('author'),
            'text' => Request::get('text')
        ));
    }

现在,返回响应::json(array('success'=>true))行怎么样?如何将其转换为Laravel 5?谢谢。

不确定转换为Laravel 5是什么意思,这一行代码本身就是有效的Laravel 5代码,但您可以利用Laravel 5提供的良好辅助功能:

return response()->json([
    'success' => true
]);

在Laravel5中,如果您只返回一个数组,它将作为json显示在输出中,因此只返回数组('success'=>true);可以。