From ed46eaa5dd76755983bfa64912e09e511b11ac20 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 1 Jun 2020 19:31:25 +0100 Subject: [PATCH] + Add wallet user --- .env.example | 6 + app/Http/Controllers/CommissionController.php | 46 ++ app/Http/Controllers/WalletController.php | 8 + app/Models/Identification.php | 76 ++++ app/Models/User.php | 82 ++++ app/Models/WalletsUser.php | 48 ++ bootstrap/app.php | 5 + composer.json | 1 + composer.lock | 413 +++++++++++++++++- config/mail.php | 110 +++++ resources/lang/fr/errors.php | 2 +- routes/web.php | 8 + 12 files changed, 801 insertions(+), 4 deletions(-) create mode 100644 app/Models/Identification.php create mode 100755 app/Models/User.php create mode 100644 app/Models/WalletsUser.php create mode 100644 config/mail.php diff --git a/.env.example b/.env.example index d57ad09..b5dbc04 100755 --- a/.env.example +++ b/.env.example @@ -23,3 +23,9 @@ ACCEPTED_KEYS=yhSTSSqIO1uSE1icu09edPOeSFGxIDjo TWILIO_ACCOUNT_SID="ACacdb9c9601741af001ebbc7eca4969cd" TWILIO_AUTH_TOKEN="e0e2f1176c09b3980c9ecf967187191b" TWILIO_SMS_FROM="+447400348273" + +MAIL_HOST=mail.ilink-app.com +MAIL_USERNAME=noreply@ilink-app.com +MAIL_PASSWORD=ilink2017GA +MAIL_FROM_ADDRESS=noreply@ilink-app.com +MAIL_FROM_NAME="iLink World" diff --git a/app/Http/Controllers/CommissionController.php b/app/Http/Controllers/CommissionController.php index 5f784a7..db17049 100755 --- a/app/Http/Controllers/CommissionController.php +++ b/app/Http/Controllers/CommissionController.php @@ -10,6 +10,8 @@ use App\Models\WalletTransaction; use App\Traits\ApiResponser; use Illuminate\Http\Request; use Illuminate\Http\Response; +use Illuminate\Support\Facades\Date; +use Illuminate\Support\Facades\Mail; class CommissionController extends Controller { @@ -38,4 +40,48 @@ class CommissionController extends Controller return $this->successResponse($wallet); } + + public function sendMail(){ + + $recipients = ['dietchidjery@gmail.com']; + Mail::mailer('smtp')->raw('Message test.', function ($message) use ($recipients) { + $message->subject('This is a test to see if emails are working'); + $message->to($recipients); + }); + return $this->successResponse("mail envoye"); + } + + public function fileUpload(Request $request) { + +// if ($request->hasFile('image')) { +// $image = $request->file('image'); +// $name = time().'.'.$image->getClientOriginalExtension(); +// $destinationPath = storage_path('/storage'); +// $image->move($destinationPath, $name); +// +// +// return $this->successResponse("image envoye"); +// } + + $response = null; + $user = (object) ['image' => ""]; + + if ($request->hasFile('image')) { + $original_filename = $request->file('image')->getClientOriginalName(); + $original_filename_arr = explode('.', $original_filename); + $file_ext = end($original_filename_arr); + $destination_path = './upload/user/'; + $image = 'U-' . time() . '.' . $file_ext; + + if ($request->file('image')->move($destination_path, $image)) { + $user->image = '/upload/user/' . $image; + return $this->successResponse($user); + } else { + return $this->errorResponse('Cannot upload file'); + } + } else { + return $this->errorResponse('File not found'); + } + + } } diff --git a/app/Http/Controllers/WalletController.php b/app/Http/Controllers/WalletController.php index 023d2af..b7086bc 100755 --- a/app/Http/Controllers/WalletController.php +++ b/app/Http/Controllers/WalletController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\Wallet; +use App\Models\WalletsUser; use App\Traits\ApiResponser; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -94,4 +95,11 @@ class WalletController extends Controller return $this->successResponse(trans('messages.new_wallet_added')); } + + // Wallets users iLink + public function showWalletUser($id_user){ + $wallet = WalletsUser::where('idUser',$id_user)->firstOrFail(); + return $this->successResponse($wallet); + } + } diff --git a/app/Models/Identification.php b/app/Models/Identification.php new file mode 100644 index 0000000..3eeed44 --- /dev/null +++ b/app/Models/Identification.php @@ -0,0 +1,76 @@ + 'int', + 'idUser' => 'int', + 'status' => 'int' + ]; + + protected $dates = [ + 'birth_date', + 'validity_date_document', + 'createdAt' + ]; + + protected $fillable = [ + 'firstname', + 'lastname', + 'birth_date', + 'town', + 'country', + 'identity_document', + 'id_identity_document', + 'validity_date_document', + 'idUser', + 'status', + 'createdAt', + 'user_image', + 'document_image' + ]; + + public function country() + { + return $this->belongsTo(Country::class, 'country'); + } + + public function user() + { + return $this->belongsTo(User::class, 'idUser'); + } +} diff --git a/app/Models/User.php b/app/Models/User.php new file mode 100755 index 0000000..e2b56fe --- /dev/null +++ b/app/Models/User.php @@ -0,0 +1,82 @@ + 'float', + 'active' => 'int', + 'network_id' => 'int' + ]; + + protected $dates = [ + 'date_modified', + 'date_created' + ]; + + protected $hidden = [ + 'encrypted_password' + ]; + + protected $fillable = [ + 'uid', + 'firstname', + 'lastname', + 'phone', + 'email', + 'adresse', + 'solde', + 'encrypted_password', + 'salt', + 'validation_code', + 'active', + 'date_modified', + 'date_created' + ]; + + public function identifications() + { + return $this->hasMany(Identification::class, 'idUser'); + } + + public function wallets_users() + { + return $this->hasMany(WalletsUser::class, 'idUser'); + } +} diff --git a/app/Models/WalletsUser.php b/app/Models/WalletsUser.php new file mode 100644 index 0000000..24e34f6 --- /dev/null +++ b/app/Models/WalletsUser.php @@ -0,0 +1,48 @@ + 'float', + 'idUser' => 'int' + ]; + + protected $dates = [ + 'createdAt' + ]; + + protected $fillable = [ + 'balance', + 'createdAt', + 'idUser' + ]; + + public function user() + { + return $this->belongsTo(User::class, 'idUser'); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index 0a1b5ee..e27fca4 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -60,6 +60,10 @@ $app->singleton( */ $app->configure('app'); +$app->configure('mail'); +$app->alias('mailer', Illuminate\Mail\Mailer::class); +$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class); +$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class); /* |-------------------------------------------------------------------------- @@ -95,6 +99,7 @@ $app->configure('app'); // $app->register(App\Providers\AppServiceProvider::class); // $app->register(App\Providers\AuthServiceProvider::class); // $app->register(App\Providers\EventServiceProvider::class); + $app->register(Illuminate\Mail\MailServiceProvider::class); /* |-------------------------------------------------------------------------- diff --git a/composer.json b/composer.json index fd7e4d0..b97c875 100755 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "require": { "php": "^7.2.5", "guzzlehttp/guzzle": "^6.5", + "illuminate/mail": "^7.13", "laravel/lumen-framework": "^7.0", "twilio/sdk": "^6.3" }, diff --git a/composer.lock b/composer.lock index 7ab17b0..2a64408 100755 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3e56a6208178c25d0d589884fc9ea980", + "content-hash": "38b17bef54c08bf451d9d7db7a488b12", "packages": [ { "name": "brick/math", @@ -1216,6 +1216,61 @@ "homepage": "https://laravel.com", "time": "2020-03-08T16:13:06+00:00" }, + { + "name": "illuminate/mail", + "version": "v7.13.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/mail.git", + "reference": "b18644e351475342a6675307797d9efa2595ae68" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/mail/zipball/b18644e351475342a6675307797d9efa2595ae68", + "reference": "b18644e351475342a6675307797d9efa2595ae68", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/container": "^7.0", + "illuminate/contracts": "^7.0", + "illuminate/support": "^7.0", + "league/commonmark": "^1.3", + "php": "^7.2.5", + "psr/log": "^1.0", + "swiftmailer/swiftmailer": "^6.0", + "tijsverkoyen/css-to-inline-styles": "^2.2.2" + }, + "suggest": { + "aws/aws-sdk-php": "Required to use the SES mail driver (^3.0).", + "guzzlehttp/guzzle": "Required to use the Mailgun mail driver (^6.3.1|^7.0).", + "wildbit/swiftmailer-postmark": "Required to use Postmark mail driver (^3.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Mail\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Mail package.", + "homepage": "https://laravel.com", + "time": "2020-05-13T14:11:09+00:00" + }, { "name": "illuminate/pagination", "version": "v7.3.0", @@ -1766,6 +1821,106 @@ ], "time": "2020-03-19T16:00:28+00:00" }, + { + "name": "league/commonmark", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/commonmark.git", + "reference": "412639f7cfbc0b31ad2455b2fe965095f66ae505" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/412639f7cfbc0b31ad2455b2fe965095f66ae505", + "reference": "412639f7cfbc0b31ad2455b2fe965095f66ae505", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1" + }, + "conflict": { + "scrutinizer/ocular": "1.7.*" + }, + "require-dev": { + "cebe/markdown": "~1.0", + "commonmark/commonmark.js": "0.29.1", + "erusev/parsedown": "~1.0", + "ext-json": "*", + "github/gfm": "0.29.0", + "michelf/php-markdown": "~1.4", + "mikehaertl/php-shellcommand": "^1.4", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5", + "scrutinizer/ocular": "^1.5", + "symfony/finder": "^4.2" + }, + "bin": [ + "bin/commonmark" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "League\\CommonMark\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Colin O'Dell", + "email": "colinodell@gmail.com", + "homepage": "https://www.colinodell.com", + "role": "Lead Developer" + } + ], + "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM)", + "homepage": "https://commonmark.thephpleague.com", + "keywords": [ + "commonmark", + "flavored", + "gfm", + "github", + "github-flavored", + "markdown", + "md", + "parser" + ], + "funding": [ + { + "url": "https://enjoy.gitstore.app/repositories/thephpleague/commonmark", + "type": "custom" + }, + { + "url": "https://www.colinodell.com/sponsor", + "type": "custom" + }, + { + "url": "https://www.paypal.me/colinpodell/10.00", + "type": "custom" + }, + { + "url": "https://github.com/colinodell", + "type": "github" + }, + { + "url": "https://www.patreon.com/colinodell", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/league/commonmark", + "type": "tidelift" + } + ], + "time": "2020-05-04T22:15:21+00:00" + }, { "name": "monolog/monolog", "version": "2.0.2", @@ -2502,6 +2657,68 @@ ], "time": "2020-03-29T20:13:32+00:00" }, + { + "name": "swiftmailer/swiftmailer", + "version": "v6.2.3", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "149cfdf118b169f7840bbe3ef0d4bc795d1780c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/149cfdf118b169f7840bbe3ef0d4bc795d1780c9", + "reference": "149cfdf118b169f7840bbe3ef0d4bc795d1780c9", + "shasum": "" + }, + "require": { + "egulias/email-validator": "~2.0", + "php": ">=7.0.0", + "symfony/polyfill-iconv": "^1.0", + "symfony/polyfill-intl-idn": "^1.10", + "symfony/polyfill-mbstring": "^1.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.1", + "symfony/phpunit-bridge": "^3.4.19|^4.1.8" + }, + "suggest": { + "ext-intl": "Needed to support internationalized email addresses", + "true/punycode": "Needed to support internationalized email addresses, if ext-intl is not installed" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.2-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "https://swiftmailer.symfony.com", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2019-11-12T09:31:26+00:00" + }, { "name": "symfony/console", "version": "v5.0.7", @@ -2578,6 +2795,73 @@ "homepage": "https://symfony.com", "time": "2020-03-30T11:42:42+00:00" }, + { + "name": "symfony/css-selector", + "version": "v5.0.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/css-selector.git", + "reference": "5f8d5271303dad260692ba73dfa21777d38e124e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/5f8d5271303dad260692ba73dfa21777d38e124e", + "reference": "5f8d5271303dad260692ba73dfa21777d38e124e", + "shasum": "" + }, + "require": { + "php": "^7.2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\CssSelector\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony CssSelector Component", + "homepage": "https://symfony.com", + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-27T16:56:45+00:00" + }, { "name": "symfony/error-handler", "version": "v5.0.7", @@ -3081,6 +3365,79 @@ ], "time": "2020-02-27T09:26:54+00:00" }, + { + "name": "symfony/polyfill-iconv", + "version": "v1.17.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-iconv.git", + "reference": "c4de7601eefbf25f9d47190abe07f79fe0a27424" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/c4de7601eefbf25f9d47190abe07f79fe0a27424", + "reference": "c4de7601eefbf25f9d47190abe07f79fe0a27424", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-iconv": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Iconv\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Iconv extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "iconv", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-12T16:47:27+00:00" + }, { "name": "symfony/polyfill-intl-idn", "version": "v1.15.0", @@ -3631,6 +3988,55 @@ ], "time": "2020-03-27T16:56:45+00:00" }, + { + "name": "tijsverkoyen/css-to-inline-styles", + "version": "2.2.2", + "source": { + "type": "git", + "url": "https://github.com/tijsverkoyen/CssToInlineStyles.git", + "reference": "dda2ee426acd6d801d5b7fd1001cde9b5f790e15" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/dda2ee426acd6d801d5b7fd1001cde9b5f790e15", + "reference": "dda2ee426acd6d801d5b7fd1001cde9b5f790e15", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "php": "^5.5 || ^7.0", + "symfony/css-selector": "^2.7 || ^3.0 || ^4.0 || ^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "TijsVerkoyen\\CssToInlineStyles\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Tijs Verkoyen", + "email": "css_to_inline_styles@verkoyen.eu", + "role": "Developer" + } + ], + "description": "CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.", + "homepage": "https://github.com/tijsverkoyen/CssToInlineStyles", + "time": "2019-10-24T08:53:34+00:00" + }, { "name": "twilio/sdk", "version": "6.3.0", @@ -5426,5 +5832,6 @@ "platform": { "php": "^7.2.5" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/config/mail.php b/config/mail.php new file mode 100644 index 0000000..54299aa --- /dev/null +++ b/config/mail.php @@ -0,0 +1,110 @@ + env('MAIL_MAILER', 'smtp'), + + /* + |-------------------------------------------------------------------------- + | Mailer Configurations + |-------------------------------------------------------------------------- + | + | Here you may configure all of the mailers used by your application plus + | their respective settings. Several examples have been configured for + | you and you are free to add your own as your application requires. + | + | Laravel supports a variety of mail "transport" drivers to be used while + | sending an e-mail. You will specify which one you are using for your + | mailers below. You are free to add additional mailers as required. + | + | Supported: "smtp", "sendmail", "mailgun", "ses", + | "postmark", "log", "array" + | + */ + + 'mailers' => [ + 'smtp' => [ + 'transport' => 'smtp', + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'port' => env('MAIL_PORT', 587), + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), + 'username' => env('MAIL_USERNAME'), + 'password' => env('MAIL_PASSWORD'), + 'timeout' => null, + 'auth_mode' => null, + ], + + 'ses' => [ + 'transport' => 'ses', + ], + + 'mailgun' => [ + 'transport' => 'mailgun', + ], + + 'postmark' => [ + 'transport' => 'postmark', + ], + + 'sendmail' => [ + 'transport' => 'sendmail', + 'path' => '/usr/sbin/sendmail -bs', + ], + + 'log' => [ + 'transport' => 'log', + 'channel' => env('MAIL_LOG_CHANNEL'), + ], + + 'array' => [ + 'transport' => 'array', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), + ], + + /* + |-------------------------------------------------------------------------- + | Markdown Mail Settings + |-------------------------------------------------------------------------- + | + | If you are using Markdown based email rendering, you may configure your + | theme and component paths here, allowing you to customize the design + | of the emails. Or, you may simply stick with the Laravel defaults! + | + */ + + 'markdown' => [ + 'theme' => 'default', + + 'paths' => [ + resource_path('views/vendor/mail'), + ], + ], + +]; diff --git a/resources/lang/fr/errors.php b/resources/lang/fr/errors.php index 1928462..dd1d875 100755 --- a/resources/lang/fr/errors.php +++ b/resources/lang/fr/errors.php @@ -2,5 +2,5 @@ return [ 'model_not_found' => 'Il n\'existe aucune instance de :model avec l\'id donné', 'unexpected_error'=> 'Erreur inattendue. Essayer plus tard', - 'service_unavailable' => 'Service not disponible' + 'service_unavailable' => 'Service non disponible' ]; diff --git a/routes/web.php b/routes/web.php index d703050..fd80690 100755 --- a/routes/web.php +++ b/routes/web.php @@ -35,4 +35,12 @@ $router->group(['prefix' => '/wallets'] , function () use ($router){ $router->get('{id_agent}/activated', 'WalletController@activated'); $router->get('{id_wallet}', 'WalletController@show'); $router->post('', 'WalletController@create'); + + // Wallets users iLink + $router->group(['prefix' => '/users'] , function () use ($router){ + $router->get('{id_user}', 'WalletController@showWalletUser'); + }); }); + +$router->get('mail','CommissionController@sendMail'); +$router->post('file','CommissionController@fileUpload');