Ignore:
Timestamp:
02/24/21 17:04:35 (4 years ago)
Author:
Özkan İliyaz <iliyaz_96@…>
Branches:
master
Children:
0c07a90
Parents:
1f059b0
Message:

ADD post confirmation with multiple phases, notification after succesfully password creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Dashboard/UsersController.php

    r1f059b0 rd25ba66  
    1010use App\Notifications\WelcomeUser;
    1111use App\Http\Controllers\Controller;
     12use Illuminate\Support\Facades\DB;
    1213use Illuminate\Support\Facades\Storage;
    1314use Propaganistas\LaravelPhone\PhoneNumber;
     
    3233    public function store(NewUserRequest $request)
    3334    {
    34         $user = new User();
     35        DB::transaction(function () use ($request) {
    3536
    36         $user->name = $request->name;
    37         $user->surname = $request->surname;
    38         $user->email = $request->email;
    39         $user->country_code = $request->mobile_number_country;
    40         $user->mobile_number = PhoneNumber::make($request->mobile_number, $request->mobile_number_country)->formatInternational();
    41         $user->username = $request->username;
    42         $user->password = $user->generateTemporaryPassword();
    43         $user->security_code = $user->generateSecurityCode();
    44         $user->verify_token = $user->generateVerifyToken();
     37            $user = new User();
    4538
    46         $user->role_id = $request->userRole;
     39            $user->name = $request->name;
     40            $user->surname = $request->surname;
     41            $user->email = $request->email;
     42            $user->country_code = $request->mobile_number_country;
     43            $user->mobile_number = PhoneNumber::make($request->mobile_number, $request->mobile_number_country)->formatInternational();
     44            $user->username = $request->username;
     45            $user->password = $user->generateTemporaryPassword();
     46            $user->security_code = $user->generateSecurityCode();
     47            $user->verify_token = $user->generateVerifyToken();
    4748
    48         $user->save();
     49            $user->role_id = $request->userRole;
    4950
    50         $user->userProfile()->create([
    51             "profile_link" => $user->generateProfileLink($request->name, $request->surname),
    52             "technoblog_email" => $user->generateTechnoblogEmail($request->name, $request->surname)
    53         ]);
     51            $user->save();
    5452
    55         $user->notify(new WelcomeUser($user));
     53            $user->userProfile()->create([
     54                "profile_link" => $user->generateProfileLink($request->name, $request->surname),
     55                "technoblog_email" => $user->generateTechnoblogEmail($request->name, $request->surname)
     56            ]);
    5657
    57         Alert::flash("New user added successfully");
     58            $user->notify(new WelcomeUser($user));
     59
     60            Alert::flash("New user added successfully");
     61
     62        });
    5863
    5964        return redirect()->route("dashboard.users.create");
Note: See TracChangeset for help on using the changeset viewer.