I have a strange problem with Eloquent which I am trying to do as follows:
$this->node = \DB::table('permission') ->select('permission.id', 'object.name as object_name', 'permission.created_at', 'object.id as object_id') ->join('object', 'object.id', '=', 'permission.object_id') ->join('action', 'action.id', '=', 'permission.action_id') ->where('permission.person_id', $this->person['id']) ->groupBy('permission.object_id') ->orderBy('permission.created_at', 'desc') ->paginate(5);
Laravel Framework will report an error:
QueryException on line 761 Connection.php: SQLSTATE [42000]: syntax error or access violation: 1055 'permission.id' is not in GROUP BY (SQL: select permission . id , object . name as object_name , permission . created_at , object . id as object_id of permission internal connection of object to object = permission . object_id internal connection of action to action . id = permission . action_id where permission . person_id = 1 group by permission . object_id order permission . created_at restriction descending 5 offset 0)
I added the Eloquent DB :: listen debugging function to the AppServiceProvider:
use Illuminate\Support\Facades\DB; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function boot() {
And he prints this SQL query:
select `permission`.`id`, `object`.`name` as `object_name`, `permission`.`created_at`, `object`.`id` as `object_id` from `permission` inner join `object` on `object`.`id` = `permission`.`object_id` inner join `action` on `action`.`id` = `permission`.`action_id` where `permission`.`person_id` = 1 group by `permission`.`object_id` order by `permission`.`created_at` desc limit 5 offset 0
What is really in MySQL through PhpMyAdmin , and here is the result for the query:
Even So, I tested the command directly in mysql and it works fine, look at the mysql output:

Any idea?
thanks