Merge branch 'master' of https://github.com/bagisto/bagisto into 4754

This commit is contained in:
rahul shukla 2021-04-07 17:00:48 +05:30
commit 961ccea17d
9 changed files with 280 additions and 102 deletions

View File

@ -4,8 +4,12 @@ on: [push, pull_request]
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.3', '7.4', '8.0']
name: PHP ${{ matrix.php-versions }} test on ${{ matrix.operating-system }}
services:
mysql:
@ -26,7 +30,7 @@ jobs:
- name: Setup php
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
php-version: ${{ matrix.php-versions }}
extensions: curl, gd, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer, zip
- name: Set environment

View File

@ -8,7 +8,7 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^7.3",
"php": "^7.3|^8.0",
"algolia/algoliasearch-client-php": "^2.2",
"astrotomic/laravel-translatable": "^11.0.0",
"aws/aws-sdk-php": "^3.171",
@ -40,15 +40,15 @@
"tymon/jwt-auth": "^1.0.0"
},
"require-dev": {
"codeception/codeception": "4.1.19",
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.1",
"codeception/module-filesystem": "^1.0",
"codeception/module-laravel5": "^1.0",
"codeception/module-webdriver": "^1.0",
"filp/whoops": "^2.0",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.3.0",
"phpunit/phpunit": "^9.5.0"
"nunomaduro/collision": "^5.3",
"phpunit/phpunit": "^9.5"
},
"replace": {
"bagisto/laravel-user": "v0.1.0",

193
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a89cde809f8fd811b54a9c0fee47837f",
"content-hash": "9de092b253ba36be14bb379b51782427",
"packages": [
{
"name": "algolia/algoliasearch-client-php",
@ -167,16 +167,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.176.3",
"version": "3.176.4",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "a4f0bbeff965f67ca4dbfccfa2865de611f14c30"
"reference": "7cafb35d3ef9944f542a97dde4a6bb52ad0f45d1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/a4f0bbeff965f67ca4dbfccfa2865de611f14c30",
"reference": "a4f0bbeff965f67ca4dbfccfa2865de611f14c30",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7cafb35d3ef9944f542a97dde4a6bb52ad0f45d1",
"reference": "7cafb35d3ef9944f542a97dde4a6bb52ad0f45d1",
"shasum": ""
},
"require": {
@ -251,9 +251,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.176.3"
"source": "https://github.com/aws/aws-sdk-php/tree/3.176.4"
},
"time": "2021-03-29T18:16:38+00:00"
"time": "2021-03-30T18:17:07+00:00"
},
{
"name": "babenkoivan/elastic-adapter",
@ -851,32 +851,32 @@
},
{
"name": "doctrine/dbal",
"version": "2.12.1",
"version": "2.13.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "adce7a954a1c2f14f85e94aed90c8489af204086"
"reference": "67d56d3203b33db29834e6b2fcdbfdc50535d796"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/adce7a954a1c2f14f85e94aed90c8489af204086",
"reference": "adce7a954a1c2f14f85e94aed90c8489af204086",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/67d56d3203b33db29834e6b2fcdbfdc50535d796",
"reference": "67d56d3203b33db29834e6b2fcdbfdc50535d796",
"shasum": ""
},
"require": {
"doctrine/cache": "^1.0",
"doctrine/deprecations": "^0.5.3",
"doctrine/event-manager": "^1.0",
"ext-pdo": "*",
"php": "^7.3 || ^8"
"php": "^7.1 || ^8"
},
"require-dev": {
"doctrine/coding-standard": "^8.1",
"jetbrains/phpstorm-stubs": "^2019.1",
"phpstan/phpstan": "^0.12.40",
"phpunit/phpunit": "^9.4",
"psalm/plugin-phpunit": "^0.10.0",
"doctrine/coding-standard": "8.2.0",
"jetbrains/phpstorm-stubs": "2020.2",
"phpstan/phpstan": "0.12.81",
"phpunit/phpunit": "^7.5.20|^8.5|9.5.0",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
"vimeo/psalm": "^3.17.2"
"vimeo/psalm": "4.6.4"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@ -885,11 +885,6 @@
"bin/doctrine-dbal"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\DBAL\\": "lib/Doctrine/DBAL"
@ -942,7 +937,7 @@
],
"support": {
"issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/2.12.1"
"source": "https://github.com/doctrine/dbal/tree/2.13.0"
},
"funding": [
{
@ -958,7 +953,50 @@
"type": "tidelift"
}
],
"time": "2020-11-14T20:26:58+00:00"
"time": "2021-03-28T18:10:53+00:00"
},
{
"name": "doctrine/deprecations",
"version": "v0.5.3",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "9504165960a1f83cc1480e2be1dd0a0478561314"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/9504165960a1f83cc1480e2be1dd0a0478561314",
"reference": "9504165960a1f83cc1480e2be1dd0a0478561314",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0",
"psr/log": "^1.0"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v0.5.3"
},
"time": "2021-03-21T12:59:47+00:00"
},
{
"name": "doctrine/event-manager",
@ -1231,35 +1269,33 @@
},
{
"name": "dompdf/dompdf",
"version": "v0.8.6",
"version": "v0.8.3",
"source": {
"type": "git",
"url": "https://github.com/dompdf/dompdf.git",
"reference": "db91d81866c69a42dad1d2926f61515a1e3f42c5"
"reference": "75f13c700009be21a1965dc2c5b68a8708c22ba2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/db91d81866c69a42dad1d2926f61515a1e3f42c5",
"reference": "db91d81866c69a42dad1d2926f61515a1e3f42c5",
"url": "https://api.github.com/repos/dompdf/dompdf/zipball/75f13c700009be21a1965dc2c5b68a8708c22ba2",
"reference": "75f13c700009be21a1965dc2c5b68a8708c22ba2",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-mbstring": "*",
"phenx/php-font-lib": "^0.5.2",
"phenx/php-svg-lib": "^0.3.3",
"php": "^7.1"
"phenx/php-font-lib": "0.5.*",
"phenx/php-svg-lib": "0.3.*",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^7.5",
"squizlabs/php_codesniffer": "^3.5"
"phpunit/phpunit": "^4.8|^5.5|^6.5",
"squizlabs/php_codesniffer": "2.*"
},
"suggest": {
"ext-gd": "Needed to process images",
"ext-gmagick": "Improves image processing performance",
"ext-imagick": "Improves image processing performance",
"ext-zlib": "Needed for pdf stream compression"
"ext-imagick": "Improves image processing performance"
},
"type": "library",
"extra": {
@ -1299,7 +1335,7 @@
"issues": "https://github.com/dompdf/dompdf/issues",
"source": "https://github.com/dompdf/dompdf/tree/master"
},
"time": "2020-08-30T22:54:22+00:00"
"time": "2018-12-14T02:40:31+00:00"
},
{
"name": "dragonmantank/cron-expression",
@ -1772,16 +1808,16 @@
},
{
"name": "facade/ignition",
"version": "2.6.0",
"version": "2.7.0",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "4be10a998815f77952b9eb983fb0b64c8a4defbb"
"reference": "bdc8b0b32c888f6edc838ca641358322b3d9506d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/4be10a998815f77952b9eb983fb0b64c8a4defbb",
"reference": "4be10a998815f77952b9eb983fb0b64c8a4defbb",
"url": "https://api.github.com/repos/facade/ignition/zipball/bdc8b0b32c888f6edc838ca641358322b3d9506d",
"reference": "bdc8b0b32c888f6edc838ca641358322b3d9506d",
"shasum": ""
},
"require": {
@ -1845,7 +1881,7 @@
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2021-03-24T18:58:31+00:00"
"time": "2021-03-30T15:55:38+00:00"
},
{
"name": "facade/ignition-contracts",
@ -2025,16 +2061,16 @@
},
{
"name": "filp/whoops",
"version": "2.11.0",
"version": "2.12.0",
"source": {
"type": "git",
"url": "https://github.com/filp/whoops.git",
"reference": "f6e14679f948d8a5cfb866fa7065a30c66bd64d3"
"reference": "d501fd2658d55491a2295ff600ae5978eaad7403"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filp/whoops/zipball/f6e14679f948d8a5cfb866fa7065a30c66bd64d3",
"reference": "f6e14679f948d8a5cfb866fa7065a30c66bd64d3",
"url": "https://api.github.com/repos/filp/whoops/zipball/d501fd2658d55491a2295ff600ae5978eaad7403",
"reference": "d501fd2658d55491a2295ff600ae5978eaad7403",
"shasum": ""
},
"require": {
@ -2084,7 +2120,7 @@
],
"support": {
"issues": "https://github.com/filp/whoops/issues",
"source": "https://github.com/filp/whoops/tree/2.11.0"
"source": "https://github.com/filp/whoops/tree/2.12.0"
},
"funding": [
{
@ -2092,7 +2128,7 @@
"type": "github"
}
],
"time": "2021-03-19T12:00:00+00:00"
"time": "2021-03-30T12:00:00+00:00"
},
{
"name": "flynsarmy/db-blade-compiler",
@ -2894,16 +2930,16 @@
},
{
"name": "laravel/framework",
"version": "v8.34.0",
"version": "v8.35.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "81892ca110795a9c46c7e198cba7763bfd2af0bf"
"reference": "d118c0df39e7524131176aaf76493eae63a8a602"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/81892ca110795a9c46c7e198cba7763bfd2af0bf",
"reference": "81892ca110795a9c46c7e198cba7763bfd2af0bf",
"url": "https://api.github.com/repos/laravel/framework/zipball/d118c0df39e7524131176aaf76493eae63a8a602",
"reference": "d118c0df39e7524131176aaf76493eae63a8a602",
"shasum": ""
},
"require": {
@ -3058,7 +3094,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-03-23T15:12:51+00:00"
"time": "2021-03-30T21:34:17+00:00"
},
{
"name": "laravel/legacy-factories",
@ -3382,30 +3418,33 @@
},
{
"name": "lcobucci/jwt",
"version": "3.3.3",
"version": "3.2.5",
"source": {
"type": "git",
"url": "https://github.com/lcobucci/jwt.git",
"reference": "c1123697f6a2ec29162b82f170dd4a491f524773"
"reference": "82be04b4753f8b7693b62852b7eab30f97524f9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/c1123697f6a2ec29162b82f170dd4a491f524773",
"reference": "c1123697f6a2ec29162b82f170dd4a491f524773",
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/82be04b4753f8b7693b62852b7eab30f97524f9b",
"reference": "82be04b4753f8b7693b62852b7eab30f97524f9b",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-openssl": "*",
"php": "^5.6 || ^7.0"
"php": ">=5.5"
},
"require-dev": {
"mdanter/ecc": "~0.3.1",
"mikey179/vfsstream": "~1.5",
"phpmd/phpmd": "~2.2",
"phpunit/php-invoker": "~1.1",
"phpunit/phpunit": "^5.7 || ^7.3",
"phpunit/phpunit": "~4.5",
"squizlabs/php_codesniffer": "~2.3"
},
"suggest": {
"mdanter/ecc": "Required to use Elliptic Curves based algorithms."
},
"type": "library",
"extra": {
"branch-alias": {
@ -3435,19 +3474,9 @@
],
"support": {
"issues": "https://github.com/lcobucci/jwt/issues",
"source": "https://github.com/lcobucci/jwt/tree/3.3.3"
"source": "https://github.com/lcobucci/jwt/tree/3.2"
},
"funding": [
{
"url": "https://github.com/lcobucci",
"type": "github"
},
{
"url": "https://www.patreon.com/lcobucci",
"type": "patreon"
}
],
"time": "2020-08-20T13:22:28+00:00"
"time": "2018-11-11T12:22:26+00:00"
},
{
"name": "league/commonmark",
@ -8322,16 +8351,16 @@
},
{
"name": "tymon/jwt-auth",
"version": "1.0.2",
"version": "dev-develop",
"source": {
"type": "git",
"url": "https://github.com/tymondesigns/jwt-auth.git",
"reference": "e588cb719539366c0e2f6017f975379cb73e9680"
"reference": "ab00f2d7cce5f043067aef7849cdc792de2df635"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/e588cb719539366c0e2f6017f975379cb73e9680",
"reference": "e588cb719539366c0e2f6017f975379cb73e9680",
"url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/ab00f2d7cce5f043067aef7849cdc792de2df635",
"reference": "ab00f2d7cce5f043067aef7849cdc792de2df635",
"shasum": ""
},
"require": {
@ -8342,15 +8371,17 @@
"lcobucci/jwt": "<3.4",
"namshi/jose": "^7.0",
"nesbot/carbon": "^1.0|^2.0",
"php": "^5.5.9|^7.0"
"php": "^7.2|^8.0"
},
"require-dev": {
"illuminate/console": "^5.2|^6|^7|^8",
"illuminate/database": "^5.2|^6|^7|^8",
"illuminate/routing": "^5.2|^6|^7|^8",
"mockery/mockery": ">=0.9.9",
"phpunit/phpunit": "~4.8|~6.0"
"phpunit/phpunit": "^8.5|^9.4",
"yoast/phpunit-polyfills": "^0.2.0"
},
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
@ -8402,7 +8433,7 @@
"type": "patreon"
}
],
"time": "2020-11-27T12:32:42+00:00"
"time": "2021-02-02T14:44:28+00:00"
},
{
"name": "vlucas/phpdotenv",
@ -11599,7 +11630,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^7.3"
"php": "^7.3|^8.0"
},
"platform-dev": [],
"plugin-api-version": "2.0.0"

