Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

uzairkhalil's avatar

Update user's different type data in different tables while updating userprofile in jetstream update form

I added two more tables Business and Bank along with User in jetstream registration form. I inserted data successfully in all these three tables at once at registration process. But now I want to put this user data in update form to update. I have no idea where to update data of Business and Bank tables too along with User table. my app/Actions/Fortify/CreatedNewUser.php file is: `<?php

namespace App\Actions\Fortify;

use App\Models\Team; use App\Models\User; use App\Models\Business; use App\Models\Bank; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Laravel\Fortify\Contracts\CreatesNewUsers; use Laravel\Jetstream\Jetstream;

class CreateNewUser implements CreatesNewUsers { use PasswordValidationRules;

/**
 * Create a newly registered user.
 *
 * @param  array  $input
 * @return \App\Models\User
 */
public function create(array $input){

$user = User::create([
 
    'user_id' => $input['user_id'],
    'username' => $input['username'],
    'name' => $input['name'],
    'lname' => $input['lname'],
    'email' => $input['email'],
    'phone' => $input['phone'],
    'cell' => $input['cell'],
    'persnl_add1' => $input['persnl_add1'],
    'persnl_add2' => $input['persnl_add2'],
    'city' => $input['city'],
    'province' => $input['province'],
    'country' => $input['country'],
    'web' => $input['web'],
    'password' => Hash::make($input['password']),
]);

Business::create([
    'user_id' => $input['user_id'],
    'bsns_name' => $input['bsns_name'],
    'bsns_add1' => $input['bsns_add1'],
    'bsns_add2' => $input['bsns_add2'],
    'bsns_city' => $input['bsns_city'],
    'bsns_province' => $input['bsns_province'],
    'bsns_country' => $input['bsns_country'],
    ]);

Bank::create([
    'user_id' => $input['user_id'],
    'branch_code' => $input['branch_code'],
    'bank_name' => $input['bank_name'],
    'acc_no' => $input['acc_no'],
    'acc_title' => $input['acc_title'],
    ]);

    return $user;
}

}`

here is the app/Actions/Fortify/UpdateUserProfileInformation.php: `<?php

namespace App\Actions\Fortify;

use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; use Illuminate\Support\Facades\Hash;

class UpdateUserProfileInformation implements UpdatesUserProfileInformation { /** * Validate and update the given user's profile information. * * @param mixed $user * @param array $input * @return void */ public function update($user, array $input) { Validator::make($input, [ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], 'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'], ])->validateWithBag('updateProfileInformation');

    if (isset($input['photo'])) {
        $user->updateProfilePhoto($input['photo']);
    }

    if ($input['email'] !== $user->email &&
        $user instanceof MustVerifyEmail) {
        $this->updateVerifiedUser($user, $input);
    } else {
        $user->forceFill([
            'username' => $input['username'],
            'name' => $input['name'],
            'lname' => $input['lname'],
            'email' => $input['email'],
            'phone' => $input['phone'],
            'cell' => $input['cell'],
            'persnl_add1' => $input['persnl_add1'],
            'persnl_add2' => $input['persnl_add2'],
            'city' => $input['city'],
            'province' => $input['province'],
            'country' => $input['country'],
            'web' => $input['web'],
        ])->save();
    }
}

/**
 * Update the given verified user's profile information.
 *
 * @param  mixed  $user
 * @param  array  $input
 * @return void
 */
protected function updateVerifiedUser($user, array $input)
{
    $user->forceFill([
        'name' => $input['name'],
        'email' => $input['email'],
        'email_verified_at' => null,
    ])->save();

    $user->sendEmailVerificationNotification();
}

}`

Here I can't see to where update data of those other tables

0 likes
1 reply
Snapey's avatar

Please learn how to format code blocks.

Your problem has nothing to do with fortify or jetstream

Just create a CRUD operation for the user record rather than trying to reuse the registration code.

Please or to participate in this conversation.