santino
1 week ago

create user with profile table

Posted 1 week ago by santino

Hi, I am trying to create a user with a profile table related so far...

      $newUser = User::create([
            'name' => 'daniel',
            'email' => '[email protected]',
            'password' => Hash::make(123),
      ]);

      Profile::create([
            'user_id' => $newUser->id,
            'nombre' => 'Adminer',
            'apellido' => 'Jhonson',
      ]);

this is working but I thing there should be a better way to do it... can some one help me? am using for a role this one

$newUser->role()->attach(1);

I love this way

so I want to make something like this

$newUser->Profile()->attach($newUser->id); // this is my idea to create an attached table to that ID user

thanks in advance for your help

Please sign in or create an account to participate in this conversation.