laravel group by query error
<p>I am trying to get all notification list of a user group by Source_id and type and selecting 'Source_id', 'type','created_at':</p>

<pre><code>    $notificationlist = Notification::select(['Source_id', 'type','created_at'])
        -&gt;where('user_id', $user-&gt;id)
        -&gt;groupby('Source_id','type')
        -&gt;orderby('created_at', 'desc')
        -&gt;get();
</code></pre>

<p>but i get :</p>

<pre><code>SQLSTATE[42000]: Syntax error or access violation: 1055 'a.notifications.created_at' isn't in GROUP BY 
(SQL: select `Source_id`, `type`, `created_at` from `notifications` where `user_id` = 1 group by `Source_id`, `type` order by `created_at` desc)
</code></pre>

<p>Notification Model:</p>

<pre><code>&lt;?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Notification extends Model
{
    protected $fillable = ['activity_type','type','Source_id', 'created_at'];


    public function user()
    {
        return $this-&gt;belongsTo('Cartalyst\Sentinel\Users\EloquentUser');
    }
}
</code></pre>

<p>schema Notification:</p>

<pre><code>Schema::create('notifications', function (Blueprint $table) {
            $table-&gt;increments('id');
            $table-&gt;integer('user_id')-&gt;unsigned();
            $table-&gt;integer('Source_id')-&gt;unsigned();
            $table-&gt;integer('type');
            $table-&gt;integer('activity_type');
            $table-&gt;timestamps();
            $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')
                -&gt;onDelete('cascade')
                -&gt;onUpdate('cascade');
            $table-&gt;timestamps();
        });
</code></pre>

<p>but when i ran same query in phpmyadmin it executed successfully</p>

<p><a href="https://i.stack.imgur.com/phmXq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/phmXq.png" alt="enter image description here"></a></p>

<p>as error says to include created_at in group by but if i include it then i can't get my desired output as all created_at timestamp is unique</p>