I followed a tutorial on Laravel
and AngularJS
and trying to convert a public function
to laravel 5. The code is this:
public function store()
{
Comment::create(array(
'author' => Input::get('author'),
'text' => Input::get('text')
));
return Response::json(array('success' => true));
}
I converted it with this:
public function store()
{
Comment::create(array(
'author' => Request::get('author'),
'text' => Request::get('text')
));
}
Now, how about the line return Response::json(array('success' => true))
? How can I convert it to Laravel 5? Thank you.
Not sure what you mean by converting to Laravel 5, this line of code itself is valid Laravel 5 code, but you can leverage nice helper function Laravel 5 provides:
return response()->json([
'success' => true
]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.