$section_data = SectionModel::select('section_name')->where('section_code',$fil_det->section_code )->first() ; if($fil_det->section_code == $fil_det->folder_id ){ $action_msg .= 'root (folder) of '.$section_data->section_name. ' (section)' ; }else{ $folder_data = FolderDirectoryModel::select('folder_name')->where('id', $fil_det->folder_id )->first() ; $action_msg .= $folder_data->folder_name .' (folder) of '.$section_data->section_name. ' (section)' ; }