Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Create User After they complete the first part of the form.
- *
- */
- public function createUserFromOrder(Request $request)
- {
- $validation = $this->validate($request, [
- 'first_name' => 'required',
- 'last_name' => 'required',
- 'email' => 'required|confirm|unique:users,email',
- 'email_confirmation' => 'required'
- ]);
- if ($validation->fails()) {
- return 'testing';
- $errors = $validation->errors();
- $errors = json_decode($errors);
- return response()->json([
- 'success' => false,
- 'message' => $errors
- ], 422);
- }
- $randomPassword = str_random(7);
- $createdSuccessfully = "<div class='alert alert-success' role='alert'><span class='status-available'> User Profile Created.</span></div>";
- $userData = [
- 'email' => $request->email,
- 'password' => $randomPassword,
- 'first_name' => $request->first_name,
- 'last_name' => $request->last_name,
- ];
- $user = Sentinel::registerAndActivate($userData);
- $role = Sentinel::findRoleByName('patient');
- $role->users()->attach($user);
- Sentinel::login($user, true);
- $order = Order::create([
- 'program_id' => $request->program_id,
- 'program_type_id' => $request->program_type_id,
- 'amount' => 433,
- 'order_type' => 0,
- 'paid' => 0,
- 'status' => 0
- ]);
- $user->complete($order);
- $order->addAddon($request->input('addons'));
- return $createdSuccessfully;
- }
- $.ajax({
- type: "POST",
- url: '{{action('OrderProcessController@createUserFromOrder') }}',
- data:
- {
- email: email,
- first_name: first_name,
- last_name: last_name,
- program_id: program_id,
- program_type_id: program_type_id,
- amount: amount,
- addons: addons
- },
- success:function(data){
- $("#user-created-confirmation").html(data);
- },
- error:function (){}
- }, function(){
- setTimeout(function() {
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement