+ Verify users identification
This commit is contained in:
		
							parent
							
								
									da240a732b
								
							
						
					
					
						commit
						a0e27c10ba
					
				|  | @ -42,12 +42,11 @@ class UserController extends Controller | ||||||
| 
 | 
 | ||||||
|         $identification->fill($request->all()); |         $identification->fill($request->all()); | ||||||
|         $identification->id_user = $user->id; |         $identification->id_user = $user->id; | ||||||
|         $identification->user_code = $this->generateRandomString(); |  | ||||||
|         $identification->status = 0; |         $identification->status = 0; | ||||||
| 
 | 
 | ||||||
|         $identification->save(); |         $identification->save(); | ||||||
|         $this->sendMail($user->email,trans('messages.successful_identification'), |         $this->sendMail($user->email,trans('messages.successful_identification'), | ||||||
|             trans('messages.successful_identification_message',['name'=>$identification->lastname.' '.$identification->firstname,'user_code'=>$identification->user_code])); |             trans('messages.successful_identification_message',['name'=>$identification->lastname.' '.$identification->firstname])); | ||||||
|         return $this->successResponse(trans('messages.successful_identification')); |         return $this->successResponse(trans('messages.successful_identification')); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -71,25 +70,28 @@ class UserController extends Controller | ||||||
|         $identification->document_image_front = $this->uploadImage($request,'document_image_front','D-F',"documents"); |         $identification->document_image_front = $this->uploadImage($request,'document_image_front','D-F',"documents"); | ||||||
|         $identification->document_image_back = $this->uploadImage($request,'document_image_back','D-B',"documents"); |         $identification->document_image_back = $this->uploadImage($request,'document_image_back','D-B',"documents"); | ||||||
|         $identification->user_image = $this->uploadImage($request,'user_image','U',"photos"); |         $identification->user_image = $this->uploadImage($request,'user_image','U',"photos"); | ||||||
|  |         $identification->user_code = $this->generateRandomString(); | ||||||
|         $identification->status = 1; |         $identification->status = 1; | ||||||
| 
 | 
 | ||||||
|         $identification->save(); |         $identification->save(); | ||||||
|         $this->sendMail($identification->user->email,trans('messages.validated_identification'),trans('messages.validated_identification_message')); |         $this->sendMail($identification->user->email,trans('messages.validated_identification'),trans('messages.validated_identification_message',['user_code'=>$identification->user_code])); | ||||||
|         return $this->successResponse(trans('messages.validated_identification')); |         return $this->successResponse(trans('messages.validated_identification')); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function fetchIdentification($user_code) |     public function fetchIdentification($user_phone) | ||||||
|     { |     { | ||||||
|         return Identification::where('user_code', $user_code)->firstOrFail(); |         $user = User::where('phone', $user_phone)->firstOrFail(); | ||||||
|  |         return Identification::where('id_user', $user->id)->firstOrFail(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public function verifyIdentification($id_user) |     public function verifyIdentification($user_phone) | ||||||
|     { |     { | ||||||
|         $identification = Identification::where('id_user', $id_user)->firstOrFail(); |         $user = User::where('phone', $user_phone)->firstOrFail(); | ||||||
|         if($identification->status == 1) |         $identification = Identification::where('id_user', $user->id)->first(); | ||||||
|             return $this->successResponse(trans('messages.user_identificated'),Response::HTTP_NO_CONTENT); |         if($identification){ | ||||||
|         else |             return $this->errorResponse(trans('messages.user_identificated')); | ||||||
|             return $this->successResponse($identification); |         }else | ||||||
|  |             return $this->successResponse($user); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private function generateRandomString($length = 10) |     private function generateRandomString($length = 10) | ||||||
|  |  | ||||||
|  | @ -15,12 +15,12 @@ return [ | ||||||
|     'successful_identification_message' => 'Hi :name, |     'successful_identification_message' => 'Hi :name, | ||||||
| 
 | 
 | ||||||
| Your identification has been taken into account. Contact an iLink World agent with your ID to validate your identity. | Your identification has been taken into account. Contact an iLink World agent with your ID to validate your identity. | ||||||
| Your username: :user_code |  | ||||||
| 
 | 
 | ||||||
| Regards, | Regards, | ||||||
| iLinkWorld team.', | iLinkWorld team.', | ||||||
|     'validated_identification_message' => 'Your identification is confirmed! |     'validated_identification_message' => 'Your identification is confirmed! | ||||||
| 
 | 
 | ||||||
|  | Your username: :user_code | ||||||
| You can now use the services of iLink World. | You can now use the services of iLink World. | ||||||
| Welcome to the iLink World family !!! | Welcome to the iLink World family !!! | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -15,12 +15,12 @@ return [ | ||||||
|     'successful_identification_message' => 'Salut :name, |     'successful_identification_message' => 'Salut :name, | ||||||
| 
 | 
 | ||||||
| Votre identification a été prise en compte . Rapprochez vous auprès d\'un agent iLink World muni de votre pièce d\'identité pour faire valider de votre identité. | Votre identification a été prise en compte . Rapprochez vous auprès d\'un agent iLink World muni de votre pièce d\'identité pour faire valider de votre identité. | ||||||
| Votre identifiant : :user_code |  | ||||||
| 
 | 
 | ||||||
| Cordialement, | Cordialement, | ||||||
| Equipe iLinkWorld.', | Equipe iLinkWorld.', | ||||||
|     'validated_identification_message' => 'Votre identification est confirmée ! |     'validated_identification_message' => 'Votre identification est confirmée ! | ||||||
| 
 | 
 | ||||||
|  | Votre identifiant : :user_code | ||||||
| Vous pouvez desormais utiliser les services de iLink World. | Vous pouvez desormais utiliser les services de iLink World. | ||||||
| Bienvenue dans la famille iLink World !!! | Bienvenue dans la famille iLink World !!! | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -47,7 +47,7 @@ $router->group(['prefix' => '/wallets'] , function () use ($router){ | ||||||
| $router->group(['prefix' => '/identifications'] , function () use ($router){ | $router->group(['prefix' => '/identifications'] , function () use ($router){ | ||||||
|     $router->post('','UserController@identification'); |     $router->post('','UserController@identification'); | ||||||
|     $router->post('{id_identification}','UserController@validateIdentification'); |     $router->post('{id_identification}','UserController@validateIdentification'); | ||||||
|     $router->get('{user_code}','UserController@fetchIdentification'); |     $router->get('{user_phone}','UserController@fetchIdentification'); | ||||||
|     $router->get('verify/{id_user}','UserController@verifyIdentification'); |     $router->get('verify/{user_phone}','UserController@verifyIdentification'); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue