Call to a member function toArray() on null 📋

Error
Toggle Vendor Stack Frames
            );
       }
       else{
            $this->loadTable('Staffs');
            $detailAr $this->Staffs->findById($id)->first()->toArray();
            $department = ((int)$detailAr['department_id']>0) ? $this->getField('Departments''name_'.$lang, ['id' => $detailAr['department_id']]) : '';
            $profession = ((int)$detailAr['profession_id']>0) ? $this->getField('Professions''name_'.$lang, ['id' => $detailAr['profession_id']]) : '';
            
            $replaceAr = array(
Error in: ROOT/src/Controller/PagesController.php, line 204

If you want to customize this error message, create templates/Error/error500.php