Hello I am currently trying to extend the user plugin to allow the user to have an address. I have succeeded in doing this when the user has only one address but I want the user to be able to have multiple.
Im having some issues and cant seem to figure this out. Below is my Plugin.php boot function.
public function boot()
{
//Extending User Plugin
UserModel::extend(function($model) {
$model->hasOne['profile'] = ['Bigmotive\Profile\Models\Profile'];
$model->hasMany['addresses'] = ['Bigmotive\Profile\Models\Address'];
});
UsersController::extendFormFields(function($form, $model, $context){
if (!$model instanceof UserModel)
return;
if (!$model->exists)
return;
// Ensures profile model always exists...
ProfileModel::getFromUser($model);
$form->addTabFields([
'profile[phone]' => [
'label' => 'Phone',
'tab' => 'Profile',
],
'addresses' => [
'label' => 'Address 1',
'tab' => 'Address',
'type' => '????',
'path' => '????'
],
]);
});
}
Last updated