diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index b9677cf..7e343c4 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -55,12 +55,16 @@ class UserController extends Controller // dd($request->allFiles()); $this->validate($request, [ 'id_network' => 'required|integer|min:0|not_in:0', - 'document_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:6048', + 'id_country' => 'required|integer|min:0|not_in:0', + 'document_image_front' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:6048', + 'document_image_back' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:6048', 'user_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:6048', ]); $identification->idNetwork = $request->id_network; - $identification->document_image = $this->uploadImage($request,'document_image','D',"documents"); + $identification->id_country = $request->id_country; + $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->user_image = $this->uploadImage($request,'user_image','U',"photos"); $identification->status = 1; @@ -69,6 +73,20 @@ class UserController extends Controller return $this->successResponse(trans('messages.validated_identification')); } + public function fetchIdentification($user_code) + { + return Identification::where('user_code', $user_code)->firstOrFail(); + } + + public function verifyIdentification($id_user) + { + $identification = Identification::where('id_user', $id_user)->firstOrFail(); + if($identification->status == 1) + return $this->successResponse(trans('messages.user_identificated'),Response::HTTP_NO_CONTENT); + else + return $this->successResponse($identification); + } + private function generateRandomString($length = 10) { $characters = '23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ'; diff --git a/app/Models/Identification.php b/app/Models/Identification.php index bc7edd8..5aec4dc 100644 --- a/app/Models/Identification.php +++ b/app/Models/Identification.php @@ -25,9 +25,11 @@ use Illuminate\Database\Eloquent\Model; * @property int $status * @property Carbon $createdAt * @property string $user_image - * @property string $document_image + * @property string $document_image_front + * @property string $document_image_back * @property string $user_code * @property int $idNetwork + * @property int $country_id * * @property User $user * @property Network $network @@ -42,7 +44,8 @@ class Identification extends Model protected $casts = [ 'id_user' => 'int', 'status' => 'int', - 'idNetwork' => 'int' + 'idNetwork' => 'int', + 'country_id' => 'int' ]; protected $dates = [ @@ -56,7 +59,7 @@ class Identification extends Model 'lastname', 'birth_date', 'town', - 'country', + 'country', 'identity_document', 'id_identity_document', 'expiry_date_document', @@ -64,15 +67,21 @@ class Identification extends Model 'status', 'createdAt', 'user_image', - 'document_image', + 'document_image_front', + 'document_image_back', 'user_code', - 'idNetwork' + 'idNetwork', + 'country_id' ]; + public function country() + { + return $this->belongsTo(Country::class); + } public function user() { - return $this->belongsTo(User::class, 'idUser'); + return $this->belongsTo(User::class, 'id_user'); } public function network() diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index e66aa45..de6f4fc 100755 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -9,6 +9,7 @@ return [ 'canceled_credit_request' => 'Canceled credit request', 'canceled_transaction' => 'Canceled transaction', 'successful_identification'=>'Successful identification', + 'user_identificated' => 'User already identificated', 'validated_identification'=>'Validated identification', 'identification_already_validated'=>'Identification already validated', 'successful_identification_message' => 'Hi :name, diff --git a/resources/lang/fr/messages.php b/resources/lang/fr/messages.php index 9d503ec..bff0a8d 100755 --- a/resources/lang/fr/messages.php +++ b/resources/lang/fr/messages.php @@ -10,6 +10,7 @@ return [ 'canceled_transaction' => 'Transaction annulée', 'successful_identification' => 'Identification réussie', 'validated_identification' => 'Identification validée', + 'user_identificated' => 'Utilisateur déjà identifié', 'identification_already_validated' => 'Identification deja validée', 'successful_identification_message' => 'Salut :name, diff --git a/routes/web.php b/routes/web.php index 4b161ed..321e3d0 100755 --- a/routes/web.php +++ b/routes/web.php @@ -47,5 +47,7 @@ $router->group(['prefix' => '/wallets'] , function () use ($router){ $router->group(['prefix' => '/identifications'] , function () use ($router){ $router->post('','UserController@identification'); $router->post('{id_identification}','UserController@validateIdentification'); + $router->get('{user_code}','UserController@fetchIdentification'); + $router->get('verify/{id_user}','UserController@verifyIdentification'); });