siki

mail@pastecode.io avatar
unknown
php
2 years ago
1.7 kB
5
Indexable
Never
<?php
    $askepId    = 1;
    $askepSdkis = \DB::table('askep_sdki')
                    ->where('askep_id', $askepId)
                    ->pluck('askep_sdki_id');

    $pluckedSdki = \DB::table('askep_sdki')
                    ->where('askep_id', $askepId)
                    ->pluck('sdki_id');
    
    // list sdki
    $selectedSdki = \DB::table('askep_sdki')
                        ->join('sdki', 'sdki.sdki_id', 'askep_sdki.sdki_id')
                        ->where('askep_id', $askepId)
                        ->get();
    
    // list bd
    $selectedBd = \DB::table('askep_bd')
    ->join('bd', 'bd.bd_id', 'askep_bd.bd_id')
    ->whereIn('askep_sdki_id', $askepSdkis)
    ->get();


    // list dd
    $selectedDd = \DB::table('askep_dd')
    ->join('dd', 'dd.dd_id', 'askep_dd.dd_id')
    ->whereIn('askep_sdki_id', $askepSdkis)
    ->get();

    // list kat - subkat - siki
    $selectedSiki = \DB::table('askep_siki')
    ->join('siki', 'siki.siki_id', 'askep_siki.siki_id')
    ->whereIn('askep_sdki_id', $askepSdkis)
    ->pluck('siki_id');
    
    $katSiki = \DB::table('kat_siki')
    ->whereIn('sdki_id', $pluckedSdki)
    ->get()
    ->toArray();

    foreach($katSiki as $kat) {
        $kat['subkat'] = \DB::table('subkat_siki')
                ->where('kat_siki_id', $kat['kat_siki_id'])
                ->get()
                ->toArray();
        
        foreach($kat['subkat'] as $subkat) {
            $subkat['siki'] = \DB::table('siki')
                ->where('subkat_siki_id', $subkat['subkat_siki_id'])
                ->whereIn('siki_id', $selectedSiki)
                ->get()
                ->toArray();
        }
    }
?>