0
votes

I am working in laravel 5.3. I have issue to run query.I am trying for groupby query but its not working and error like Call to undefined method Illuminate\Database\Query\Builder::only_full_group_by(). My code like

public function showcart()
{

        $cart = DB::table('cartshow')->only_full_group_by('pro_id')->get(); die();

        $i = 1;
        foreach($cart as $tt)
        {

            $count = DB::table('cartlist')->where('pro_id',$tt->pro_id)->sum('qnty');

            $sel_pro= DB::table('product') -> where('id',$tt->pro_id)->first();

            $proname = $sel_pro->name;
            $price = ($sel_pro->price) * $count;

      echo $cartdata  ="<tr>
                                <td>$proname<br><small>Swaminarayan, Extra Hot, Cheese</small></td>
                                <td style='vertical-align:middle'>
                                <input type='button' value='-' onclick='qtyminus($tt->pro_id);' class='qtyminus' field='quantity' />
                                <input type='text' name='quantity' value='$count' class='qty' id='txt$tt->pro_id'/>
                                <input type='button' value='+' onclick='qtyplus($tt->pro_id);' class='qtyplus' field='quantity' />
                                </td>
                                <td class='text-right' style='vertical-align:middle'><button data-id ='$tt->pro_id' type='button' class='btn btn-xs btn-info'><i class='fa fa-remove'></i></button></td>
                            </tr>";

    }   

}   
1
I'm not able to find any only_full_group_by method in Laravel, am I missing something ? Can you post the reference to your method ? - jaysingkar
you can not use the method like this. Laravel QueryBuilder does not have that method defined.Since, your link points to version 5.7 only_full_group_by is default. So, instead use groupBy(). - jaysingkar

1 Answers

0
votes

only_full_group_by is one of the MySQL modes. You can not call only_full_group_by on the QueryBuilder since there isn't any only_full_group_by method defined in QueryBuilder.
Yo use Group By in Laravel use groupBy() method.

$cart = DB::table('cartshow')->groupBy('pro_id')->get();

Since, in comments you have provided the MySQL link of version 5.7 only_full_group_by is the default mode.

If you want to manipulate the MySQL modes here's the reference