我正在尝试在十月份的cms中扩展用户插件。当我向Profile插件添加一些代码时,User插件中Profile的标签消失了。 这是我的代码
//Profile Model
public static function getFromUser($user)
{
if ($user->profile) {
return $user->profile;
}
$profile = new static;
$profile->user = $user;
$profile->save();
$user->profile = $profile;
return $profile;
}
//Plugin.php
public function boot()
{
UserModel::extend(function ($model) {
$model->hasOne['profile'] = ['Sepehr\Profile\Models\Profile'];
});
UserController::extendFormFields(function ($form, $model, $context) {
//when i add these code my Profile's tab is gone
if (!$model instanceof UserModel) {
return;
}
if (!$model->exists) {
return;
}
ProfileModel::getFromUser($model);
//when i add these code my Profile's tab is gone
$form->addTabFields([
'profile[bio]' => [
'label' => 'bio',
'tab' => 'Profile',
],
'profile[facebook]' => [
'label' => 'facebook',
'tab' => 'Profile',
'type' => 'textarea'
],
]);
});
}
没有这些行的选项卡又回来了,但是当我单击“保存”并关闭时,发生此错误:“配置文件”尝试将其添加到$ jsonable