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

CheckSqlModeCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

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
    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