Initial commit

This commit is contained in:
Christophe LATOUR 2017-07-21 16:40:11 +02:00
commit c88ea57ba5
56 changed files with 5147 additions and 0 deletions

17
.env_dev Normal file
View File

@ -0,0 +1,17 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=e!MV*C9N*B5&#FJbyf*2c8m5QOJOGeQ6&8eCL_qo
APP_TIMEZONE=UTC
DB_CONNECTION=mysql
DB_HOST=192.168.0.44
DB_PORT=3306
DB_DATABASE=brico_dev
DB_USERNAME=brico_dev
DB_PASSWORD=brico_dev42
DOMAIN_STATIC=www.bricoprive.com
CACHE_DRIVER=file
QUEUE_DRIVER=sync

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
~*
._*
*~
.buildpath
config.codekit
.DS_Store
.DS_Store?
.env
.env.php
.env.*.php
Homestead.json
Homestead.yaml
.idea
*.komodoproject
*.log
.netbeans
.project
.project
.sass-cache
.settings
.Spotlight-V100
*.sublime*
.svn
.*.swp
.Trash*
[Tt]humbs.db
.zfs/
vendor/*

41
README.md Normal file
View File

@ -0,0 +1,41 @@
Welcome to History API for brico!
===================
## **Init project**
```
composer install
```
The default env is
```
APP_ENV=local
APP_DEBUG=true
APP_KEY=e!MV*C9N*B5&#FJbyf*2c8m5QOJOGeQ6&8eCL_qo
APP_TIMEZONE=UTC
DB_CONNECTION=mysql
DB_HOST=192.168.0.44
DB_PORT=3306
DB_DATABASE=brico_dev
DB_USERNAME=brico_dev
DB_PASSWORD=brico_dev42
DOMAIN_STATIC=www.bricoprive.com
CACHE_DRIVER=file
QUEUE_DRIVER=sync
```
Configure your vhost
DocumentRoot shoud be /your/path/to/your/project/**public/**
Call http://your_domain.com/history
## **Test**
Example on (192.168.0.93)
Add this on your /etc/hosts to test
```
192.168.0.93 local.api.com
```
The call http://local.api.com/history

0
app/Classes/.gitkeep Normal file
View File

110
app/Classes/Application.php Normal file
View File

@ -0,0 +1,110 @@
<?php
namespace App\Classes;
use Laravel\Lumen\Application as BaseApplication;
class Application extends BaseApplication {
public function setLocale() {
$locale = $this->app['config']->get('app.locale', 'en_US').'.UTF-8';
setlocale(LC_ALL, $locale);
putenv('LANG='.$locale);
putenv('OS_LOCALE='.$locale);
putenv('LANGUAGE='.$locale);
}
public function configure($name) {
if(isset($this->loadedConfigurations[$name])) {
return;
}
$this->loadedConfigurations[$name] = TRUE;
$path = $this->getConfigurationPath($name, FALSE);
if($path) {
$this->make('config')->set($name, require $path);
}
$path = $this->getConfigurationPath($name, TRUE);
if($path) {
$this->app['config']->set(
$name,
array_merge(
$this->app['config']->get($name, []),
require $path
)
);
}
}
/**
* Register the aliases for the application.
*
* @param array $userAliases
* @return void
*/
public function withAliases($userAliases = [])
{
$defaults = [
'Illuminate\Support\Facades\Auth' => 'Auth',
'Illuminate\Support\Facades\Cache' => 'Cache',
'Illuminate\Support\Facades\DB' => 'DBLumen',
'Illuminate\Support\Facades\Event' => 'Event',
'Illuminate\Support\Facades\Gate' => 'Gate',
'Illuminate\Support\Facades\Log' => 'Log',
'Illuminate\Support\Facades\Queue' => 'Queue',
'Illuminate\Support\Facades\Schema' => 'Schema',
'Illuminate\Support\Facades\URL' => 'URL',
'Illuminate\Support\Facades\Validator' => 'Validator',
];
if (! static::$aliasesRegistered) {
static::$aliasesRegistered = true;
$merged = array_merge($defaults, $userAliases);
foreach ($merged as $original => $alias) {
class_alias($original, $alias);
}
}
}
public function getConfigurationPath($name = NULL, $only_defaults = NULL) {
if(!isset($this->lumen_path)) {
global $composer_autoloader;
$this->lumen_path = dirname(realpath($composer_autoloader->findFile(BaseApplication::class)));
}
if(!$name) {
$appConfigDir = $this->basePath('config').'/';
if(
file_exists($appConfigDir)
&& $only_defaults !== FALSE
) {
return $appConfigDir;
} elseif(
file_exists($path = $this->lumen_path.'/../config/')
&& !$only_defaults
) {
return $path;
}
} else {
$appConfigPath = $this->basePath('config').'/'.$name.'.php';
if(
file_exists($appConfigPath)
&& $only_defaults !== FALSE
) {
return $appConfigPath;
} elseif(
file_exists($path = $this->lumen_path.'/../config/'.$name.'.php')
&& !$only_defaults
) {
return $path;
}
}
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Classes;
use Monolog\Handler\ErrorLogHandler as BaseErrorLogHandler;
class ErrorLogHandler extends BaseErrorLogHandler {
protected function write(array $record) {
if($this->expandNewlines) {
$lines = preg_split('{[\r\n]+}', (string) $record['message']);
foreach($lines as $line) {
error_log($line, $this->messageType);
}
} else {
error_log((string) $record['message'], $this->messageType);
}
}
}

0
app/Console/.gitkeep Normal file
View File

29
app/Console/Kernel.php Normal file
View File

@ -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 = [
\Laravelista\LumenVendorPublish\VendorPublishCommand::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule) {
//
}
}

