Changeset d25ba66 for app/Http/Controllers/Dashboard/UsersController.php
- Timestamp:
- 02/24/21 17:04:35 (4 years ago)
- Branches:
- master
- Children:
- 0c07a90
- Parents:
- 1f059b0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/Dashboard/UsersController.php
r1f059b0 rd25ba66 10 10 use App\Notifications\WelcomeUser; 11 11 use App\Http\Controllers\Controller; 12 use Illuminate\Support\Facades\DB; 12 13 use Illuminate\Support\Facades\Storage; 13 14 use Propaganistas\LaravelPhone\PhoneNumber; … … 32 33 public function store(NewUserRequest $request) 33 34 { 34 $user = new User();35 DB::transaction(function () use ($request) { 35 36 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(); 45 38 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(); 47 48 48 $user->save();49 $user->role_id = $request->userRole; 49 50 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(); 54 52 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 ]); 56 57 57 Alert::flash("New user added successfully"); 58 $user->notify(new WelcomeUser($user)); 59 60 Alert::flash("New user added successfully"); 61 62 }); 58 63 59 64 return redirect()->route("dashboard.users.create");
Note:
See TracChangeset
for help on using the changeset viewer.