I am beginner in Laravel. I use in my project Laravel 5.8.
I have schema:
Schema::create('statistics', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('company_id')->unsigned();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
$table->text('agent')->nullable();
$table->date('date')->nullable();
$table->ipAddress('ip');
$table->bigInteger('user_id')->default(0);
$table->bigInteger('quest_id')->default(0);
$table->string('browser', 70)->nullable();
$table->string('platform', 70)->nullable();
$table->string('language', 12)->nullable();
$table->engine = "InnoDB";
$table->charset = 'utf8mb4';
$table->collation = 'utf8mb4_unicode_ci';
});
and I have function:
Statistics::select('id', 'ip', 'date', 'user_id')->where('date', '>=', $dateFrom )->where('date', '<=', $dateTo )->where('user_id', $id)->groupBy('ip')->get();
When I have enable strict mode in database.php I have error:
SQLSTATE[42000]: Syntax error or access violation: 1055 'db.statistics.id' isn't in GROUP BY (SQL: select `id`, `ip`, `date`, `user_id` from `statistics` where `date` >= 2019-10-15 00:00:00 and `date` <= 2019-10-22 00:00:00 and `user_id` = 2 group by `ip`)
I like strict mode.
How can I repair my function?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2MIMGyj
via IFTTT
Aucun commentaire:
Enregistrer un commentaire