0
app/Events/.gitkeep Normal file
View File

0
app/Exceptions/.gitkeep Normal file
View File

View File

@ -0,0 +1,65 @@
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
class Handler extends ExceptionHandler
{
/**
* 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 \Exception $e
* @return void
*/
public function report(Exception $e)
{
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if (env('APP_DEBUG') === true) {
return parent::render($request, $e);
} else {
$statusCode = 500;
if ($e instanceof ModelNotFoundException) {
$statusCode = 404;
} elseif ($e instanceof HttpException) {
$statusCode = $e->getStatusCode();
}
return response()->json(array(
'errors' => array(
$e->getMessage(),
)
), $statusCode);
}
}
}

0
app/Jobs/.gitkeep Normal file
View File

0
app/Listeners/.gitkeep Normal file
View File

0
app/Models/.gitkeep Normal file
View File

35
app/Models/Carrier.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Antadis\API\Front\Models\Carrier as BaseCarrier;
/**
* @rest\model Carrier
* @rest\property inetger is_relay
*/
class Carrier extends BaseCarrier
{
protected $_relayConfiguration = NULL;
/**
* Returns carrier_ids which are relay
* @return type
*/
protected function getRelayConfiguration() {
if ($this->_relayConfiguration === NULL) {
$this->_relayConfiguration = \Configuration::get('ANT_CARRIERS_OOH');
}
return $this->_relayConfiguration;
}
/**
* {@inheritdoc}
*/
public function toArray() {
$relayConfiguration = $this->getRelayConfiguration();
return array_merge(parent::toArray(), array(
'is_relay' => in_array($this->id, explode(',', $relayConfiguration))
));
}
}

27
app/Models/Cart.php Normal file
View File

