本文整理汇总了PHP中AdminHelper::modelConfigs方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminHelper::modelConfigs方法的具体用法?PHP AdminHelper::modelConfigs怎么用?PHP AdminHelper::modelConfigs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminHelper
的用法示例。
在下文中一共展示了AdminHelper::modelConfigs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getModelParents
public function getModelParents()
{
if (!is_null($this->gtcmsModelParents)) {
return $this->gtcmsModelParents;
}
$parents = array();
foreach (\AdminHelper::modelConfigs() as $modelConfig) {
if ($modelConfig->name != $this->name && $modelConfig->relatedModels) {
foreach ($modelConfig->relatedModels as $relatedModel) {
if ($relatedModel->name == $this->name) {
$parents[] = $modelConfig->id;
}
}
}
}
$this->gtcmsModelParents = $parents;
return $parents;
}
示例2: input
public static function input($modelConfig)
{
$input = \Request::all();
if (is_array($input) && !empty($input)) {
$formFields = array();
foreach ($modelConfig->formFields as $field) {
$formFields[$field->property] = $field;
}
$userRole = \Auth::user()->role;
foreach ($input as $property => &$value) {
//set parent IDs to NULL if no value was selected from dropdown
foreach (AdminHelper::modelConfigs() as $currentModelConfig) {
if (!is_array($property) && $property == $currentModelConfig->id && !$value) {
$value = NULL;
}
}
if ($modelConfig) {
if (isset($formFields[$property])) {
$field = $formFields[$property];
//unset property if user isn't allowed to edit it
if ($field->restrictedAccess && !$field->restrictedAccess->{$userRole}) {
unset($input[$property]);
} else {
//format DateTime / Date
if (in_array($field->type, array('date', 'dateTime'))) {
if (Tools::validateDate($value)) {
if ($field->type == "date") {
$value = date("Y-m-d", strtotime($value));
} else {
if ($field->type == "dateTime") {
$value = date("Y-m-d H:i:s", strtotime($value));
} else {
$value = "";
}
}
} else {
$value = "";
}
}
//set null when empty
if ($field->setNullWhenEmpty && !$value && $value !== 0 && $value !== "0") {
$value = null;
}
}
}
}
}
}
if ($modelConfig->name == "User" && isset($input['is_superadmin']) && !\Auth::user()->is_superadmin) {
$input['is_superadmin'] = 0;
}
return $input;
}