Passed
Push — main ( 9dcd8c...750ca5 )
by Tan
03:18
created

CheckSqlModeCommand::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 11
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace CSlant\Blog\Core\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\DB;
7
8
class CheckSqlModeCommand extends Command
9
{
10
    protected $signature = 'check:sqlmode';
11
    protected $description = 'Check the current SQL mode of the database';
12
13
    public function handle()
14
    {
15
        $mode = DB::select("SELECT @@sql_mode as sql_mode")[0]->sql_mode ?? 'unknown';
16
17
        $this->info("🔍 Current sql_mode:");
18
        $this->line($mode);
19
20
        if (str_contains($mode, 'ONLY_FULL_GROUP_BY')) {
21
            $this->warn("⚠️  ONLY_FULL_GROUP_BY is enabled. Group By is strict.");
22
        } else {
23
            $this->info("✅ ONLY_FULL_GROUP_BY is disabled. Can use Group By without strict mode.");
24
        }
25
    }
26
}
27