query that worked in Laravel 5.2 give me error in Laravel 5.3

只谈情不闲聊 提交于 2019-12-05 06:16:32

Go to your config/database.php folder. In mysql configuration array, change strict => true to strict => false, and everything will work nicely.

As per documentation your join query should like this Reference -:https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0

 $galleries = Gallery::with(array(
        'images' => function ($query) {
            $query->orderBy('order', 'asc');
        }
    ))
    ->with('votes')
    ->leftJoin('votes',function($query){
                 $query->on('votes','gallery')->where('votes', 'votes.votable_id', '=', 'gallery.id')->where('votes.votable_type','App\Gallery');   })->selectRaw(
        'gallery.*, count(case votes.status when "upvote" then 1 else null end) - count(case votes.status when "downvote" then 1 else null end) as points'
    )
    ->groupBy('gallery.id')
    ->orderBy('points', 'desc')
    ->published()->orderBy('gallery.created_at', 'desc')->paginate(30);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!