Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
5.2 kB
3
Indexable
Never
listmodulall 
array (
  0 => 
  (object) array(
     'id_master_menu' => 31,  
     'before_modul' => 'mastermembercard', 
     'urutan' => '13',
  ),
  1 => 
  (object) array(
     'id_master_menu' => 32,  
     'before_modul' => 'mastervoid', 
     'urutan' => '13',
  ),
  2 => 
  (object) array(
     'id_master_menu' => 33,  
     'before_modul' => 'masterkompetitor', 
     'urutan' => '13',
  ),
  3 => 
  (object) array(
     'id_master_menu' => 34,  
     'before_modul' => 'masterbuilding', 
     'urutan' => '13',
  ),
  4 => 
  (object) array(
     'id_master_menu' => 35,  
     'before_modul' => 'mastermembercard.indexidcash', 
     'urutan' => '14',
  ),
  5 => 
  (object) array(
     'id_master_menu' => 36, 
     'routes' => 'indexspacebuilding',
     'before_modul' => 'masterbuilding.indexspacebuilding', 
     'urutan' => '14',
  ),
  6 => 
  (object) array(
     'id_master_menu' => 37,
     'name_menu' => 'Check Saldo', 
     'before_modul' => 'mastermembercard.indexchecksaldo', 
     'urutan' => '14',
  ),
  7 => 
  (object) array(
     'id_master_menu' => 41, 
     'before_modul' => 'masterkompetitor.indexkompetitor', 
     'urutan' => '14',
  ),
  8 => 
  (object) array(
     'id_master_menu' => 42, 
     'before_modul' => 'masterkompetitor.indexkompetitor.indexsupermarket', 
     'urutan' => '15',
  ),
)  

listlevelmodul = array (
  0 => 
  (object) array(
     'nama_level' => 'Grand Parent',
     'id_level' => 13,
  ),
  1 => 
  (object) array(
     'nama_level' => 'Parent',
     'id_level' => 14,
  ),
  2 => 
  (object) array(
     'nama_level' => 'Child 1',
     'id_level' => 15,
  ),
  3 => 
  (object) array(
     'nama_level' => 'Child 2',
     'id_level' => 16,
  ),
  4 => 
  (object) array(
     'nama_level' => 'Child 3',
     'id_level' => 17,
  ),
  5 => 
  (object) array(
     'nama_level' => 'Child 4',
     'id_level' => 18,
  ),
  6 => 
  (object) array(
     'nama_level' => 'Child 5',
     'id_level' => 19,
  ),
)  





how to create output this arraymultidimensi : 

array (
  0 => 
  (object) array(
    'id_master_menu' => 31,
    'before_modul' => 'mastermembercard',
    'urutan' => '13',
    'anakan' => 
    array (
      0 => 
      (object) array(
        'id_master_menu' => 35,
        'before_modul' => 'mastermembercard.indexidcash',
        'urutan' => '14',
        'anakan' => 
        array (
        ),
      ),
      1 => 
      (object) array(
        'id_master_menu' => 37,
        'before_modul' => 'mastermembercard.indexchecksaldo',
        'urutan' => '14',
        'anakan' => 
        array (
        ),
      ),
    ),
  ),
  1 => 
  (object) array(
    'id_master_menu' => 32,
    'before_modul' => 'mastervoid',
    'urutan' => '13',
    'anakan' => 
    array (
    ),
  ),
  2 => 
  (object) array(
    'id_master_menu' => 33,
    'before_modul' => 'masterkompetitor',
    'urutan' => '13',
    'anakan' => 
    array (
      0 => 
      (object) array(
        'id_master_menu' => 41,
        'before_modul' => 'masterkompetitor.indexkompetitor',
        'urutan' => '14',
        'anakan' => 
        array (
          0 => 
          (object) array(
            'id_master_menu' => 42,
            'before_modul' => 'masterkompetitor.indexkompetitor.indexsupermarket',
            'urutan' => '15',
            'anakan' => 
            array (
            ),
          ),
        ),
      ),
    ),
  ),
  3 => 
  (object) array(
    'id_master_menu' => 34,
    'before_modul' => 'masterbuilding',
    'urutan' => '13',
    'anakan' => 
    array (
      0 => 
      (object) array(
        'id_master_menu' => 36,
        'before_modul' => 'masterbuilding.indexspacebuilding',
        'urutan' => '14',
        'anakan' => 
        array (
        ),
      ),
    ),
  ),
)




$outputArray = [];

foreach ($listmodulall as $modul) {
  if ($modul->before_modul === 'mastermembercard') {
    $modul->anakan = [];
    foreach ($listmodulall as $childModul) {
      if ($childModul->before_modul === 'mastermembercard.indexidcash' || $childModul->before_modul === 'mastermembercard.indexchecksaldo') {
        $modul->anakan[] = $childModul;
      }
    }
    $outputArray[] = $modul;
  } elseif ($modul





 public function getModulonall(){ 
       $listmodulall = $this->managementMobileService->listmodulall();
       $modulfirst = $this->managementMobileService->modulfirstservice();
       $listlevelmodul = $this->managementMobileService->listlevelall();
        $listleveloffset = $this->managementMobileService->offsetlistlevel();
             $outputArray = [];

foreach ($modulfirst as $modul) {
    foreach ($listmodulall as $modulall) {
        if ($modul->before_modul === $modulall->before_modul) {
            $modul->anakan = [];
        }else{
    foreach ($listleveloffset as $levelan) { 
if ($levelan->id_level == $modulall->urutan) {   
  $aksesmodul = $this->managementMobileService->aksesmodul($levelan->id_level,$modulall->before_modul);
 
} 
}
}
    }
    $outputArray[] = $modul;
}