CheckSqlModeCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
eloc 10
c 2
b 0
f 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 2
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
12
    protected $description = 'Check the current SQL mode of the database';
13
14
    public function handle(): void
15
    {
16
        $mode = DB::select("SELECT @@sql_mode as sql_mode")[0]->sql_mode ?? 'unknown';
17
18
        $this->info("🔍 Current sql_mode:");
19
        $this->line($mode);
20
21
        if (str_contains($mode, 'ONLY_FULL_GROUP_BY')) {
22
            $this->warn("⚠️  ONLY_FULL_GROUP_BY is enabled. Group By is strict.");
23
        } else {
24
            $this->info("✅ ONLY_FULL_GROUP_BY is disabled. Can use Group By without strict mode.");
25
        }
26
    }
27
}
28