duandingqi9442 2013-04-08 00:28
浏览 73
已采纳

php laravel中的数组到字符串转换错误

I am creating an event based website. I am using laravel for this with backbone. I am retrieving data from database using backbonejs with laravel as following

var events = new Events();
new EventsView({el: $("#calendar"), collection: events}).render();
events.fetch();

On the server side I have following controller

class Calendars_Controller extends Base_Controller {

public $restful = true;

public function get_index()
{
    //print_r(Calendar::all() );
    return Calendar::all();
}

}

But this returns following error

Unhandled Exception

Message:

Array to string conversion
Location:

/Applications/MAMP/htdocs/calendar/laravel/response.php on line 272

How can I solve this issue?

  • 写回答

1条回答 默认 最新

  • dscw1223 2013-04-08 01:39
    关注

    If you're not using Laravel 4, you might want to try returning the following from your controller instead:

    $events = Calendar::all();
    return Response::eloquent($events);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部