public function lastId($p1 = null, $p2 = null) { if (!$p1) { return ee(2, 'ins_not_exists'); } if (class_exists(MName($p1, 'i'))) { $ins = M($p1, 'i'); } return $ins->lastId($p2); }
/** * 请求 * @param [type] $ctrl [description] * @param [type] $action [description] * @param string $params [description] * @return [type] [description] */ public function cook($ctrl, $action, $params = '') { // If exists model in univ, use it. if (class_exists(MName($ctrl, 'v')) && !rq('write_data')) { $ins = new M($ctrl, 'v'); } else { if (class_exists(MName($ctrl, 'i'))) { $ins = M($ctrl, 'i'); } else { return ee(2); } } // 权限检查 // 方法调用 是否存在 check guard return call_user_func_array([$ins, $action], explode('/', $params)); }
/** * 主方法 * @param [type] $p1 用户类型 * @param [type] $p2 model名 * @return [type] [description] */ public function leader($p1 = null, $p2 = null) { if (empty($p1)) { return ee(2); } $ins_name = $p1; $action_name = $p2; if (!$this->has_permission($ins_name, $action_name)) { abort(403, d(403)); } // If exists model in univ, use it. if (class_exists(MName($ins_name, 'v')) && !rq('write_data')) { $ins = M($ins_name, 'v'); } else { if (class_exists(MName($ins_name, 'i'))) { $ins = M($ins_name, 'i'); } else { return ee(2, 'ins_not_exists'); } } return $ins->{$action_name}(); }
/** * Model Meta Data * Get data form t_* tables; * * @param $modelNameSingular * @param $without * @return array */ function mmData($modelNameSingular, $without = []) { foreach (wolf('model_types') as $t) { $modelName = MName($modelNameSingular, $t); if (!class_exists($modelName) || in_array($t, $without) || !starts_with($t, wolf('m_t'))) { continue; } $frontModelName = camel_case(class_basename($modelName)); $data[$frontModelName] = $modelName::all()->toArray(); } if ($data) { return ss($data); } return ee('invalid_argument', func_get_args()); }