View File

@ -0,0 +1,106 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
class TransactionController extends Controller
{
/**
* Contains current guard.
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration.
*
* @var array
*/
protected $_config;
/**
* Repository object.
*
* @var \Webkul\Core\Eloquent\Repository
*/
protected $repository;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->guard = request()->has('token') ? 'api' : 'customer';
$this->_config = request('_config');
if (isset($this->_config['authorization_required']) && $this->_config['authorization_required']) {
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard);
}
if ($this->_config) {
$this->repository = app($this->_config['repository']);
}
}
/**
* Returns a listing of the Order Transactions.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$query = $this->repository->scopeQuery(function($query) {
$query = $query->leftJoin('orders', 'order_transactions.order_id', '=', 'orders.id')->select('order_transactions.*', 'orders.customer_id');
if (isset($this->_config['authorization_required']) && $this->_config['authorization_required']) {
$query = $query->where('customer_id', auth()->user()->id);
}
foreach (request()->except(['page', 'limit', 'pagination', 'sort', 'order', 'token']) as $input => $value) {
$query = $query->whereIn($input, array_map('trim', explode(',', $value)));
}
if ($sort = request()->input('sort')) {
$query = $query->orderBy($sort, request()->input('order') ?? 'desc');
} else {
$query = $query->orderBy('id', 'desc');
}
return $query;
});
if (is_null(request()->input('pagination')) || request()->input('pagination')) {
$results = $query->paginate(request()->input('limit') ?? 10);
} else {
$results = $query->get();
}
return $this->_config['resource']::collection($results);
}
/**
* Returns an individual invoice.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function get($id)
{
if (isset($this->_config['authorization_required']) && $this->_config['authorization_required']) {
$query = $this->repository->leftJoin('orders', 'order_transactions.order_id', '=', 'orders.id')
->select('order_transactions.*', 'orders.customer_id')
->where('customer_id', auth()->user()->id)
->findOrFail($id);
} else {
$query = $this->repository->findOrFail($id);
}
return new $this->_config['resource']($query);
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderTransaction extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'transaction_id' => $this->transaction_id,
'status' => $this->status,
'type' => $this->type,
'payment_method' => $this->payment_method,
'data' => $this->data,
'updated_at' => $this->updated_at,
'created_at' => $this->created_at,
];
}
}

View File

@ -215,7 +215,7 @@ Route::group(['prefix' => 'api'], function ($router) {
]);
//Invoice routes
//Shipment routes
Route::get('shipments', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\ShipmentRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Shipment',
@ -228,6 +228,18 @@ Route::group(['prefix' => 'api'], function ($router) {
'authorization_required' => true
]);
//Transaction routes
Route::get('transactions', 'TransactionController@index')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\OrderTransactionRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\OrderTransaction',
'authorization_required' => true
]);
Route::get('transactions/{id}', 'TransactionController@get')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\OrderTransactionRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\OrderTransaction',
'authorization_required' => true
]);
//Wishlist routes
Route::get('wishlist', 'ResourceController@index')->defaults('_config', [

View File

@ -515,7 +515,7 @@
});
if (matchedAttribute[0]['type'] == 'multiselect' || matchedAttribute[0]['type'] == 'checkbox') {
this.condition.operator = '{}';
// this.condition.operator = '{}';
this.condition.value = this.condition.value == '' && this.condition.value != undefined
? []

View File

@ -1,14 +1,14 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Webkul\Sales\Models\Invoice;
use Webkul\Sales\Models\Shipment;
use Illuminate\Support\Facades\DB;
use Webkul\Sales\Models\OrderAddress;
use Illuminate\Support\Facades\Schema;
use Webkul\Checkout\Models\CartAddress;
use Illuminate\Database\Schema\Blueprint;
use Webkul\Checkout\Models\CartShippingRate;
use Webkul\Sales\Models\Invoice;
use Webkul\Sales\Models\OrderAddress;
use Webkul\Sales\Models\Shipment;
use Illuminate\Database\Migrations\Migration;
class AddTableAddresses extends Migration
{
@ -20,9 +20,6 @@ class AddTableAddresses extends Migration
public function up()
{
try {
// transaction is important to prevent loosing data on failure
DB::beginTransaction();
Schema::create('addresses', function (Blueprint $table) {
$table->increments('id');
$table->string('address_type');
@ -70,10 +67,7 @@ class AddTableAddresses extends Migration
Schema::drop('order_address');
Schema::enableForeignKeyConstraints();
DB::commit();
} catch (Exception $e) {
DB::rollBack();
throw $e;
}
}
@ -85,7 +79,7 @@ class AddTableAddresses extends Migration
*/
public function down()
{
throw new Exception('you cannot revert this migration: data would be lost');
throw new Exception('You cannot revert this migration. Data would be lost.');
}
private function migrateCustomerAddresses(): void

3
storage/app/public/.gitignore vendored Executable file
View File

@ -0,0 +1,3 @@
*
!public/
!.gitignore