fix registration

This commit is contained in:
Andras Bacsai 2023-04-13 17:17:30 +02:00
parent 408236b6b1
commit 1905ed0dc6
2 changed files with 7 additions and 3 deletions

View File

@ -36,18 +36,21 @@ public function create(array $input): User
$team = Team::create([
'name' => explode(' ', $input['name'], 2)[0] . "'s Team",
'personal_team' => true,
'is_root_user' => User::count() == 0 ? true : false,
]);
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
'is_root_user' => User::count() == 0 ? true : false,
]);
DB::table('team_user')->insert([
'team_id' => $user->id,
'user_id' => $team->id,
'user_id' => $user->id,
'team_id' => $team->id,
'role' => 'admin',
]);
session(['currentTeam' => $user->currentTeam = $team]);
return $user;
}
}

View File

@ -9,6 +9,7 @@ class Team extends BaseModel
];
protected $fillable = [
'name',
'personal_team'
];
public function projects() {
return $this->hasMany(Project::class);