@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Antadis\API\Front\Models\Cart as BaseCart;
class Cart extends BaseCart
{
/**
* {@inheritdoc}
*/
public function toArray() {
if (!class_exists('SaleDelay')) {
require_once _PS_ROOT_DIR_.'/modules/privatesales_delay/saledelay.php';
}
$products_delay = \SaleDelay::associateDelay($this->getProducts());
$delays = array_keys($products_delay);
$date = new \DateTime();
$delivery_date = \SaleDelay::getDeliveryDate($delays, null, $date, true);
return array_merge(parent::toArray(), array(
'delay' => empty($delivery_date) ? '' : $delivery_date
));
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Models\Order;
use Antadis\API\Front\Models\Order\OrderDetail as BaseOrderDetail;
class OrderDetail extends BaseOrderDetail
{
/**
* {@inheritdoc}
*/
public function toArray() {
return parent::toArray();
}
}

31
app/Models/Tag.php Normal file
View File

@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Antadis\API\Front\Models\Tag as BaseTag;
use Illuminate\Support\Collection;
require_once _PS_ROOT_DIR_ . '/modules/privatesales_family_menu/privatesales_family_menu.php';
class Tag extends BaseTag
{
/**
* @Override
*/
static public function apiGetTags() {
global $cookie;
$modules_tags = new \Privatesales_Family_Menu();
$raw_tags = $modules_tags->getTree($cookie->id_lang);
$tags = new Collection();
foreach ($raw_tags as $tag) {
$tagModel = new static();
$tagModel->name = $tag['name'];
$tagModel->id = $tag['id_category_family'];
$tags->push($tagModel);
}
return $tags;
}
}

30
app/Models/User.php Normal file
View File

@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Antadis\API\Front\Models\Customer as BaseCustomer;
use Antadis\Auth\Wsse\Contracts\WsseUser;
use Illuminate\Support\Collection;
require_once _PS_ROOT_DIR_ . '/modules/privatesales_family_menu/privatesales_family_menu.php';
class User extends BaseCustomer implements WsseUser
{
/**
* @see Antadis\Auth\Wsse\Contracts\WsseUser::findByUsername()
*/
static public function findByUsername($username) {
$model = new static();
$user = $model->getByEmail($username);
$model->populate($user, $user['id_customer']);
return $model;
}
/**
* @see Antadis\Auth\Wsse\Contracts\WsseUser::getWssePassword()
*/
public function getWssePassword() {
return $this->passwd;
}
}

0
app/Providers/.gitkeep Normal file
View File

View File

@ -0,0 +1,47 @@
<?php
namespace App\Providers;
use App\Models\User;
use Antadis\Security\Wsse\WsseHeaderGenerator;
use Antadis\Security\Wsse\Dater;
use Antadis\Security\Wsse\Noncer;
use Antadis\Security\Wsse\Digester;
use Antadis\Gateways\Prestashop;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use ApiUser;
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()
{
$this->app['auth']->viaRequest('api', function ($request) {
//BRICO USER 2553994 (latour@antadis.com)
//BBB USER 952478 (marion@antadis.com)
$user = new ApiUser(952478);
if (\Validate::isLoadedObject($user)) {
return $user;
} else {
return null;
}
return User::findByEmail('latour@antadis.com');
});
}
}

View File

0
app/Web/.gitkeep Normal file
View File

View File

View File

@ -0,0 +1,38 @@
<?php
namespace App\Web\Controllers;
use Antadis\API\Front\Web\Controllers\AddressController as BaseAddressController;
use App\Models\Address;
use Illuminate\Http\Request;
class AddressController extends BaseAddressController
{
/**
* {@inheritdoc}
*/
public function lists(Request $request) {
return parent::lists($request);
}
/**
* {@inheritdoc}
*/
public function update(Request $request, $id_address) {
return parent::update($request, $id_address);
}
/**
* {@inheritdoc}
*/
public function create(Request $request) {
return parent::create($request);
}
/**
* {@inheritdoc}
*/
public function get(Request $request, $id_address) {
return parent::get($request, $id_address);
}
}

View File

@ -0,0 +1,61 @@
<?php
namespace App\Web\Controllers;
use App\Models\User;
use Antadis\API\Front\Web\Controllers\AuthController as BaseAuthController;
use Illuminate\Http\Request;
use ApiCart;
class AuthController extends BaseAuthController
{
/**
* {@inheritdoc}
*/
public function signin(Request $request)
{
global $cookie;
$user = parent::signin($request);
$cartModel = ApiCart::class;
$cookie->id_customer = $user->id;
$cookie->customer_lastname = $user->lastname;
$cookie->customer_firstname = $user->firstname;
$cookie->passwd = $user->passwd;
$cookie->logged = 1;
$cookie->id_currency = 1;
$cookie->email = $user->email;
$cookie->id_cart = ApiCart::lastNoneOrderedCart($user->id);
$cookie->write();
return $user;
}
/**
* {@inheritdoc}
*/
public function signout(Request $request)
{
return parent::signout($request);
}
/**
* {@inheritdoc}
*/
public function signup(Request $request)
{
$user = parent::signup($request);
return $user;
}
/**
* {@inheritdoc}
*/
public function recover(Request $request)
{
return parent::recover($request);
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Web\Controllers;
use App\Models\Carrier;
use Antadis\API\Front\Web\Controllers\CartController as BaseCartController;
use Illuminate\Http\Request;
class CartController extends BaseCartController
{
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Web\Controllers;
use Antadis\API\Front\Web\Controllers\CategoryController as BaseCategoryController;
use Illuminate\Http\Request;
class CategoryController extends BaseCategoryController
{
/**
* {@inheritdoc}
*/
public function get(Request $request, $id_category) {
return parent::get($request, $id_category);
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Web\Controllers;
use App\Models\Carrier;
use Antadis\API\Front\Web\Controllers\Controller as BaseController;
use Illuminate\Http\Request;
class Controller extends BaseController
{
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Web\Controllers;
use Illuminate\Http\Request;
use Antadis\API\Front\Web\Controllers\DiscountController as BaseDiscountController;
use App\Models\Discount\Discount;
class DiscountController extends BaseDiscountController
{
/**
* {@inheritdoc}
*/
public function lists(Request $request) {
return parent::lists($request);
}
/**
* {@inheritdoc}
*/
public function get(Request $request, $id_discount) {
return parent::get($request, $id_discount);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Web\Controllers;
use Antadis\API\Front\Web\Controllers\GeneratorController as BaseGeneratorController;
use Antadis\API\Swagger\Generator;
class GeneratorController extends BaseGeneratorController
{
public function index() {
return parent::index();
}
protected function getDefaultSwaggerFiles() {
//MERGE OVERRIDED SWAGGER CONFIGURATION
return array_merge([
__DIR__.'/../../Models/Carrier.php',
], parent::getDefaultSwaggerFiles());
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Web\Controllers;
use Illuminate\Http\Request;
use Antadis\API\Front\Web\Controllers\OrderController as BaseOrderController;
use App\Models\Order\Detail;
class OrderController extends BaseOrderController
{
/**
* {@inheritdoc}
*/
public function lists(Request $request) {
return parent::lists($request);
}
/**
* {@inheritdoc}
*/
public function get(Request $request, $id_order) {
return parent::get($request, $id_order);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Web\Controllers;
use Antadis\API\Front\Web\Controllers\ProductController as BaseProductController;
use App\Models\Product\Product;
use Illuminate\Http\Request;
class ProductController extends BaseProductController
{
/**
* {@inheritdoc}
*/
public function get(Request $request, $id_product) {
return parent::get($request, $id_product);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Web\Controllers;
use Antadis\API\Front\Web\Controllers\SaleController as BaseSaleController;
use Illuminate\Http\Request;
class SaleController extends BaseSaleController
{
/**
* {@inheritdoc}
*/
public function lists(Request $request) {
return parent::lists($request);
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Web\Controllers;
use App\Models\Tag;
use Antadis\API\Front\Web\Controllers\TagController as BaseTagController;
use Illuminate\Http\Request;
class TagController extends BaseTagController
{
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Web\Controllers;
use Illuminate\Http\Request;
use Antadis\API\Front\Web\Controllers\UserController as BaseUserController;
class UserController extends BaseUserController
{
}

View File

View File

@ -0,0 +1,44 @@
<?php
namespace App\Web\Middlewares;
use Closure;
use Illuminate\Contracts\Auth\Factory as Auth;
use \Illuminate\Http\Request;
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 $request, Closure $next, $guard = null)
{
if ($this->auth->guard($guard)->guest()) {
return response('Unauthorized.', 401);
}
return $next($request);
}
}

35
artisan Executable file
View File

@ -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));

128
bootstrap/app.php Normal file
View File

@ -0,0 +1,128 @@
<?php
require_once __DIR__.'/../../bebeboutik/config/config.inc.php';
require_once __DIR__ . '/../../bebeboutik/config/autoload_lumen.php';
// require_once __DIR__.'/../../brico/www/config/config.inc.php';
// require_once __DIR__ . '/../../brico/www/config/autoload_lumen.php';
$composer_autoloader = require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../config/env.php';
/*
|--------------------------------------------------------------------------
| 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 App\Classes\Application(
realpath(__DIR__.'/../')
);
foreach(array(
'app',
'auth',
'broadcasting',
'cache',
'database',
'queue',
'session',
'view',
'wsse',
'api',
'cors',
) as $configuration) {
$app->configure($configuration);
}
$app->setLocale();
//$app->withFacades();
// Needed to use Eloquent
//$app->withEloquent();
$app->configureMonologUsing(function($monolog) {
$monolog->pushHandler(new App\Classes\ErrorLogHandler());
return $monolog;
});
/*
|--------------------------------------------------------------------------
| 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 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->routeMiddleware([
'auth' => App\Web\Middlewares\Authenticate::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(Antadis\Gateways\Prestashop\ServiceProvider::class);
if (env('APP_DEBUG') === true) {
//AUTOLOGGED USER
$app->register(App\Providers\AuthServiceProvider::class);
} else {
//REAL APP USER
$app->register(Antadis\Auth\Wsse\WsseAuthServiceProvider::class);
}
$app->register(Barryvdh\Cors\ServiceProvider::class);
$app->register(Antadis\API\Front\ApiProvider::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->group(['namespace' => 'App\Web\Controllers'], function ($app) {
require __DIR__.'/../routes/web.php';
});
return $app;

54
composer.json Normal file
View File

@ -0,0 +1,54 @@
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"private": true,
"require": {
"php": ">=5.6.4",
"laravel/lumen-framework": "5.4.*",
"antadis/auth-provider-wsse": "0.1.*",
"antadis/api-front" : "0.1.*",
"barryvdh/laravel-cors": "^0.9.2"
},
"require-dev": {
"antadis/swagger-generator" : "0.2.*",
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~5.0",
"mockery/mockery": "~0.9",
"laravelista/lumen-vendor-publish": "~2.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Antadis\\API\\Front\\" : "vendor/antadis/API/front/src/",
"Antadis\\Security\\Wsse\\" : "vendor/antadis/Security/Wsse/src/"
}
},
"autoload-dev": {
"classmap": [
"tests/",
"database/"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://gitlab-composer.antadis.net/"
}
],
"scripts": {
"post-root-package-install": [
],
"post-install-cmd": [
"for item in $(grep -ls \"lib-post-install-cmd\" ./vendor/*/*/composer.json); do composer run-script lib-post-install-cmd -d $(dirname ${item}); done",
"cp .env_dev .env"
],
"post-update-cmd": [
"for item in $(grep -ls \"lib-post-update-cmd\" ./vendor/*/*/composer.json); do composer run-script lib-post-update-cmd -d $(dirname ${item}); done"
]
}
}

3905
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

2
config/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -0,0 +1,12 @@
<?php
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/

View File

View File

@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}

27
phpunit.xml Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/app.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>

20
public/.htaccess Normal file
View File

@ -0,0 +1,20 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

28
public/index.php Normal file
View File

@ -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
resources/views/.gitkeep Normal file
View File

101
routes/web.php Normal file
View File

@ -0,0 +1,101 @@
<?php
/*
|--------------------------------------------------------------------------
| 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.
|
*/
$app->middleware([
Barryvdh\Cors\HandleCors::class,
]);
/** SWGGER DOCUMENTATION */
$app->get('/documentation', 'GeneratorController@index');
$app->post('/signup', 'AuthController@signup');
$app->post('/signout', 'AuthController@signout');
$app->post('/recover', 'AuthController@recover');
$app->group(['middleware' => 'auth'], function() use ($app) {
/*
|--------------------------------------------------------------------------
| AUTH ROUTES
|--------------------------------------------------------------------------
*/
$app->post('/signin', 'AuthController@signin');
/*
|--------------------------------------------------------------------------
| SALE ROUTES
|--------------------------------------------------------------------------
*/
$app->get('/sales', 'SaleController@lists');
$app->get('/tags', 'TagController@lists');
/*
|--------------------------------------------------------------------------
| CATEGORY ROUTES
|--------------------------------------------------------------------------
*/
$app->get('/category/{id_category}', 'CategoryController@get');
$app->get('/category/{id_category}/products', 'CategoryController@list_products');
/*
|--------------------------------------------------------------------------
| PRODUCT ROUTES
|--------------------------------------------------------------------------
*/
$app->get('/product/{id_product}', 'ProductController@get');
/*
|--------------------------------------------------------------------------
| CART ROUTES
|--------------------------------------------------------------------------
*/
$app->get('/cart', 'CartController@get');
/* CART CARRIERS */
$app->get('/cart/carriers', 'CartController@getCarriers');
$app->put('/cart/carrier', 'CartController@setCarrier');
/* CART PRODUCTS */
$app->put('/cart/product', 'CartController@addProduct');
$app->delete('/cart/product', 'CartController@removeProduct');
/* CART DISCOUNTS */
$app->put('/cart/discount', 'CartController@addDiscount');
/* CART ADDRESS */
$app->put('/cart/address', 'CartController@setAddress');
/*
|--------------------------------------------------------------------------
| USER ROUTES
|--------------------------------------------------------------------------
*/
$app->get('/user', 'UserController@get');
$app->get('/user/discounts', 'DiscountController@lists');
$app->get('/user/discount/{id_discount}', 'DiscountController@get');
$app->get('/user/orders', 'OrderController@lists');
$app->get('/user/order/{id_order}', 'OrderController@get');
$app->get('/user/addresses', 'AddressController@lists');
$app->get('/user/address/{id_address}', 'AddressController@get');
$app->put('/user/address/{id_address}', 'AddressController@update');
$app->post('/user/address', 'AddressController@create');
$app->delete('/user/address/{id_address}', 'AddressController@delete');
});

2
storage/app/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/cache/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/framework/views/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
storage/logs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

14
tests/TestCase.php Normal file
View File

@ -0,0 +1,14 @@
<?php
abstract class TestCase extends Laravel\Lumen\Testing\TestCase
{
/**
* Creates the application.
*
* @return \Laravel\Lumen\Application
*/
public function createApplication()
{
return require __DIR__.'/../bootstrap/app.php';
}
}