Init commit
This commit is contained in:
commit
3267ce5a0d
|
@ -0,0 +1,15 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
|
@ -0,0 +1,43 @@
|
||||||
|
APP_NAME=WalletServiceExterne
|
||||||
|
APP_ENV=production
|
||||||
|
APP_KEY=NhSitM0Iv4HmNTRVJRiQPm0x20tgz7zE
|
||||||
|
APP_DEBUG=false
|
||||||
|
APP_URL=https://test.ilink-app.com
|
||||||
|
APP_TIMEZONE=UTC
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_SLACK_WEBHOOK_URL=
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=iLink_preprod
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=vps@2017GA
|
||||||
|
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
|
||||||
|
ACCEPTED_KEYS=sPBPta0hpUKPqHLiZQpOa0jHGhhDkbY8,JeJMx6KNW1qo2h01rCVOLfX3f1nmcF2I
|
||||||
|
|
||||||
|
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"
|
||||||
|
MAIL_ENCRYPTION=tls
|
||||||
|
|
||||||
|
VISA_API_URL=localhost:8082
|
||||||
|
VISA_API_USERNAME=admin
|
||||||
|
VISA_API_PASSWORD=PasswordHere!
|
||||||
|
|
||||||
|
NOTIFICATION_SERVICE_URL=localhost:8083
|
||||||
|
NOTIFICATION_SERVICE_KEY=RfXvPQzQRgwpzQYPnLfWpZzgx4QseHlg
|
||||||
|
|
||||||
|
SWAGGER_GENERATE_ALWAYS=true
|
||||||
|
SWAGGER_DOCS_TOKEN=IzkXJp4R4KuF8phBSIRNWH2xY2amnuVi
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
/vendor
|
||||||
|
/.idea
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
.env
|
||||||
|
.phpunit.result.cache
|
||||||
|
/resources/views/vendor
|
||||||
|
/storage/api-docs
|
||||||
|
/public/swagger-ui-assets
|
|
@ -0,0 +1,6 @@
|
||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
disabled:
|
||||||
|
- unused_use
|
||||||
|
js: true
|
||||||
|
css: true
|
|
@ -0,0 +1,24 @@
|
||||||
|
# Lumen PHP Framework
|
||||||
|
|
||||||
|
[](https://travis-ci.org/laravel/lumen-framework)
|
||||||
|
[](https://packagist.org/packages/laravel/lumen-framework)
|
||||||
|
[](https://packagist.org/packages/laravel/lumen-framework)
|
||||||
|
[](https://packagist.org/packages/laravel/lumen-framework)
|
||||||
|
|
||||||
|
Laravel Lumen is a stunningly fast PHP micro-framework for building web applications with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Lumen attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as routing, database abstraction, queueing, and caching.
|
||||||
|
|
||||||
|
## Official Documentation
|
||||||
|
|
||||||
|
Documentation for the framework can be found on the [Lumen website](https://lumen.laravel.com/docs).
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to Lumen! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
|
## Security Vulnerabilities
|
||||||
|
|
||||||
|
If you discover a security vulnerability within Lumen, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Lumen framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Laravel\Lumen\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Artisan commands provided by your application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $commands = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
abstract class Event
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
class ExampleEvent extends Event
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use App\Traits\ApiResponser;
|
||||||
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
use GuzzleHttp\Exception\ServerException;
|
||||||
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Auth\AuthenticationException;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
use ApiResponser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the exception types that should not be reported.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
AuthorizationException::class,
|
||||||
|
HttpException::class,
|
||||||
|
ModelNotFoundException::class,
|
||||||
|
ValidationException::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report or log an exception.
|
||||||
|
*
|
||||||
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||||
|
*
|
||||||
|
* @param \Throwable $exception
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function report(Throwable $exception)
|
||||||
|
{
|
||||||
|
parent::report($exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render an exception into an HTTP response.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Throwable $exception
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
|
||||||
|
*
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function render($request, Throwable $exception)
|
||||||
|
{
|
||||||
|
// return parent::render($request, $exception);
|
||||||
|
if ($exception instanceof HttpException)
|
||||||
|
{
|
||||||
|
$code = $exception->getStatusCode();
|
||||||
|
$message = Response::$statusTexts[$code];
|
||||||
|
|
||||||
|
return $this->errorResponse($message,$code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($exception instanceof ModelNotFoundException)
|
||||||
|
{
|
||||||
|
$model = strtolower(class_basename($exception->getModel()));
|
||||||
|
|
||||||
|
return $this->errorResponse(trans('errors.model_not_found',['model'=>$model]),
|
||||||
|
Response::HTTP_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($exception instanceof AuthorizationException)
|
||||||
|
{
|
||||||
|
return $this->errorResponse($exception->getMessage(),Response::HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($exception instanceof ValidationException)
|
||||||
|
{
|
||||||
|
$errors = $exception->validator->errors()->getMessages();
|
||||||
|
$message = '';
|
||||||
|
foreach ($errors as $key => $val) {
|
||||||
|
foreach ($val as $validation) {
|
||||||
|
$message .= trans('errors.validation_error', ['field' => $key, 'validation' => $validation]);
|
||||||
|
}
|
||||||
|
$message .= "\n";
|
||||||
|
}
|
||||||
|
return $this->errorResponse($message, Response::HTTP_UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($exception instanceof AuthenticationException)
|
||||||
|
{
|
||||||
|
return $this->errorResponse($exception->getMessage(),Response::HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($exception instanceof QueryException)
|
||||||
|
{
|
||||||
|
return $this->errorResponse($exception->getMessage(),Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($exception instanceof ServerException)
|
||||||
|
{
|
||||||
|
return $this->errorResponse($exception->getMessage(),Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($exception instanceof \ErrorException)
|
||||||
|
{
|
||||||
|
return $this->errorResponse($exception->getMessage(),Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $exception instanceof ClientException)
|
||||||
|
{
|
||||||
|
$message = $exception->getResponse()->getBody()->getContents();
|
||||||
|
$error =json_decode($message);
|
||||||
|
$code = $exception->getCode();
|
||||||
|
|
||||||
|
if($error){
|
||||||
|
if (isset($error->message)) {
|
||||||
|
$message = json_decode($error->message);
|
||||||
|
if (isset($message->errorMessage))
|
||||||
|
return $this->errorResponse($message->errorMessage, $code);
|
||||||
|
return $this->errorResponse($error->message, $code);
|
||||||
|
}
|
||||||
|
if (isset($error->error)) {
|
||||||
|
$message = json_decode($error->error);
|
||||||
|
if (isset($message->message))
|
||||||
|
return $this->errorResponse($message->message, $code);
|
||||||
|
return $this->errorResponse($error->error, $code);
|
||||||
|
}
|
||||||
|
return $this->errorResponse($error, $code);
|
||||||
|
} else
|
||||||
|
return $this->errorResponse($message,$code);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( env('APP_DEBUG', false))
|
||||||
|
{
|
||||||
|
return parent::render($request,$exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->errorResponse(trans('errors.unexpected_error'),
|
||||||
|
Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Laravel\Lumen\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @OA\Info(
|
||||||
|
* title="Wallet Service Externe API",
|
||||||
|
* version="1.0.0",
|
||||||
|
* @OA\Contact(
|
||||||
|
* email="administrateur@ilink-app.com",
|
||||||
|
* url = "https://ilink-app.com/",
|
||||||
|
* name="Developer Team"
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @OA\Get(
|
||||||
|
* path="/",
|
||||||
|
* summary="Afficher la version de lumen",
|
||||||
|
* tags={"Lumen"},
|
||||||
|
* security={{"api_key":{}}},
|
||||||
|
* @OA\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="OK",
|
||||||
|
* @OA\JsonContent(
|
||||||
|
* example = "Lumen xx.xx.xx"
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
class ExampleController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Contracts\Auth\Factory as Auth;
|
||||||
|
|
||||||
|
class Authenticate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The authentication guard factory instance.
|
||||||
|
*
|
||||||
|
* @var \Illuminate\Contracts\Auth\Factory
|
||||||
|
*/
|
||||||
|
protected $auth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new middleware instance.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Contracts\Auth\Factory $auth
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Auth $auth)
|
||||||
|
{
|
||||||
|
$this->auth = $auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|null $guard
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next, $guard = null)
|
||||||
|
{
|
||||||
|
if ($this->auth->guard($guard)->guest()) {
|
||||||
|
return response('Unauthorized.', 401);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
class AuthenticateAccess
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
$validKeys = explode(',' ,env('ACCEPTED_KEYS'));
|
||||||
|
if(in_array($request->header('Authorization') , $validKeys)){
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
abort(Response::HTTP_UNAUTHORIZED);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class ExampleMiddleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class Localization
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
$enLangs=["en","en-US","en_US","ca","in","gb","GB","us","en-029","en-AU","en-BZ","en-CA","en-GB","en-IE","en-IN","en-JM","en-MY","en-NZ","en-PH","en-SG","en-TT","en-US","en-ZA","en-ZW","au","bz","ie","in","jm","my","nz","ph","sg","tt","za"];
|
||||||
|
|
||||||
|
// Check header request and determine localizaton
|
||||||
|
if ($request->hasHeader('X-localization')){
|
||||||
|
$local = $request->header('X-localization');
|
||||||
|
$pos=strpos($local,"-");
|
||||||
|
if($pos!=false){
|
||||||
|
$local=strtolower(explode("-",$local)[0]);
|
||||||
|
}
|
||||||
|
$local= in_array($local, $enLangs) ? 'en' : 'fr';
|
||||||
|
}else{
|
||||||
|
$local ='fr';
|
||||||
|
}
|
||||||
|
// set laravel localization
|
||||||
|
app()->setLocale($local);
|
||||||
|
// continue request
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
|
||||||
|
class SecureApiDocs
|
||||||
|
{
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
// for local, dont add any authentication
|
||||||
|
if (env('APP_ENV') === 'local') {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
$token = $request->get('token');
|
||||||
|
if (!$token) {
|
||||||
|
// try to load the token from referer
|
||||||
|
$query = array();
|
||||||
|
parse_str(
|
||||||
|
parse_url($request->header('referer'), PHP_URL_QUERY),
|
||||||
|
$query
|
||||||
|
);
|
||||||
|
if (isset($query['token'])) {
|
||||||
|
$token = $query['token'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// we will match it against the `SWAGGER_DOCS_TOKEN` environment variable
|
||||||
|
if ($token === env('SWAGGER_DOCS_TOKEN')) {
|
||||||
|
return $next($request);
|
||||||
|
} else {
|
||||||
|
return abort(403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
class ExampleJob extends Job
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
abstract class Job implements ShouldQueue
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Queueable Jobs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This job base class provides a central location to place any logic that
|
||||||
|
| is shared across all of your jobs. The trait included with the class
|
||||||
|
| provides access to the "queueOn" and "delay" queue helper methods.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\ExampleEvent;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class ExampleListener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param \App\Events\ExampleEvent $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(ExampleEvent $event)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Authenticatable;
|
||||||
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Laravel\Lumen\Auth\Authorizable;
|
||||||
|
|
||||||
|
class User extends Model implements AuthenticatableContract, AuthorizableContract
|
||||||
|
{
|
||||||
|
use Authenticatable, Authorizable, HasFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name', 'email',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Boot the authentication services for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
// Here you may define how you wish users to be authenticated for your Lumen
|
||||||
|
// application. The callback which receives the incoming request instance
|
||||||
|
// should return either a User instance or null. You're free to obtain
|
||||||
|
// the User instance via an API token or any other method necessary.
|
||||||
|
|
||||||
|
$this->app['auth']->viaRequest('api', function ($request) {
|
||||||
|
if ($request->input('api_token')) {
|
||||||
|
return User::where('api_token', $request->input('api_token'))->first();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Laravel\Lumen\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
class EventServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The event listener mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $listen = [
|
||||||
|
\App\Events\ExampleEvent::class => [
|
||||||
|
\App\Listeners\ExampleListener::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
// Api Response schema
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @OA\Schema(
|
||||||
|
* schema="ApiResponse",
|
||||||
|
* title="API Response",
|
||||||
|
* description="Format d'un message de reponse",
|
||||||
|
* @OA\Property(
|
||||||
|
* property="status", description="Code de la requete",
|
||||||
|
* @OA\Schema(type="number", example=200)
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="response", description="Resultat de la requete si pas d'erreur",
|
||||||
|
* @OA\Schema(type="object", example="{name : 'Djery'}")
|
||||||
|
* ),
|
||||||
|
* @OA\Property(
|
||||||
|
* property="error", description="Message d'erreur si erreur",
|
||||||
|
* @OA\Schema(type="string", example="There is an error")
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
trait ApiResponser
|
||||||
|
{
|
||||||
|
public function successResponse($data, $code = Response::HTTP_OK)
|
||||||
|
{
|
||||||
|
return response($this->formatResponse($code, $data, null), $code)->header('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function errorResponse($message, $code = Response::HTTP_BAD_REQUEST)
|
||||||
|
{
|
||||||
|
return response()->json($this->formatResponse($code,null,$message), $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function errorMessage($message , $code)
|
||||||
|
{
|
||||||
|
return response($message ,$code)->header('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatResponse(int $status, $response = null , $error = null)
|
||||||
|
{
|
||||||
|
return ['status' => $status , 'response' => $response , 'error' => $error];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,311 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Models\AgentPlus;
|
||||||
|
use App\Models\CodeGenerer;
|
||||||
|
use App\Models\ConfigWallet;
|
||||||
|
use App\Models\CountriesCurrency;
|
||||||
|
use App\Models\Country;
|
||||||
|
use App\Models\Identification;
|
||||||
|
use App\Models\InfosUsersGroup;
|
||||||
|
use App\Models\Network;
|
||||||
|
use App\Models\NetworksAgent;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\UsersDemandesCredit;
|
||||||
|
use App\Models\Wallet;
|
||||||
|
use App\Models\WalletAgent;
|
||||||
|
use App\Models\WalletIlinkTransaction;
|
||||||
|
use App\Models\WalletsUser;
|
||||||
|
use Brick\Math\RoundingMode;
|
||||||
|
use Brick\Money\Context\AutoContext;
|
||||||
|
use Brick\Money\CurrencyConverter;
|
||||||
|
use Brick\Money\ExchangeRateProvider\BaseCurrencyProvider;
|
||||||
|
use Brick\Money\ExchangeRateProvider\PDOProvider;
|
||||||
|
use Brick\Money\ExchangeRateProvider\PDOProviderConfiguration;
|
||||||
|
use Brick\Money\Money;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Input;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
trait Helper
|
||||||
|
{
|
||||||
|
public function sendMail($email, $title, $messageText)
|
||||||
|
{
|
||||||
|
|
||||||
|
$recipients = [$email];
|
||||||
|
Mail::mailer('smtp')->raw($messageText, function ($message) use ($recipients, $title) {
|
||||||
|
$message->subject($title);
|
||||||
|
$message->to($recipients);
|
||||||
|
});
|
||||||
|
// return $this->successResponse("mail envoye");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendPushNotificationToUser($user_code, $message, $data = null, $date = null)
|
||||||
|
{
|
||||||
|
$client = new \GuzzleHttp\Client([
|
||||||
|
'base_uri' => env('NOTIFICATION_SERVICE_URL'),
|
||||||
|
]);
|
||||||
|
$headers = [
|
||||||
|
'Authorization' => env('NOTIFICATION_SERVICE_KEY'),
|
||||||
|
];
|
||||||
|
$body = new \stdClass();
|
||||||
|
$body->user_code = $user_code;
|
||||||
|
$body->message = $message;
|
||||||
|
$body->data = $data;
|
||||||
|
$body->date = $date;
|
||||||
|
$promise = $client->requestAsync('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers])->then();
|
||||||
|
// function (ResponseInterface $res) {
|
||||||
|
// echo $res->getStatusCode() . "\n";
|
||||||
|
// },
|
||||||
|
// function (RequestException $e) {
|
||||||
|
// echo $e->getMessage() . "\n";
|
||||||
|
// echo $e->getRequest()->getMethod();
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
$promise->wait();
|
||||||
|
// return $response->getBody()->getContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendPushNotificationToAgent($agent_code, $message, $data = null, $date = null)
|
||||||
|
{
|
||||||
|
$client = new \GuzzleHttp\Client([
|
||||||
|
'base_uri' => env('NOTIFICATION_SERVICE_URL'),
|
||||||
|
]);
|
||||||
|
$headers = [
|
||||||
|
'Authorization' => env('NOTIFICATION_SERVICE_KEY'),
|
||||||
|
];
|
||||||
|
$body = new \stdClass();
|
||||||
|
$body->agent_code = $agent_code;
|
||||||
|
$body->message = $message;
|
||||||
|
$body->data = $data;
|
||||||
|
$body->date = $date;
|
||||||
|
$promise = $client->requestAsync('POST', '/onesignal/pushToAgent', ['json' => $body, 'headers' => $headers])->then();
|
||||||
|
$promise->wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkPassword($password, $encrypted_password, $salt)
|
||||||
|
{
|
||||||
|
$encrypted_password_to_check = base64_encode(sha1($password . $salt, true) . $salt);
|
||||||
|
return $encrypted_password_to_check == $encrypted_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hashSSHA($string)
|
||||||
|
{
|
||||||
|
$salt = sha1(rand());
|
||||||
|
$salt = substr($salt, 0, 10);
|
||||||
|
$encrypted = base64_encode(sha1($string . $salt, true) . $salt);
|
||||||
|
$hash = array("salt" => $salt, "encrypted" => $encrypted);
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCountryName($id_country)
|
||||||
|
{
|
||||||
|
return Country::findOrFail($id_country)->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNetworkName($id_network)
|
||||||
|
{
|
||||||
|
return Network::findOrFail($id_network)->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toMoneyWithNetwork($amount, $id_network)
|
||||||
|
{
|
||||||
|
$currency = collect(DB::select('SELECT cu.code FROM networks n INNER JOIN countries c ON c.id = n.country_id INNER JOIN currencies cu ON cu.id = c.idCurrency
|
||||||
|
WHERE n.id = :id', ['id' => $id_network]))->first();
|
||||||
|
|
||||||
|
$money = Money::of(round($amount, 2), $currency ? $currency->code : 'XAF', new AutoContext());
|
||||||
|
return $money->formatTo('fr_FR');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toMoney($amount, $id_country)
|
||||||
|
{
|
||||||
|
$country = Country::findOrFail($id_country);
|
||||||
|
$money = Money::of(round($amount, 2), $country->currency->code, new AutoContext());
|
||||||
|
return $money->formatTo('fr_FR');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toMoneyWithCurrencyCode($amount, $currency_code)
|
||||||
|
{
|
||||||
|
$money = Money::of(round($amount, 2), $currency_code, new AutoContext());
|
||||||
|
return $money->formatTo('fr_FR');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function convertMoney($amount, $init_country, $final_country)
|
||||||
|
{
|
||||||
|
// set to whatever your rates are relative to
|
||||||
|
$baseCurrency = 'USD';
|
||||||
|
|
||||||
|
// use your own credentials, or re-use your existing PDO connection
|
||||||
|
$pdo = new PDO('mysql:host=' . env('DB_HOST') . ';dbname=' . env('DB_DATABASE'), env('DB_USERNAME'), env('DB_PASSWORD'));
|
||||||
|
|
||||||
|
$configuration = new PDOProviderConfiguration();
|
||||||
|
|
||||||
|
$configuration->tableName = 'exchange_rate';
|
||||||
|
$configuration->exchangeRateColumnName = 'exchange_rate';
|
||||||
|
$configuration->targetCurrencyColumnName = 'target_currency';
|
||||||
|
$configuration->sourceCurrencyCode = $baseCurrency;
|
||||||
|
|
||||||
|
// this provider loads exchange rates from your database
|
||||||
|
$provider = new PDOProvider($pdo, $configuration);
|
||||||
|
|
||||||
|
// this provider calculates exchange rates relative to the base currency
|
||||||
|
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
|
||||||
|
|
||||||
|
// this currency converter can now handle any currency pair
|
||||||
|
$converter = new CurrencyConverter($provider);
|
||||||
|
$init_country = Country::findOrFail($init_country);
|
||||||
|
$final_country = Country::findOrFail($final_country);
|
||||||
|
$init_money = Money::of(round($amount, 2), $init_country->currency->code, new AutoContext());
|
||||||
|
return $converter->convert($init_money, $final_country->currency->code, RoundingMode::DOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toMoneyWithCurrency($amount, $init_country, $final_country)
|
||||||
|
{
|
||||||
|
return $this->convertMoney($amount, $init_country, $final_country)->formatTo('fr_FR');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toMoneyAmount($amount, $init_country, $final_country)
|
||||||
|
{
|
||||||
|
return $this->convertMoney($amount, $init_country, $final_country)->getAmount()->toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toUSDAmount($amount, $init_country, $final_currency_code = 'USD')
|
||||||
|
{
|
||||||
|
// set to whatever your rates are relative to
|
||||||
|
$baseCurrency = 'USD';
|
||||||
|
|
||||||
|
// use your own credentials, or re-use your existing PDO connection
|
||||||
|
$pdo = new PDO('mysql:host=' . env('DB_HOST') . ';dbname=' . env('DB_DATABASE'), env('DB_USERNAME'), env('DB_PASSWORD'));
|
||||||
|
|
||||||
|
$configuration = new PDOProviderConfiguration();
|
||||||
|
|
||||||
|
$configuration->tableName = 'exchange_rate';
|
||||||
|
$configuration->exchangeRateColumnName = 'exchange_rate';
|
||||||
|
$configuration->targetCurrencyColumnName = 'target_currency';
|
||||||
|
$configuration->sourceCurrencyCode = $baseCurrency;
|
||||||
|
|
||||||
|
// this provider loads exchange rates from your database
|
||||||
|
$provider = new PDOProvider($pdo, $configuration);
|
||||||
|
|
||||||
|
// this provider calculates exchange rates relative to the base currency
|
||||||
|
$provider = new BaseCurrencyProvider($provider, $baseCurrency);
|
||||||
|
|
||||||
|
// this currency converter can now handle any currency pair
|
||||||
|
$converter = new CurrencyConverter($provider);
|
||||||
|
$init_country = Country::findOrFail($init_country);
|
||||||
|
$init_money = Money::of(round($amount, 2), $init_country->currency->code, new AutoContext());
|
||||||
|
return $converter->convert($init_money, $final_currency_code, RoundingMode::DOWN)->getAmount()->toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public function getTransactionID(){
|
||||||
|
// $d = new DateTime();
|
||||||
|
// $first = str_replace(['-',':'], '',$d->format("y-m-d H:i:s.u"));
|
||||||
|
// return str_replace(' ' ,'.',$first);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function getCurrency($id_country)
|
||||||
|
{
|
||||||
|
$cc = CountriesCurrency::findOrFail($id_country);
|
||||||
|
return $cc->currency_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function arrayPaginator($array, Request $request)
|
||||||
|
{
|
||||||
|
$page = $request->query('page', 1);
|
||||||
|
$perPage = 10;
|
||||||
|
$offset = ($page * $perPage) - $perPage;
|
||||||
|
|
||||||
|
return new LengthAwarePaginator(array_slice($array, $offset, $perPage, true), count($array), $perPage, $page,
|
||||||
|
['path' => $request->url(), 'query' => $request->query()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function array_has_dupes($array)
|
||||||
|
{
|
||||||
|
// streamline per @Felix
|
||||||
|
return count($array) !== count(array_unique($array));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Calcul des taxes
|
||||||
|
public function calculateTax(array $taxes, $frais)
|
||||||
|
{
|
||||||
|
$sommeTaux = 0;
|
||||||
|
$sommeFixe = 0;
|
||||||
|
foreach ($taxes as $tax) {
|
||||||
|
if ($tax->type == '%')
|
||||||
|
$sommeTaux += $tax->valeur;
|
||||||
|
|
||||||
|
if ($tax->type == 'fixe')
|
||||||
|
$sommeFixe += $tax->valeur;
|
||||||
|
}
|
||||||
|
return ($frais * $sommeTaux / 100) + $sommeFixe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkMyIdentification($id)
|
||||||
|
{
|
||||||
|
$identification = Identification::where('id_user', $id)->first();
|
||||||
|
if (isset($identification)) {
|
||||||
|
if ($identification->status == 0)
|
||||||
|
return $this->errorResponse(trans('errors.validation_identification_required'));
|
||||||
|
else
|
||||||
|
return $identification;
|
||||||
|
} else {
|
||||||
|
return $this->errorResponse(trans('errors.identification_required'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateGroupCode($length = 8)
|
||||||
|
{
|
||||||
|
$characters = '23456789ABCDEFGHJKLMNOPQRSTUVWXYZ';
|
||||||
|
$charactersLength = strlen($characters);
|
||||||
|
$randomString = '';
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||||
|
}
|
||||||
|
return $randomString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateTransactionCode($length = 12)
|
||||||
|
{
|
||||||
|
$characters = '23456789ABCDEFGHJKLMNOPQRSTUVWXYZ';
|
||||||
|
$charactersLength = strlen($characters);
|
||||||
|
$randomString = '';
|
||||||
|
for ($i = 0; $i < $length; $i++) {
|
||||||
|
$randomString .= $characters[rand(0, $charactersLength - 1)];
|
||||||
|
}
|
||||||
|
return $randomString;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fonction de tri par date
|
||||||
|
public function sortFunction($a, $b)
|
||||||
|
{
|
||||||
|
return strtotime($b->date_creation) - strtotime($a->date_creation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Obtenir l'heure en fonction du pays de l'utilisateur
|
||||||
|
public function getCurrentTime($id_country)
|
||||||
|
{
|
||||||
|
$country = Country::find($id_country);
|
||||||
|
$country_code = isset($country) ? $country->code_country : 'GA';
|
||||||
|
$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code);
|
||||||
|
$date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime();
|
||||||
|
return $date->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtenir l'heure en fonction du code du pays de l'utilisateur
|
||||||
|
public function getCurrentTimeByCountryCode($country_code = 'GA')
|
||||||
|
{
|
||||||
|
$timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code);
|
||||||
|
$date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime();
|
||||||
|
return $date->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| First we need to get an application instance. This creates an instance
|
||||||
|
| of the application / container and bootstraps the application so it
|
||||||
|
| is ready to receive HTTP / Console requests from the environment.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = require __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run The Artisan Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When we run the console application, the current CLI command will be
|
||||||
|
| executed in this console and the response sent back to a terminal
|
||||||
|
| or another output device for the developers. Here goes nothing!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$kernel = $app->make(
|
||||||
|
'Illuminate\Contracts\Console\Kernel'
|
||||||
|
);
|
||||||
|
|
||||||
|
exit($kernel->handle(new ArgvInput, new ConsoleOutput));
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__.'/../vendor/autoload.php';
|
||||||
|
|
||||||
|
(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(
|
||||||
|
dirname(__DIR__)
|
||||||
|
))->bootstrap();
|
||||||
|
|
||||||
|
date_default_timezone_set(env('APP_TIMEZONE', 'UTC'));
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here we will load the environment and create the application instance
|
||||||
|
| that serves as the central piece of this framework. We'll use this
|
||||||
|
| application as an "IoC" container and router for this framework.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = new Laravel\Lumen\Application(
|
||||||
|
dirname(__DIR__)
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->withFacades();
|
||||||
|
|
||||||
|
$app->withEloquent();
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Container Bindings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Now we will register a few bindings in the service container. We will
|
||||||
|
| register the exception handler and the console kernel. You may add
|
||||||
|
| your own bindings here if you like or you can make another file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||||
|
App\Exceptions\Handler::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Console\Kernel::class,
|
||||||
|
App\Console\Kernel::class
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Config Files
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Now we will register the "app" configuration file. If the file exists in
|
||||||
|
| your configuration directory it will be loaded; otherwise, we'll load
|
||||||
|
| the default version. You may register other files below as needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->configure('app');
|
||||||
|
$app->configure('mail');
|
||||||
|
$app->configure('queue');
|
||||||
|
$app->alias('mailer', Illuminate\Mail\Mailer::class);
|
||||||
|
$app->alias('mailer', Illuminate\Contracts\Mail\Mailer::class);
|
||||||
|
$app->alias('mailer', Illuminate\Contracts\Mail\MailQueue::class);
|
||||||
|
$app->configure('swagger-lume');
|
||||||
|
$app->register(\SwaggerLume\ServiceProvider::class);
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, we will register the middleware with the application. These can
|
||||||
|
| be global middleware that run before and after each request into a
|
||||||
|
| route or middleware that'll be assigned to some specific routes.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->middleware([
|
||||||
|
// App\Http\Middleware\ExampleMiddleware::class
|
||||||
|
App\Http\Middleware\Localization::class,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$app->routeMiddleware([
|
||||||
|
// 'auth' => App\Http\Middleware\Authenticate::class,
|
||||||
|
'docs' => App\Http\Middleware\SecureApiDocs::class,
|
||||||
|
'auth' => App\Http\Middleware\AuthenticateAccess::class
|
||||||
|
]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Service Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here we will register all of the application's service providers which
|
||||||
|
| are used to bind services into the container. Service providers are
|
||||||
|
| totally optional, so you are not required to uncomment this line.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// $app->register(App\Providers\AppServiceProvider::class);
|
||||||
|
// $app->register(App\Providers\AuthServiceProvider::class);
|
||||||
|
// $app->register(App\Providers\EventServiceProvider::class);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Load The Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next we will include the routes file so that they can all be added to
|
||||||
|
| the application. This will provide all of the URLs the application
|
||||||
|
| can respond to, as well as the controllers that may handle them.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->router->group([
|
||||||
|
'namespace' => 'App\Http\Controllers',
|
||||||
|
], function ($router) {
|
||||||
|
require __DIR__.'/../routes/web.php';
|
||||||
|
});
|
||||||
|
|
||||||
|
return $app;
|
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
"name": "laravel/lumen",
|
||||||
|
"description": "The Laravel Lumen Framework.",
|
||||||
|
"keywords": ["framework", "laravel", "lumen"],
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "project",
|
||||||
|
"require": {
|
||||||
|
"php": "^7.3|^8.0",
|
||||||
|
"darkaonline/swagger-lume": "^8.0",
|
||||||
|
"guzzlehttp/guzzle": "^7.0",
|
||||||
|
"laravel/lumen-framework": "^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
"mockery/mockery": "^1.3.1",
|
||||||
|
"phpunit/phpunit": "^9.3"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"classmap": [
|
||||||
|
"tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true,
|
||||||
|
"optimize-autoloader": true
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"scripts": {
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
],
|
||||||
|
"post-install-cmd": [
|
||||||
|
"cp -a vendor/swagger-api/swagger-ui/dist public/swagger-ui-assets"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Mailer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default mailer that is used to send any email
|
||||||
|
| messages sent by your application. Alternative mailers may be setup
|
||||||
|
| and used as needed; however, this mailer will be used by default.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => 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'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Queue Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Laravel's queue API supports an assortment of back-ends via a single
|
||||||
|
| API, giving you convenient access to each back-end using the same
|
||||||
|
| syntax for every one. Here you may define a default connection.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('QUEUE_CONNECTION', 'sync'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Queue Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the connection information for each server that
|
||||||
|
| is used by your application. A default configuration has been added
|
||||||
|
| for each back-end shipped with Laravel. You are free to add more.
|
||||||
|
|
|
||||||
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sync' => [
|
||||||
|
'driver' => 'sync',
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'table' => 'jobs',
|
||||||
|
'queue' => 'default',
|
||||||
|
'retry_after' => 90,
|
||||||
|
],
|
||||||
|
|
||||||
|
'beanstalkd' => [
|
||||||
|
'driver' => 'beanstalkd',
|
||||||
|
'host' => 'localhost',
|
||||||
|
'queue' => 'default',
|
||||||
|
'retry_after' => 90,
|
||||||
|
'block_for' => 0,
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqs' => [
|
||||||
|
'driver' => 'sqs',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||||
|
'queue' => env('SQS_QUEUE', 'your-queue-name'),
|
||||||
|
'suffix' => env('SQS_SUFFIX'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => 'default',
|
||||||
|
'queue' => env('REDIS_QUEUE', 'default'),
|
||||||
|
'retry_after' => 90,
|
||||||
|
'block_for' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Failed Queue Jobs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These options configure the behavior of failed queue job logging so you
|
||||||
|
| can control which database and table are used to store the jobs that
|
||||||
|
| have failed. You may change them to any database / table you wish.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => [
|
||||||
|
'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
|
||||||
|
'database' => env('DB_CONNECTION', 'mysql'),
|
||||||
|
'table' => 'failed_jobs',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,210 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'api' => [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Edit to set the api's title
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'title' => 'iLink APP API',
|
||||||
|
],
|
||||||
|
|
||||||
|
'routes' => [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Route for accessing api documentation interface
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'api' => '/api/documentation',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Route for accessing parsed swagger annotations.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'docs' => '/docs',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Route for Oauth2 authentication callback.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'oauth2_callback' => '/api/oauth2-callback',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Route for serving assets
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'assets' => '/swagger-ui-assets',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Middleware allows to prevent unexpected access to API documentation
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'middleware' => [
|
||||||
|
'api' => ['docs'],
|
||||||
|
'asset' => [],
|
||||||
|
'docs' => ['docs'],
|
||||||
|
'oauth2_callback' => [],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'paths' => [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Absolute path to location where parsed swagger annotations will be stored
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'docs' => storage_path('api-docs'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| File name of the generated json documentation file
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'docs_json' => 'api-docs.json',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Absolute path to directory containing the swagger annotations are stored.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'annotations' => base_path('app'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Absolute path to directories that you would like to exclude from swagger generation
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'excludes' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Edit to set the swagger scan base path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'base' => env('L5_SWAGGER_BASE_PATH', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Absolute path to directory where to export views
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'views' => base_path('resources/views/vendor/swagger-lume'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| API security definitions. Will be generated into documentation file.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'security' => [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Examples of Security definitions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
'api_key_security_example' => [ // Unique name of security
|
||||||
|
'type' => 'apiKey', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
|
||||||
|
'description' => 'A short description for security scheme',
|
||||||
|
'name' => 'api_key', // The name of the header or query parameter to be used.
|
||||||
|
'in' => 'header', // The location of the API key. Valid values are "query" or "header".
|
||||||
|
],
|
||||||
|
'oauth2_security_example' => [ // Unique name of security
|
||||||
|
'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
|
||||||
|
'description' => 'A short description for oauth2 security scheme.',
|
||||||
|
'flow' => 'implicit', // The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode".
|
||||||
|
'authorizationUrl' => 'http://example.com/auth', // The authorization URL to be used for (implicit/accessCode)
|
||||||
|
//'tokenUrl' => 'http://example.com/auth' // The authorization URL to be used for (password/application/accessCode)
|
||||||
|
'scopes' => [
|
||||||
|
'read:projects' => 'read your projects',
|
||||||
|
'write:projects' => 'modify projects in your account',
|
||||||
|
]
|
||||||
|
],*/
|
||||||
|
|
||||||
|
/* Open API 3.0 support
|
||||||
|
'passport' => [ // Unique name of security
|
||||||
|
'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
|
||||||
|
'description' => 'Laravel passport oauth2 security.',
|
||||||
|
'in' => 'header',
|
||||||
|
'scheme' => 'https',
|
||||||
|
'flows' => [
|
||||||
|
"password" => [
|
||||||
|
"authorizationUrl" => config('app.url') . '/oauth/authorize',
|
||||||
|
"tokenUrl" => config('app.url') . '/oauth/token',
|
||||||
|
"refreshUrl" => config('app.url') . '/token/refresh',
|
||||||
|
"scopes" => []
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
'api_key' => [ // Unique name of security
|
||||||
|
'type' => 'apiKey', // Valid values are "basic", "apiKey" or "oauth2".
|
||||||
|
'description' => "Api Key",
|
||||||
|
'name' => 'Authorization', // The name of the header or query parameter to be used.
|
||||||
|
'in' => 'header', // The location of the API key. Valid values are "query" or "header".
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Turn this off to remove swagger generation on production
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'generate_always' => env('SWAGGER_GENERATE_ALWAYS', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Edit to set the swagger version number
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'swagger_version' => env('SWAGGER_VERSION', '3.0'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Edit to trust the proxy's ip address - needed for AWS Load Balancer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'proxy' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configs plugin allows to fetch external configs instead of passing them to SwaggerUIBundle.
|
||||||
|
| See more at: https://github.com/swagger-api/swagger-ui#configs-plugin
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'additional_config_url' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically),
|
||||||
|
| 'method' (sort by HTTP method).
|
||||||
|
| Default is the order returned by the server unchanged.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'operations_sort' => env('L5_SWAGGER_OPERATIONS_SORT', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Uncomment to pass the validatorUrl parameter to SwaggerUi init on the JS
|
||||||
|
| side. A null value here disables validation.
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
'validator_url' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Uncomment to add constants which can be used in anotations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
'constants' => [
|
||||||
|
// 'SWAGGER_LUME_CONST_HOST' => env('SWAGGER_LUME_CONST_HOST', 'http://my-default-host.com'),
|
||||||
|
],
|
||||||
|
];
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = User::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->faker->name,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
// $this->call('UsersTableSeeder');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Application Test Suite">
|
||||||
|
<directory suffix="Test.php">./tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<php>
|
||||||
|
<env name="APP_ENV" value="testing"/>
|
||||||
|
<env name="CACHE_DRIVER" value="array"/>
|
||||||
|
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||||
|
</php>
|
||||||
|
</phpunit>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
Options -MultiViews -Indexes
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
# Handle Authorization Header
|
||||||
|
RewriteCond %{HTTP:Authorization} .
|
||||||
|
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||||
|
|
||||||
|
# Redirect Trailing Slashes If Not A Folder...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_URI} (.+)/$
|
||||||
|
RewriteRule ^ %1 [L,R=301]
|
||||||
|
|
||||||
|
# Handle Front Controller...
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ index.php [L]
|
||||||
|
</IfModule>
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| First we need to get an application instance. This creates an instance
|
||||||
|
| of the application / container and bootstraps the application so it
|
||||||
|
| is ready to receive HTTP / Console requests from the environment.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = require __DIR__.'/../bootstrap/app.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Once we have the application, we can handle the incoming request
|
||||||
|
| through the kernel, and send the associated response back to
|
||||||
|
| the client's browser allowing them to enjoy the creative
|
||||||
|
| and wonderful application we have prepared for them.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->run();
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'model_not_found' => 'Does not exist any instance of :model with given id',
|
||||||
|
'unexpected_error' => 'Unexpected error. Try later',
|
||||||
|
'validation_error' => 'The field :field has :validation',
|
||||||
|
'service_unavailable' => 'Service unavailable',
|
||||||
|
];
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
];
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
"EN_COURS" => "CURRENT",
|
||||||
|
"CASSE" => "BROKEN",
|
||||||
|
"EN_ATTENTE_DE_VALIDATION" => "PENDING VALIDATION",
|
||||||
|
"REMBOURSE" => "REFUNDED",
|
||||||
|
"NON_VALIDE" => "INVALID",
|
||||||
|
"VALIDE" => "VALID",
|
||||||
|
"SIMPLE" => "SIMPLE",
|
||||||
|
"BLOQUE" => "BLOCKED",
|
||||||
|
"NON_TRAITEE" => "NOT TREATED",
|
||||||
|
"TRAITEE" => "TREATED",
|
||||||
|
"groupe" => 'GROUP',
|
||||||
|
"individuel" => "INDIVIDUAL"
|
||||||
|
];
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'model_not_found' => 'Il n\'existe aucune instance de :model avec l\'id donné',
|
||||||
|
'unexpected_error' => 'Erreur inattendue. Essayer plus tard',
|
||||||
|
'validation_error' => 'Le champ :field a :validation',
|
||||||
|
'service_unavailable' => 'Service non disponible',
|
||||||
|
'invalid_cvv' => 'CVV invalide',
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
];
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
"EN_COURS" => "EN COURS",
|
||||||
|
"CASSE" => "CASSÉE",
|
||||||
|
"EN_ATTENTE_DE_VALIDATION" => "EN ATTENTE DE VALIDATION",
|
||||||
|
"REMBOURSE" => "REMBOURSE",
|
||||||
|
"NON_VALIDE" => "NON VALIDE",
|
||||||
|
"VALIDE" => "VALIDE",
|
||||||
|
"SIMPLE" => "SIMPLE",
|
||||||
|
"BLOQUE" => "BLOQUÉE",
|
||||||
|
"NON_TRAITEE" => "NON_TRAITÉE",
|
||||||
|
"TRAITEE" => "TRAITÉE",
|
||||||
|
"groupe" => 'GROUPE',
|
||||||
|
"individuel" => "INDIVIDUEL"
|
||||||
|
];
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/** @var \Laravel\Lumen\Routing\Router $router */
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Routes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is where you can register all of the routes for an application.
|
||||||
|
| It is a breeze. Simply tell Lumen the URIs it should respond to
|
||||||
|
| and give it the Closure to call when that URI is requested.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($router) {
|
||||||
|
$router->get('/', function () use ($router) {
|
||||||
|
return $router->app->version();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,3 @@
|
||||||
|
*
|
||||||
|
!data/
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Laravel\Lumen\Testing\DatabaseMigrations;
|
||||||
|
use Laravel\Lumen\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
|
class ExampleTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A basic test example.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testExample()
|
||||||
|
{
|
||||||
|
$this->get('/');
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$this->app->version(), $this->response->getContent()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Laravel\Lumen\Testing\TestCase as BaseTestCase;
|
||||||
|
|
||||||
|
abstract class TestCase extends BaseTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates the application.
|
||||||
|
*
|
||||||
|
* @return \Laravel\Lumen\Application
|
||||||
|
*/
|
||||||
|
public function createApplication()
|
||||||
|
{
|
||||||
|
return require __DIR__.'/../bootstrap/app.php';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue