Merge branch 'dev' into sarga-v1

This commit is contained in:
merdan 2022-02-05 14:28:26 +05:00
commit 6b4d3d6466
785 changed files with 37937 additions and 33171 deletions

70
.env.example Normal file
View File

@ -0,0 +1,70 @@
APP_NAME=Bagisto
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_ADMIN_URL=admin
APP_TIMEZONE=Asia/Kolkata
APP_LOCALE=en
LOG_CHANNEL=stack
APP_CURRENCY=USD
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_PREFIX=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
SHOP_MAIL_FROM=
ADMIN_MAIL_TO=
MAIL_FROM_NAME=
FIXER_API_KEY=
EXCHANGE_RATES_API_KEY=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_CALLBACK_URL=https://yourhost.com/customer/social-login/facebook/callback
TWITTER_CLIENT_ID=
TWITTER_CLIENT_SECRET=
TWITTER_CALLBACK_URL=https://yourhost.com/customer/social-login/twitter/callback
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_CALLBACK_URL=https://yourhost.com/customer/social-login/google/callback
LINKEDIN_CLIENT_ID=
LINKEDIN_CLIENT_SECRET=
LINKEDIN_CALLBACK_URL=https://yourhost.com/customer/social-login/linkedin/callback
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=https://yourhost.com/customer/social-login/github/callback

View File

@ -1,46 +0,0 @@
APP_NAME=Laravel
APP_ENV=local
APP_VERSION=1.3.3
APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE=
APP_DEBUG=true
APP_URL=http://localhost
APP_ADMIN_URL=admin
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=bagisto_testing
DB_USERNAME=bagisto
DB_PASSWORD=secret
DB_PREFIX=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
SHOP_MAIL_FROM=test@example.com
ADMIN_MAIL_TO=test@example.com

View File

@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.3', '7.4', '8.0']
php-versions: ['7.4', '8.0', '8.1']
name: PHP ${{ matrix.php-versions }} test on ${{ matrix.operating-system }}
services:
@ -33,19 +33,32 @@ jobs:
php-version: ${{ matrix.php-versions }}
extensions: curl, gd, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer, zip
- name: Set Environment
run: |
set -e
sed -i "s|^\(DB_HOST=\s*\).*$|\1127.0.0.1|" .env.testing
sed -i "s|^\(DB_PORT=\s*\).*$|\1${{ job.services.mysql.ports['3306'] }}|" .env.testing
printf "the complete .env.testing ...\n\n"
cat .env.testing
- name: Composer Install
run: |
set -e
composer install --no-cache
- name: Set Testing Environment
run: |
cp .env.example .env.testing
set -e
sed -i "s|^\(DB_HOST=\s*\).*$|\1127.0.0.1|" .env.testing
sed -i "s|^\(DB_PORT=\s*\).*$|\1${{ job.services.mysql.ports['3306'] }}|" .env.testing
sed -i "s|^\(DB_DATABASE=\s*\).*$|\1bagisto_testing|" .env.testing
sed -i "s|^\(DB_USERNAME=\s*\).*$|\1bagisto|" .env.testing
sed -i "s|^\(DB_PASSWORD=\s*\).*$|\1secret|" .env.testing
- name: Key Generate
run: set -e && php artisan key:generate --env=testing
- name: Comlplete Testing Env File
run: |
printf "The complete `.env.testing` ... \n\n"
cat .env.testing
- name: Optimize Stuffs
run: set -e && php artisan optimize:clear --env=testing
- name: Migrate Database
run: set -e && php artisan migrate --env=testing
@ -55,9 +68,6 @@ jobs:
- name: Vendor Publish
run: set -e && php artisan vendor:publish --all --force --env=testing
- name: Optimize Stuffs
run: set -e && php artisan optimize --env=testing
- name: Execute Unit Tests
run: set -e && vendor/bin/codecept run unit
@ -67,6 +77,9 @@ jobs:
- name: Execute Trigger Tests
run: set -e && vendor/bin/codecept run trigger
- name: Execute API Tests
run: set -e && vendor/bin/codecept run api
- name: Persist Test Artifacts
uses: actions/upload-artifact@v1
if: always()

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.env
.env.testing
.idea
.php_cs.cache
.vscode

138
README.md
View File

@ -1,20 +1,66 @@
<h1 align="center">
Sarga
</h1>
<p align="center">
<a href="http://www.bagisto.com"><img src="https://bagisto.com/wp-content/themes/bagisto/images/logo.png" alt="Total Downloads"></a>
</p>
<p align="center">
<a href="https://packagist.org/packages/bagisto/bagisto"><img src="https://poser.pugx.org/bagisto/bagisto/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/bagisto/bagisto"><img src="https://poser.pugx.org/bagisto/bagisto/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/bagisto/bagisto"><img src="https://poser.pugx.org/bagisto/bagisto/license.svg" alt="License"></a>
<a href="https://github.com/bagisto/bagisto/actions"><img src="https://github.com/bagisto/bagisto/workflows/CI/badge.svg" alt="Backers on Open Collective"></a>
<a href="#backers"><img src="https://opencollective.com/bagisto/backers/badge.svg" alt="Backers on Open Collective"></a>
<a href="#sponsors"><img src="https://opencollective.com/bagisto/sponsors/badge.svg" alt="Sponsors on Open Collective"></a>
</p>
<p align="center">
<a href="https://twitter.com/intent/follow?screen_name=bagistoshop"><img src="https://img.shields.io/twitter/follow/bagistoshop?style=social"></a>
<a href="https://www.youtube.com/channel/UCbrfqnhyiDv-bb9QuZtonYQ"><img src="https://img.shields.io/youtube/channel/subscribers/UCbrfqnhyiDv-bb9QuZtonYQ?style=social"></a>
</p>
<p align="center">
➡️ <a href="https://bagisto.com/en/">Website</a> | <a href="https://devdocs.bagisto.com/">Documentation</a> | <a href="https://webkul.com/blog/laravel-ecommerce-website/">Installation Guide</a> | <a href="https://forums.bagisto.com/">Forums</a> | <a href="https://www.facebook.com/groups/bagisto/">Community</a> ⬅️
</p>
<p align="center" style="display: inline;">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/ar.svg" alt="Arabic" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/de.svg" alt="German" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/us.svg" alt="English" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/es.svg" alt="Spanish" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/ir.svg" alt="Persian" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/it.svg" alt="Italian" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/nl.svg" alt="Dutch" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/pl.svg" alt="Polish" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/pt.svg" alt="Portuguese" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/tr.svg" alt="Turkish" width="24" height="24">
<img class="flag-img" src="https://flagicons.lipis.dev/flags/4x3/eg.svg" alt="Egyptian" width="24" height="24">
</p>
## Topics
1. [Introduction](#introduction)
2. [Documentation](#documentation)
3. [Requirements](#requirements)
4. [Installation & Configuration](#installation-and-configuration)
5. [License](#license)
6. [Security Vulnerabilities](#security-vulnerabilities)
7. [Modules](#modules)
8. [Miscellaneous](#miscellaneous)
### Introduction
[Sarga](https://www.sarga.com.tr) is a hand-tailored E-Commerce framework built on some of the hottest opensource technologies
An easy to use, free and opensource laravel ecommerce platform to build your online shop in no time.
[Bagisto](https://www.bagisto.com) is a hand-tailored E-Commerce framework built on some of the hottest opensource technologies
such as [Laravel](https://laravel.com) (a [PHP](https://secure.php.net/) framework) and [Vue.js](https://vuejs.org)
a progressive Javascript framework.
**Sarga can help you cut down your time, cost, and workforce for building online stores or migrating from physical stores
**Bagisto can help you cut down your time, cost, and workforce for building online stores or migrating from physical stores
to the ever-demanding online world. Your business -- whether small or huge -- can benefit. And it's straightforward to set it up.**
**Read our documentation: [Sarga Docs](https://devdocs.bagisto.com/)**
**Read our documentation: [Bagisto Docs](https://devdocs.bagisto.com/)**
**We also have a forum for any concerns, feature requests, or discussions. Please visit: [Bagisto Forums](https://forums.bagisto.com/)**
# Visit our live [Demo](https://demo.bagisto.com)
It packs in lots of features that will allow your E-Commerce business to scale in no time:
@ -33,17 +79,50 @@ It packs in lots of features that will allow your E-Commerce business to scale i
* Price rules (Discount) inbuilt.
* Theme (Velocity).
* CMS Pages.
* Check out [these features and more](https://bagisto.com/features/).
**For Developers**:
Take advantage of two of the hottest frameworks used in this project -- Laravel and Vue.js -- both have been used in Bagisto.
### Documentation
#### Bagisto Documentation [https://devdocs.bagisto.com](https://devdocs.bagisto.com)
### Requirements
* **SERVER**: Apache 2 or NGINX.
* **RAM**: 3 GB or higher.
* **PHP**: 7.3 or higher.
* **PHP**: 7.4 or higher.
* **For MySQL users**: 5.7.23 or higher.
* **For MariaDB users**: 10.2.7 or Higher.
* **Node**: 8.11.3 LTS or higher.
* **Composer**: 1.6.5 or higher.
### Installation and Configuration
**1. You can install Bagisto by using the GUI installer.**
##### a. Download zip from the link below:
[Download the latest release](https://github.com/bagisto/bagisto/releases/latest)
##### b. Extract the contents of the zip and execute the project in your browser:
~~~
http(s)://example.com
~~~
**2. Or you can install Bagisto from your console.**
##### Execute these commands below, in order
~~~
1. composer create-project bagisto/bagisto
~~~
~~~
2. php artisan bagisto:install
~~~
**To execute Bagisto**:
@ -61,7 +140,7 @@ If not done, open the specified entry point in your host's file in your browser
##### On local:
~~~
PHP artisan serve
php artisan serve
~~~
@ -87,3 +166,46 @@ Bagisto is a truly open-source E-Commerce framework that will always be free und
### Security Vulnerabilities
Would you please not disclose security vulnerabilities publicly? If you find any security vulnerability in Bagisto, then please email us: mailto:support@bagisto.com.
### Modules
[Available Modules](https://bagisto.com/en/extensions)
Need something else? Please email us at support@bagisto.com.
### Miscellaneous
#### Contribute
Bagisto is a community-driven project; we appreciate every contribution from the community.
- If you found an issue that you think we should know about, or if you have a suggestion, please submit an issue.
- If you want to submit a solution or offer a new feature, please create a pull request.
Please read our [contributing guide](https://github.com/bagisto/bagisto/blob/master/.github/CONTRIBUTING.md) for more info.
#### Contributors
This project is on [Open Collective](https://opencollective.com/bagisto), and it exists thanks to the people who contribute.
<a href="https://github.com/bagisto/bagisto/graphs/contributors"><img src="https://opencollective.com/bagisto/contributors.svg?width=890&button=false"/></a>
#### Backers
Thank you to all our backers! 🙏
<a href="https://opencollective.com/bagisto#contributors" target="_blank"><img src="https://opencollective.com/bagisto/backers.svg?width=890"></a>
#### Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
<div>
<a href="https://opencollective.com/bagisto/contribute/sponsor-7372/checkout" target="_blank">
<img src="https://images.opencollective.com/static/images/become_sponsor.svg">
</a>
</div>
<kbd>
<a href="http://e.ventures/" target="_blank">
<img src="https://images.opencollective.com/e-ventures1/7d61db2/logo.png" height="75">
</a>
</kbd>

View File

@ -35,6 +35,7 @@ class Kernel extends HttpKernel
],
'api' => [
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:60,1',
'bindings',
],

View File

@ -11,7 +11,5 @@ class VerifyCsrfToken extends Middleware
*
* @var array
*/
protected $except = [
'paypal/standard/ipn'
];
protected $except = [];
}

View File

@ -8,12 +8,11 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^7.3|^8.0",
"algolia/algoliasearch-client-php": "^2.2",
"php": "^7.4|^8.0",
"astrotomic/laravel-translatable": "^11.0.0",
"babenkoivan/elastic-scout-driver": "^1.1",
"bagisto/laravel-datafaker": "dev-master",
"aws/aws-sdk-php": "^3.171",
"bagisto/legacy-api": "^1.0",
"bagisto/rest-api": "dev-master",
"bagistobrasil/bagisto-product-social-share": "^0.1.2",
"barryvdh/laravel-debugbar": "^3.1",
"barryvdh/laravel-dompdf": "^0.8.5|^0.9.0",
@ -27,11 +26,11 @@
"guzzlehttp/guzzle": "^7.0.1",
"intervention/image": "^2.4",
"intervention/imagecache": "^2.3",
"kalnoy/nestedset": "^5.0",
"kalnoy/nestedset": "^6.0",
"khaled.alshamaa/ar-php": "^6.0.0",
"konekt/concord": "^1.2",
"laravel/framework": "^8.0",
"laravel/legacy-factories": "^1.1",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.12",
"laravel/scout": "^8.0",
"laravel/socialite": "^5.0",
"laravel/tinker": "^2.0",
@ -39,13 +38,14 @@
"maatwebsite/excel": "^3.1.26",
"prettus/l5-repository": "^2.6",
"tymon/jwt-auth": "1.0.x-dev"
"pusher/pusher-php-server": "^7.0"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.1",
"codeception/module-filesystem": "^1.0",
"codeception/module-laravel": "^2.0",
"codeception/module-rest": "^1.4",
"codeception/module-webdriver": "^1.0",
"filp/whoops": "^2.0",
"mockery/mockery": "^1.3.1",
@ -95,7 +95,6 @@
"Webkul\\Paypal\\": "packages/Webkul/Paypal/src",
"Webkul\\Sales\\": "packages/Webkul/Sales/src",
"Webkul\\Tax\\": "packages/Webkul/Tax/src",
"Webkul\\API\\": "packages/Webkul/API",
"Webkul\\CatalogRule\\": "packages/Webkul/CatalogRule/src",
"Webkul\\CartRule\\": "packages/Webkul/CartRule/src",
"Webkul\\Rule\\": "packages/Webkul/Rule/src",
@ -105,6 +104,7 @@
"Webkul\\SocialLogin\\": "packages/Webkul/SocialLogin/src",
"Webkul\\DebugBar\\": "packages/Webkul/DebugBar/src",
"Webkul\\Marketing\\": "packages/Webkul/Marketing/src",
"Webkul\\Notification\\": "packages/Webkul/Notification/src",
"Webkul\\Marketplace\\": "packages/Webkul/Marketplace/src",
"Sarga\\Shop\\": "packages/Sarga/Shop/src",
"Sarga\\API\\": "packages/Sarga/API",
@ -114,10 +114,10 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\Acceptance\\": "tests/acceptance/",
"Tests\\API\\": "tests/api/",
"Tests\\Functional\\": "tests/functional/",
"Tests\\Unit\\": "tests/unit/",
"Tests\\Trigger\\": "tests/trigger/"
"Tests\\Trigger\\": "tests/trigger/",
"Tests\\Unit\\": "tests/unit/"
}
},
"extra": {

2790
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -157,16 +157,11 @@ return [
'cipher' => 'AES-256-CBC',
/*
Code Editor
/**
* Code editor.
*/
'editor' => 'vscode',
/*
Application Version
*/
'version' => env('APP_VERSION'),
/**
* Blacklisting attributes while debugging
*/
@ -200,7 +195,7 @@ return [
'providers' => [
/*
* Laravel Framework Service Providers...
* Laravel Framework Service Providers.
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
@ -226,13 +221,15 @@ return [
Illuminate\View\ViewServiceProvider::class,
/*
* Package Service Providers...
* Package Service Providers.
*/
Astrotomic\Translatable\TranslatableServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
/*
* Application Service Providers...
* Application Service Providers.
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
@ -240,20 +237,17 @@ return [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
//Laravel Intervention
Intervention\Image\ImageServiceProvider::class,
//Laravel Maatwebsite
Maatwebsite\Excel\ExcelServiceProvider::class,
//Repository
/**
* Repository Service Providers.
*/
Prettus\Repository\Providers\RepositoryServiceProvider::class,
Konekt\Concord\ConcordServiceProvider::class,
Flynsarmy\DbBladeCompiler\DbBladeCompilerServiceProvider::class,
Barryvdh\DomPDF\ServiceProvider::class,
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
//Webkul packages
/**
* Webkul Package Service Providers.
*/
Webkul\Theme\Providers\ThemeServiceProvider::class,
Webkul\User\Providers\UserServiceProvider::class,
Webkul\Admin\Providers\AdminServiceProvider::class,
@ -272,16 +266,16 @@ return [
// Webkul\Paypal\Providers\PaypalServiceProvider::class,
Webkul\Sales\Providers\SalesServiceProvider::class,
Webkul\Tax\Providers\TaxServiceProvider::class,
Webkul\API\Providers\APIServiceProvider::class,
Webkul\CatalogRule\Providers\CatalogRuleServiceProvider::class,
Webkul\CartRule\Providers\CartRuleServiceProvider::class,
Webkul\Rule\Providers\RuleServiceProvider::class,
// Webkul\CMS\Providers\CMSServiceProvider::class,
// Webkul\Velocity\Providers\VelocityServiceProvider::class,
// Webkul\BookingProduct\Providers\BookingProductServiceProvider::class,
Webkul\CMS\Providers\CMSServiceProvider::class,
Webkul\Velocity\Providers\VelocityServiceProvider::class,
Webkul\BookingProduct\Providers\BookingProductServiceProvider::class,
Webkul\SocialLogin\Providers\SocialLoginServiceProvider::class,
Webkul\DebugBar\Providers\DebugBarServiceProvider::class,
Webkul\Marketing\Providers\MarketingServiceProvider::class,
Webkul\Notification\Providers\NotificationServiceProvider::class,
Webkul\Marketplace\Providers\MarketplaceServiceProvider::class,
Sarga\Shop\Providers\ShopServiceProvider::class,

View File

@ -2,12 +2,17 @@
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'admins',
'guard' => 'customer',
'passwords' => 'customers',
],
'guards' => [
'web' => [
'customer' => [
'driver' => 'session',
'provider' => 'customers',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
@ -17,20 +22,10 @@ return [
'provider' => 'customers',
],
'customer' => [
'driver' => 'session',
'provider' => 'customers'
],
'admin' => [
'driver' => 'session',
'provider' => 'admins'
],
'admin-api' => [
'driver' => 'jwt',
'provider' => 'admins',
]
],
],
'providers' => [
@ -42,21 +37,22 @@ return [
'admins' => [
'driver' => 'eloquent',
'model' => Webkul\User\Models\Admin::class,
]
],
],
'passwords' => [
'admins' => [
'provider' => 'admins',
'table' => 'admin_password_resets',
'expire' => 60,
'throttle' => 60,
],
'customers' => [
'provider' => 'customers',
'table' => 'customer_password_resets',
'expire' => 60,
'throttle' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'admin_password_resets',
'expire' => 60,
'throttle' => 60,
],
],
];

View File

@ -5,6 +5,7 @@ return [
'convention' => Webkul\Core\CoreConvention::class,
'modules' => [
/**
* Example:
* VendorA\ModuleX\Providers\ModuleServiceProvider::class,
@ -13,7 +14,6 @@ return [
*/
\Webkul\Admin\Providers\ModuleServiceProvider::class,
\Webkul\API\Providers\ModuleServiceProvider::class,
\Webkul\Attribute\Providers\ModuleServiceProvider::class,
\Webkul\BookingProduct\Providers\ModuleServiceProvider::class,
\Webkul\CartRule\Providers\ModuleServiceProvider::class,
@ -38,5 +38,6 @@ return [
\Webkul\Ui\Providers\ModuleServiceProvider::class,
\Webkul\User\Providers\ModuleServiceProvider::class,
\Webkul\Velocity\Providers\ModuleServiceProvider::class,
]
],
];

View File

@ -1,7 +1,5 @@
<?php
use Illuminate\Support\Str;
return [
/*
@ -38,7 +36,7 @@ return [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => env('DB_PREFIX'),
'prefix' => env('DB_PREFIX', ''),
],
'mysql' => [
@ -51,7 +49,7 @@ return [
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => env('DB_PREFIX'),
'prefix' => env('DB_PREFIX', ''),
'strict' => false,
'engine' => 'InnoDB ROW_FORMAT=DYNAMIC',
],

65
config/sanctum.php Normal file
View File

@ -0,0 +1,65 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Stateful Domains
|--------------------------------------------------------------------------
|
| Requests from the following domains / hosts will receive stateful API
| authentication cookies. Typically, these should include your local
| and production domains which access your API via a frontend SPA.
|
*/
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
))),
/*
|--------------------------------------------------------------------------
| Sanctum Guards
|--------------------------------------------------------------------------
|
| This array contains the authentication guards that will be checked when
| Sanctum is trying to authenticate a request. If none of these guards
| are able to authenticate the request, Sanctum will use the bearer
| token that's present on an incoming request for authentication.
|
*/
'guard' => ['customer'],
/*
|--------------------------------------------------------------------------
| Expiration Minutes
|--------------------------------------------------------------------------
|
| This value controls the number of minutes until an issued token will be
| considered expired. If this value is null, personal access tokens do
| not expire. This won't tweak the lifetime of first-party sessions.
|
*/
'expiration' => null,
/*
|--------------------------------------------------------------------------
| Sanctum Middleware
|--------------------------------------------------------------------------
|
| When authenticating your first-party SPA with Sanctum you may need to
| customize some of the middleware Sanctum uses while processing the
| request. You may change the middleware listed below as required.
|
*/
'middleware' => [
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
],
];

View File

@ -41,7 +41,20 @@ return [
|
*/
'queue' => env('SCOUT_QUEUE', true),
'queue' => env('SCOUT_QUEUE', false),
/*
|--------------------------------------------------------------------------
| Database Transactions
|--------------------------------------------------------------------------
|
| This configuration option determines if your data will only be synced
| with your search indexes after every open database transaction has
| been committed, thus preventing any discarded data from syncing.
|
*/
'after_commit' => false,
/*
|--------------------------------------------------------------------------
@ -72,6 +85,21 @@ return [
'soft_delete' => false,
/*
|--------------------------------------------------------------------------
| Identify User
|--------------------------------------------------------------------------
|
| This option allows you to control whether to notify the search engine
| of the user performing the search. This is sometimes useful if the
| engine supports any analytics based on this application's users.
|
| Supported engines: "algolia"
|
*/
'identify' => env('SCOUT_IDENTIFY', false),
/*
|--------------------------------------------------------------------------
| Algolia Configuration

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePersonalAccessTokensTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->bigIncrements('id');
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('personal_access_tokens');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class Notifications extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->increments('id');
$table->string('type');
$table->boolean('read')->default(0);
$table->integer('order_id')->unsigned();
$table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace Sarga\API\Http\Controllers;
use Sarga\API\Http\Requests\AddressRequest;
use Webkul\RestApi\Http\Controllers\V1\Shop\Customer\AddressController;
use Webkul\RestApi\Http\Resources\V1\Shop\Customer\CustomerAddressResource;
class Addresses extends AddressController
{
/**
* Store address.
*
* @param \Webkul\Customer\Http\Requests\CustomerAddressRequest $request
* @return \Illuminate\Http\JsonResponse
*/
public function create(AddressRequest $request)
{
$data = $request->all();
$data['address1'] = implode(PHP_EOL, array_filter($data['address1']));
$data['customer_id'] = $request->user()->id;
$data['country'] = 'Turkmenistan';
$data['postcode'] = '0000';
$customerAddress = $this->customerAddressRepository->create($data);
return response([
'data' => new CustomerAddressResource($customerAddress),
'message' => 'Your address has been created successfully.',
]);
}
}

View File

@ -73,7 +73,11 @@ class Products extends ProductController
$distinctVariants = $variants->unique($attribute->code);
$gr_data = array('attribute' => SuperAttribute::make($attribute),'options' =>[]);
$gr_data = array(
'attribute' => SuperAttribute::make($attribute),
'options' =>[],
'level' => $product->super_attributes->count()
);
foreach($distinctVariants as $variant)
{

View File

@ -1,6 +1,7 @@
<?php
use Illuminate\Support\Facades\Route;
use Sarga\API\Http\Controllers\Addresses;
use Sarga\API\Http\Controllers\Customers;
use Sarga\API\Http\Controllers\Categories;
use Sarga\API\Http\Controllers\Channels;
@ -14,8 +15,8 @@ use Sarga\API\Http\Resources\Catalog\AttributeOption;
use Sarga\API\Http\Resources\Catalog\Category;
use Webkul\Core\Repositories\CountryStateRepository;
Route::group(['prefix' => 'api'], function ($router) {
Route::group(['middleware' => ['locale', 'currency']], function ($router) {
Route::group(['prefix' => 'api'], function () {
Route::group(['middleware' => ['locale', 'currency']], function () {
//Channel routes
Route::get('channels',[Channels::class, 'index']);
@ -24,16 +25,15 @@ Route::group(['prefix' => 'api'], function ($router) {
Route::get('vendor/products/{vendor_id}',[Vendors::class,'products'])->name('api.vendor.products');
Route::get('vendor/brands/{vendor_id}',[Vendors::class,'brands'])->name('api.vendor.brands');
//category routes
Route::get('descendant-categories', [Categories::class, 'index'])->name('api.descendant-categories');
Route::get('category-details/{id}', [Categories::class, 'details']);
Route::get('categories', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => CategoryRepository::class,
'resource' => Category::class,
])->name('api.categories');
Route::get('categories/{id}/filters',[Categories::class,'filters']);
//attributes by code
Route::get('attribute-options', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => AttributeOptionRepository::class,
@ -42,7 +42,6 @@ Route::group(['prefix' => 'api'], function ($router) {
//Product routes
Route::get('products', [Products::class, 'index']);
Route::get('products/{id}', [Products::class, 'get']);
Route::get('products/{id}/variants', [Products::class, 'variants']);
@ -52,16 +51,27 @@ Route::group(['prefix' => 'api'], function ($router) {
]);
});
Route::group(['prefix' => 'scrap','middleware' =>['scrap']], function ($router){
//scrap
Route::group(['prefix' => 'scrap','middleware' =>['scrap']], function (){
Route::put('upload',[IntegrationController::class,'bulk_upload']);
Route::put('create',[IntegrationController::class,'create']);
});
Route::group(['prefix' => 'customer'],function ($router){
//customer
Route::group(['prefix' => 'customer'],function (){
Route::post('register', [Customers::class, 'register']);
Route::post('login', [Customers::class, 'login']);
Route::put('profile', [Customers::class, 'store']);
Route::group(['middleware' => ['auth:sanctum', 'sanctum.customer']], function () {
Route::put('profile', [Customers::class, 'update']);
/**
* Customer address routes.
*/
Route::get('addresses', [Addresses::class, 'index']);
Route::post('addresses', [Addresses::class, 'create']);
Route::get('addresses/{id}', [Addresses::class, 'show']);
Route::put('addresses/{id}', [Addresses::class, 'update']);
Route::delete('addresses/{id}', [Addresses::class, 'destroy']);
});
});
});

View File

@ -1,145 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\API\Http\Resources\Customer\CustomerAddress as CustomerAddressResource;
class AddressController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* CustomerAddressRepository object
*
* @var \Webkul\Customer\Repositories\CustomerAddressRepository
*/
protected $customerAddressRepository;
/**
* Controller instance
*
* @param CustomerAddressRepository $customerAddressRepository
*/
public function __construct(CustomerAddressRepository $customerAddressRepository)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard);
$this->_config = request('_config');
$this->customerAddressRepository = $customerAddressRepository;
}
/**
* Get user address.
*
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function get()
{
$customer = auth($this->guard)->user();
$addresses = $customer->addresses()->get();
return CustomerAddressResource::collection($addresses);
}
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function store()
{
$customer = auth($this->guard)->user();
if (request()->input('address1') && ! is_array(request()->input('address1'))) {
return response()->json([
'message' => 'address1 must be an array.',
]);
}
if (request()->input('address1')) {
request()->merge([
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
'customer_id' => $customer->id,
'country' => 'Turkmenistan',
'postcode' => '0000'
]);
}
$this->validate(request(), [
'address1' => 'string|required',
'company' => 'string|nullable',
'vat_id' => 'string|nullable',
// 'country' => 'string|required',
'state' => 'string|nullable',
'city' => 'string|required',
// 'postcode' => 'required',
'phone' => 'required',
]);
$customerAddress = $this->customerAddressRepository->create(request()->all());
return response()->json([
'message' => 'Your address has been created successfully.',
'data' => new CustomerAddressResource($customerAddress),
]);
}
/**
* Update the specified resource in storage.
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function update(int $id)
{
if (request()->input('address1') && ! is_array(request()->input('address1'))) {
return response()->json([
'message' => 'address1 must be an array.',
]);
}
request()->merge(['address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
'country' => 'Turkmenistan',
'postcode' => '0000'
]);
$this->validate(request(), [
'address1' => 'string|required',
'company' => 'string|nullable',
'vat_id' => 'string|nullable',
// 'country' => 'string|required',
'state' => 'string|nullable',
'city' => 'string|required',
// 'postcode' => 'required',
'phone' => 'required',
]);
$customerAddress = $this->customerAddressRepository->update(request()->all(), $id);
return response()->json([
'message' => 'Your address has been updated successfully.',
'data' => new CustomerAddressResource($customerAddress),
]);
}
}

View File

@ -1,304 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Cart;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Event;
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Checkout\Repositories\CartItemRepository;
use Webkul\Customer\Repositories\WishlistRepository;
use Webkul\API\Http\Resources\Checkout\Cart as CartResource;
class CartController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* CartRepository object
*
* @var \Webkul\Checkout\Repositories\CartRepository
*/
protected $cartRepository;
/**
* CartItemRepository object
*
* @var \Webkul\Checkout\Repositories\CartItemRepository
*/
protected $cartItemRepository;
/**
* WishlistRepository object
*
* @var \Webkul\Checkout\Repositories\WishlistRepository
*/
protected $wishlistRepository;
/**
* Controller instance
*
* @param \Webkul\Checkout\Repositories\CartRepository $cartRepository
* @param \Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
* @param \Webkul\Checkout\Repositories\WishlistRepository $wishlistRepository
*/
public function __construct(
CartRepository $cartRepository,
CartItemRepository $cartItemRepository,
WishlistRepository $wishlistRepository
) {
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
// $this->middleware('auth:' . $this->guard);
$this->_config = request('_config');
$this->cartRepository = $cartRepository;
$this->cartItemRepository = $cartItemRepository;
$this->wishlistRepository = $wishlistRepository;
}
/**
* Get customer cart.
*
* @return \Illuminate\Http\JsonResponse
*/
public function get()
{
$customer = auth($this->guard)->user();
$cart = Cart::getCart();
return response()->json([
'data' => $cart ? new CartResource($cart) : null,
]);
}
/**
* Store a newly created resource in storage.
*
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
*/
public function store($id): ?JsonResponse
{
if (request()->get('is_buy_now')) {
Event::dispatch('shop.item.buy-now', $id);
}
Event::dispatch('checkout.cart.item.add.before', $id);
try {
$result = Cart::addProduct($id, request()->except('_token'));
if (is_array($result) && isset($result['warning'])) {
return response()->json([
'error' => $result['warning'],
], 400);
}
if ($customer = auth($this->guard)->user()) {
$this->wishlistRepository->deleteWhere(['product_id' => $id, 'customer_id' => $customer->id]);
}
Event::dispatch('checkout.cart.item.add.after', $result);
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => __('shop::app.checkout.cart.item.success'),
'data' => $cart ? new CartResource($cart) : null,
]);
} catch (Exception $e) {
Log::error('API CartController: ' . $e->getMessage(),
['product_id' => $id, 'cart_id' => cart()->getCart() ?? 0]);
return response()->json([
'error' => [
'message' => $e->getMessage(),
'code' => $e->getCode()
]
]);
}
}
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\JsonResponse
*/
public function update(Request $request)
{
$this->validate($request, [
'qty' => 'required|array',
]);
$requestedQuantity = $request->get('qty');
foreach ($requestedQuantity as $qty) {
if ($qty <= 0) {
return response()->json([
'message' => trans('shop::app.checkout.cart.quantity.illegal'),
], Response::HTTP_UNAUTHORIZED);
}
}
foreach ($requestedQuantity as $itemId => $qty) {
$item = $this->cartItemRepository->findOneByField('id', $itemId);
Event::dispatch('checkout.cart.item.update.before', $itemId);
Cart::updateItems(['qty' => $requestedQuantity]);
Event::dispatch('checkout.cart.item.update.after', $item);
}
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => __('shop::app.checkout.cart.quantity.success'),
'data' => $cart ? new CartResource($cart) : null,
]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroy()
{
Event::dispatch('checkout.cart.delete.before');
Cart::deActivateCart();
Event::dispatch('checkout.cart.delete.after');
$cart = Cart::getCart();
return response()->json([
'message' => __('shop::app.checkout.cart.item.success-remove'),
'data' => $cart ? new CartResource($cart) : null,
]);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
*/
public function destroyItem($id)
{
Event::dispatch('checkout.cart.item.delete.before', $id);
Cart::removeItem($id);
Event::dispatch('checkout.cart.item.delete.after', $id);
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => __('shop::app.checkout.cart.item.success-remove'),
'data' => $cart ? new CartResource($cart) : null,
]);
}
/**
* Function to move a already added product to wishlist will run only on customer authentication.
*
* @param \Webkul\Checkout\Repositories\CartItemRepository $id
*
* @return \Illuminate\Http\JsonResponse
*/
public function moveToWishlist($id)
{
Event::dispatch('checkout.cart.item.move-to-wishlist.before', $id);
Cart::moveToWishlist($id);
Event::dispatch('checkout.cart.item.move-to-wishlist.after', $id);
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => __('shop::app.checkout.cart.move-to-wishlist-success'),
'data' => $cart ? new CartResource($cart) : null,
]);
}
/**
* Apply coupon code.
*
* @return \Illuminate\Http\JsonResponse
*/
public function applyCoupon()
{
$couponCode = request()->get('code');
try {
if (strlen($couponCode)) {
Cart::setCouponCode($couponCode)->collectTotals();
if (Cart::getCart()->coupon_code == $couponCode) {
return response()->json([
'success' => true,
'message' => trans('shop::app.checkout.total.success-coupon'),
]);
}
}
return response()->json([
'success' => false,
'message' => trans('shop::app.checkout.total.invalid-coupon'),
]);
} catch (\Exception $e) {
report($e);
return response()->json([
'success' => false,
'message' => trans('shop::app.checkout.total.coupon-apply-issue'),
]);
}
}
/**
* Remove coupon code.
*
* @return \Illuminate\Http\JsonResponse
*/
public function removeCoupon()
{
Cart::removeCouponCode()->collectTotals();
return response()->json([
'success' => true,
'message' => trans('shop::app.checkout.total.remove-coupon'),
]);
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\API\Http\Resources\Catalog\Category as CategoryResource;
class CategoryController extends Controller
{
/**
* CategoryRepository object
*
* @var \Webkul\Category\Repositories\CategoryRepository
*/
protected $categoryRepository;
/**
* Create a new controller instance.
*
* @param Webkul\Category\Repositories\CategoryRepository $categoryRepository
* @return void
*/
public function __construct(CategoryRepository $categoryRepository)
{
$this->categoryRepository = $categoryRepository;
}
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return CategoryResource::collection(
$this->categoryRepository->getVisibleCategoryTree(request()->input('parent_id'))
);
}
}

View File

@ -1,227 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Cart;
use Exception;
use Illuminate\Support\Str;
use Webkul\Payment\Facades\Payment;
use Webkul\Shipping\Facades\Shipping;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Shop\Http\Controllers\OnepageController;
use Webkul\Checkout\Repositories\CartItemRepository;
use Webkul\Checkout\Http\Requests\CustomerAddressForm;
use Webkul\API\Http\Resources\Sales\Order as OrderResource;
use Webkul\API\Http\Resources\Checkout\Cart as CartResource;
use Webkul\API\Http\Resources\Checkout\CartShippingRate as CartShippingRateResource;
class CheckoutController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* CartRepository object
*
* @var \Webkul\Checkout\Repositories\CartRepository
*/
protected $cartRepository;
/**
* CartItemRepository object
*
* @var \Webkul\Checkout\Repositories\CartItemRepository
*/
protected $cartItemRepository;
/**
* Controller instance
*
* @param \Webkul\Checkout\Repositories\CartRepository $cartRepository
* @param \Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
* @param \Webkul\Sales\Repositories\OrderRepository $orderRepository
*/
public function __construct(
CartRepository $cartRepository,
CartItemRepository $cartItemRepository,
OrderRepository $orderRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
// $this->middleware('auth:' . $this->guard);
$this->_config = request('_config');
$this->cartRepository = $cartRepository;
$this->cartItemRepository = $cartItemRepository;
$this->orderRepository = $orderRepository;
}
/**
* Saves customer address.
*
* @param \Webkul\Checkout\Http\Requests\CustomerAddressForm $request
* @return \Illuminate\Http\Response
*/
public function saveAddress(CustomerAddressForm $request)
{
$data = request()->all();
$data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1']));
$data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1']));
if (isset($data['billing']['id']) && str_contains($data['billing']['id'], 'address_')) {
unset($data['billing']['id']);
unset($data['billing']['address_id']);
}
if (isset($data['shipping']['id']) && Str::contains($data['shipping']['id'], 'address_')) {
unset($data['shipping']['id']);
unset($data['shipping']['address_id']);
}
if (Cart::hasError() || ! Cart::saveCustomerAddress($data) || ! Shipping::collectRates()) {
abort(400);
}
$rates = [];
foreach (Shipping::getGroupedAllShippingRates() as $code => $shippingMethod) {
$rates[] = [
'carrier_title' => $shippingMethod['carrier_title'],
'rates' => CartShippingRateResource::collection(collect($shippingMethod['rates'])),
];
}
Cart::collectTotals();
return response()->json([
'data' => [
'rates' => $rates,
'cart' => new CartResource(Cart::getCart()),
]
]);
}
/**
* Saves shipping method.
*
* @return \Illuminate\Http\Response
*/
public function saveShipping()
{
$shippingMethod = request()->get('shipping_method');
if (Cart::hasError()
|| !$shippingMethod
|| ! Cart::saveShippingMethod($shippingMethod)
) {
abort(400);
}
Cart::collectTotals();
return response()->json([
'data' => [
'methods' => Payment::getPaymentMethods(),
'cart' => new CartResource(Cart::getCart()),
]
]);
}
/**
* Saves payment method.
*
* @return \Illuminate\Http\Response
*/
public function savePayment()
{
$payment = request()->get('payment');
if (Cart::hasError() || ! $payment || ! Cart::savePaymentMethod($payment)) {
abort(400);
}
return response()->json([
'data' => [
'cart' => new CartResource(Cart::getCart()),
]
]);
}
/**
* Check for minimum order.
*
* @return \Illuminate\Http\Response
*/
public function checkMinimumOrder()
{
$minimumOrderAmount = (float) core()->getConfigData('sales.orderSettings.minimum-order.minimum_order_amount') ?? 0;
$status = Cart::checkMinimumOrder();
return response()->json([
'status' => ! $status ? false : true,
'message' => ! $status ? trans('shop::app.checkout.cart.minimum-order-message', ['amount' => core()->currency($minimumOrderAmount)]) : 'Success',
'data' => [
'cart' => new CartResource(Cart::getCart()),
]
]);
}
/**
* Saves order.
*
* @return \Illuminate\Http\Response
*/
public function saveOrder()
{
if (Cart::hasError()) {
abort(400);
}
Cart::collectTotals();
$this->validateOrder();
$cart = Cart::getCart();
if ($redirectUrl = Payment::getRedirectUrl($cart)) {
return response()->json([
'success' => true,
'redirect_url' => $redirectUrl,
]);
}
$order = $this->orderRepository->create(Cart::prepareDataForOrder());
Cart::deActivateCart();
return response()->json([
'success' => true,
'order' => new OrderResource($order),
]);
}
/**
* Validate order before creation
*
* @throws Exception
*/
public function validateOrder(): void
{
app(OnepageController::class)->validateOrder();
}
}

View File

@ -1,13 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@ -1,58 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
class CoreController extends Controller
{
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getConfig()
{
$configValues = [];
foreach (explode(',', request()->input('_config')) as $config) {
$configValues[$config] = core()->getConfigData($config);
}
return response()->json([
'data' => $configValues,
]);
}
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getCountryStateGroup()
{
return response()->json([
'data' => core()->groupedStatesByCountries(),
]);
}
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function switchCurrency()
{
return response()->json([]);
}
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function switchLocale()
{
return response()->json([]);
}
}

View File

@ -1,117 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Webkul\Customer\Http\Requests\CustomerRegistrationRequest;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Customer\Repositories\CustomerRepository;
class CustomerController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Repository object
*
* @var \Webkul\Customer\Repositories\CustomerRepository
*/
protected $customerRepository;
/**
* Repository object
*
* @var \Webkul\Customer\Repositories\CustomerGroupRepository
*/
protected $customerGroupRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
* @return void
*/
public function __construct(
CustomerRepository $customerRepository,
CustomerGroupRepository $customerGroupRepository
) {
$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);
}
$this->customerRepository = $customerRepository;
$this->customerGroupRepository = $customerGroupRepository;
}
/**
* Method to store user's sign up form data to DB.
*
* @return \Illuminate\Http\Response
*/
public function create(CustomerRegistrationRequest $request)
{
$request->validated();
$data = [
'first_name' => $request->get('first_name'),
'last_name' => $request->get('last_name'),
'email' => $request->get('email'),
'password' => $request->get('password'),
'password' => bcrypt($request->get('password')),
'channel_id' => core()->getCurrentChannel()->id,
'is_verified' => 1,
'customer_group_id' => $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id
];
Event::dispatch('customer.registration.before');
$customer = $this->customerRepository->create($data);
Event::dispatch('customer.registration.after', $customer);
return response()->json([
'message' => 'Your account has been created successfully.',
]);
}
/**
* Returns a current user data.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function get($id)
{
if (Auth::user($this->guard)->id === (int) $id) {
return new $this->_config['resource'](
$this->customerRepository->findOrFail($id)
);
}
return response()->json([
'message' => 'Invalid Request.',
], 403);
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Password;
use Webkul\Customer\Http\Requests\CustomerForgotPasswordRequest;
class ForgotPasswordController extends Controller
{
use SendsPasswordResetEmails;
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store(CustomerForgotPasswordRequest $request)
{
$request->validated();
$response = $this->broker()->sendResetLink($request->only(['email']));
return $response == Password::RESET_LINK_SENT
? response()->json([
'message' => trans($response),
])
: response()->json([
'error' => trans($response),
]);
}
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return Password::broker('customers');
}
}

View File

@ -1,106 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
class InvoiceController 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 invoices.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$query = $this->repository->scopeQuery(function($query) {
$query = $query->leftJoin('orders', 'invoices.order_id', '=', 'orders.id')->select('invoices.*', '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', 'invoices.order_id', '=', 'orders.id')
->select('invoices.*', '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

@ -1,73 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
class OrderController extends Controller
{
/**
* Contains current guard.
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration.
*
* @var array
*/
protected $_config;
/**
* Repository instance.
*
* @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']);
}
}
/**
* Cancel customer's order.
*
* @return \Illuminate\Http\Response
*/
public function cancel($id)
{
$order = auth()->guard($this->guard)->user()->all_orders()->find($id);
if ($order && $this->repository->cancel($order)) {
return response()->json([
'status' => true,
'message' => __('admin::app.response.cancel-success', [
'name' => 'Order'
]),
]);
}
return response()->json([
'status' => false,
'message' => __('shop::app.common.error'),
]);
}
}

View File

@ -1,78 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\API\Http\Resources\Catalog\Product as ProductResource;
class ProductController extends Controller
{
/**
* ProductRepository object
*
* @var \Webkul\Product\Repositories\ProductRepository
*/
protected $productRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
* @return void
*/
public function __construct(ProductRepository $productRepository)
{
$this->productRepository = $productRepository;
}
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return ProductResource::collection($this->productRepository->getAll(request()->input('category_id')));
}
/**
* Returns a individual resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function get($id)
{
return new ProductResource(
$this->productRepository->findOrFail($id)
);
}
/**
* Returns product's additional information.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function additionalInformation($id)
{
return response()->json([
'data' => app('Webkul\Product\Helpers\View')->getAdditionalData($this->productRepository->findOrFail($id)),
]);
}
/**
* Returns product's additional information.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function configurableConfig($id)
{
return response()->json([
'data' => app('Webkul\Product\Helpers\ConfigurableOption')->getConfigurationConfig($this->productRepository->findOrFail($id)),
]);
}
}

View File

@ -1,118 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
class ResourceController 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 resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$query = $this->repository->scopeQuery(function($query) {
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 a individual resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function get($id)
{
$query = isset($this->_config['authorization_required']) && $this->_config['authorization_required'] ?
$this->repository->where('customer_id', auth()->user()->id)->findOrFail($id) :
$this->repository->findOrFail($id);
return new $this->_config['resource']($query);
}
/**
* Delete's a individual resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$wishlistProduct = $this->repository->findOrFail($id);
$this->repository->delete($id);
return response()->json([
'message' => 'Item removed successfully.',
]);
}
}

View File

@ -1,71 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Webkul\Product\Repositories\ProductReviewRepository;
use Webkul\API\Http\Resources\Catalog\ProductReview as ProductReviewResource;
class ReviewController extends Controller
{
/**
* Contains current guard.
*
* @var array
*/
protected $guard;
/**
* ProductReviewRepository $reviewRepository
*
* @var \Webkul\Product\Repositories\ProductReviewRepository
*/
protected $reviewRepository;
/**
* Controller instance.
*
* @param Webkul\Product\Repositories\ProductReviewRepository $reviewRepository
*/
public function __construct(ProductReviewRepository $reviewRepository)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->reviewRepository = $reviewRepository;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function store(Request $request, $id)
{
$customer = auth($this->guard)->user();
$this->validate($request, [
'comment' => 'required',
'rating' => 'required|numeric|min:1|max:5',
'title' => 'required',
]);
$productReview = $this->reviewRepository->create([
'customer_id' => $customer ? $customer->id : null,
'name' => $customer ? $customer->name : $request->get('name'),
'status' => 'pending',
'product_id' => $id,
'comment' => $request->comment,
'rating' => $request->rating,
'title' => $request->title
]);
return response()->json([
'message' => 'Your review submitted successfully.',
'data' => new ProductReviewResource($productReview),
]);
}
}

View File

@ -1,133 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
use Webkul\Customer\Http\Requests\CustomerLoginRequest;
use Webkul\Customer\Repositories\CustomerRepository;
class SessionController extends Controller
{
/**
* Contains current guard
*
* @var string
*/
protected $guard;
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Controller instance
*
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
*/
public function __construct(CustomerRepository $customerRepository)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard, ['only' => ['get', 'update', 'destroy']]);
$this->_config = request('_config');
$this->customerRepository = $customerRepository;
}
/**
* Method to store user's sign up form data to DB.
*
* @return \Illuminate\Http\Response
*/
public function create(CustomerLoginRequest $request)
{
$request->validated();
$jwtToken = null;
if (! $jwtToken = auth()->guard($this->guard)->attempt($request->only(['email', 'password']))) {
return response()->json([
'error' => 'Invalid Email or Password',
], 401);
}
Event::dispatch('customer.after.login', $request->get('email'));
$customer = auth($this->guard)->user();
return response()->json([
'token' => $jwtToken,
'message' => 'Logged in successfully.',
'data' => new CustomerResource($customer),
]);
}
/**
* Get details for current logged in customer
*
* @return \Illuminate\Http\Response
*/
public function get()
{
$customer = auth($this->guard)->user();
return response()->json([
'data' => new CustomerResource($customer),
]);
}
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function update()
{
$customer = auth($this->guard)->user();
$this->validate(request(), [
'first_name' => 'required',
'last_name' => 'required',
'gender' => 'required',
'date_of_birth' => 'nullable|date|before:today',
'email' => 'email|unique:customers,email,' . $customer->id,
'password' => 'confirmed|min:6',
]);
$data = request()->only('first_name', 'last_name', 'gender', 'date_of_birth', 'email', 'password');
if (! isset($data['password']) || ! $data['password']) {
unset($data['password']);
} else {
$data['password'] = bcrypt($data['password']);
}
$updatedCustomer = $this->customerRepository->update($data, $customer->id);
return response()->json([
'message' => 'Your account has been updated successfully.',
'data' => new CustomerResource($updatedCustomer),
]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\Response
*/
public function destroy()
{
auth()->guard($this->guard)->logout();
return response()->json([
'message' => 'Logged out successfully.',
]);
}
}

View File

@ -1,106 +0,0 @@
<?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

@ -1,121 +0,0 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Customer\Repositories\WishlistRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\API\Http\Resources\Customer\Wishlist as WishlistResource;
use Webkul\API\Http\Resources\Checkout\Cart as CartResource;
use Cart;
class WishlistController extends Controller
{
/**
* WishlistRepository object
*
* @var \Webkul\Customer\Repositories\WishlistRepository
*/
protected $wishlistRepository;
/**
* ProductRepository object
*
* @var \Webkul\Customer\Repositories\ProductRepository
*/
protected $productRepository;
/**
* @param \Webkul\Customer\Repositories\WishlistRepository $wishlistRepository
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
*/
public function __construct(
WishlistRepository $wishlistRepository,
ProductRepository $productRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard);
$this->wishlistRepository = $wishlistRepository;
$this->productRepository = $productRepository;
}
/**
* Function to add item to the wishlist.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function create($id)
{
$product = $this->productRepository->findOrFail($id);
$customer = auth()->guard($this->guard)->user();
$wishlistItem = $this->wishlistRepository->findOneWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $id,
'customer_id' => $customer->id,
]);
if (! $wishlistItem) {
$wishlistItem = $this->wishlistRepository->create([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $id,
'customer_id' => $customer->id,
]);
return response()->json([
'data' => new WishlistResource($wishlistItem),
'message' => trans('customer::app.wishlist.success'),
]);
} else {
$this->wishlistRepository->delete($wishlistItem->id);
return response()->json([
'data' => null,
'message' => 'Item removed from wishlist successfully.',
]);
}
}
/**
* Move product from wishlist to cart.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function moveToCart($id)
{
$wishlistItem = $this->wishlistRepository->findOrFail($id);
if ($wishlistItem->customer_id != auth()->guard($this->guard)->user()->id) {
return response()->json([
'message' => trans('shop::app.security-warning'),
], 400);
}
$result = Cart::moveToCart($wishlistItem);
if ($result) {
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'data' => $cart ? new CartResource($cart) : null,
'message' => trans('shop::app.wishlist.moved'),
]);
} else {
return response()->json([
'data' => -1,
'error' => trans('shop::app.wishlist.option-missing'),
], 400);
}
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class Attribute extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'code' => $this->code,
'type' => $this->type,
'name' => $this->name,
'swatch_type' => $this->swatch_type,
'options' => AttributeOption::collection($this->options),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class AttributeFamily extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name,
'status' => $this->status,
'groups' => AttributeGroup::collection($this->attribute_groups),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class AttributeGroup extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name,
'swatch_type' => $this->swatch_type,
'attributes' => Attribute::collection($this->custom_attributes)
];
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class AttributeOption extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'admin_name' => $this->admin_name,
'label' => $this->label,
'swatch_value' => $this->swatch_value,
];
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Resources\Json\JsonResource;
class Category extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name,
'slug' => $this->slug,
'display_mode' => $this->display_mode,
'description' => $this->description,
'meta_title' => $this->meta_title,
'meta_description' => $this->meta_description,
'meta_keywords' => $this->meta_keywords,
'status' => $this->status,
'image_url' => $this->image_url,
'category_icon_path' => $this->category_icon_path
? Storage::url($this->category_icon_path)
: null,
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,293 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\Product\Facades\ProductImage as ProductImageFacade;
class Product extends JsonResource
{
/**
* Create a new resource instance.
*
* @return void
*/
public function __construct($resource)
{
$this->productReviewHelper = app('Webkul\Product\Helpers\Review');
$this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist');
parent::__construct($resource);
}
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
/* assign product */
$product = $this->product ? $this->product : $this;
/* get type instance */
$productTypeInstance = $product->getTypeInstance();
/* generating resource */
return [
/* product's information */
'id' => $product->id,
'sku' => $product->sku,
'type' => $product->type,
'name' => $product->name,
'url_key' => $product->url_key,
'price' => $productTypeInstance->getMinimalPrice(),
'formated_price' => core()->currency($productTypeInstance->getMinimalPrice()),
'short_description' => $product->short_description,
'description' => $product->description,
'images' => ProductImage::collection($product->images),
'videos' => ProductVideo::collection($product->videos),
'base_image' => ProductImageFacade::getProductBaseImage($product),
'created_at' => $product->created_at,
'updated_at' => $product->updated_at,
/* product's reviews */
'reviews' => [
'total' => $total = $this->productReviewHelper->getTotalReviews($product),
'total_rating' => $total ? $this->productReviewHelper->getTotalRating($product) : 0,
'average_rating' => $total ? $this->productReviewHelper->getAverageRating($product) : 0,
'percentage' => $total ? json_encode($this->productReviewHelper->getPercentageRating($product)) : [],
],
/* product's checks */
'in_stock' => $product->haveSufficientQuantity(1),
'is_saved' => false,
'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product) ? true : false,
'is_item_in_cart' => \Cart::hasProduct($product),
'show_quantity_changer' => $this->when(
$product->type !== 'grouped',
$product->getTypeInstance()->showQuantityBox()
),
/* product's extra information */
$this->merge($this->allProductExtraInfo()),
/* special price cases */
$this->merge($this->specialPriceInfo()),
/* super attributes */
$this->mergeWhen($productTypeInstance->isComposite(), [
'super_attributes' => Attribute::collection($product->super_attributes),
]),
];
}
/**
* Get special price information.
*
* @return array
*/
private function specialPriceInfo()
{
$product = $this->product ? $this->product : $this;
$productTypeInstance = $product->getTypeInstance();
return [
'special_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
$productTypeInstance->getSpecialPrice()
),
'formated_special_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
core()->currency($productTypeInstance->getSpecialPrice())
),
'regular_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
data_get($productTypeInstance->getProductPrices(), 'regular_price.price')
),
'formated_regular_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
data_get($productTypeInstance->getProductPrices(), 'regular_price.formated_price')
),
];
}
/**
* Get all product's extra information.
*
* @return array
*/
private function allProductExtraInfo()
{
$product = $this->product ? $this->product : $this;
$productTypeInstance = $product->getTypeInstance();
return [
/* grouped product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Grouped,
$product->type == 'grouped'
? $this->getGroupedProductInfo($product)
: null
),
/* bundle product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Bundle,
$product->type == 'bundle'
? $this->getBundleProductInfo($product)
: null
),
/* configurable product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Configurable,
$product->type == 'configurable'
? $this->getConfigurableProductInfo($product)
: null
),
/* downloadable product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Downloadable,
$product->type == 'downloadable'
? $this->getDownloadableProductInfo($product)
: null
),
/* booking product */
$this->mergeWhen(
$product->type == 'booking',
$product->type == 'booking'
? $this->getBookingProductInfo($product)
: null
),
];
}
/**
* Get grouped product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getGroupedProductInfo($product)
{
return [
'grouped_products' => $product->grouped_products->map(function($groupedProduct) {
$associatedProduct = $groupedProduct->associated_product;
$data = $associatedProduct->toArray();
return array_merge($data, [
'qty' => $groupedProduct->qty,
'isSaleable' => $associatedProduct->getTypeInstance()->isSaleable(),
'formated_price' => $associatedProduct->getTypeInstance()->getPriceHtml(),
'show_quantity_changer' => $associatedProduct->getTypeInstance()->showQuantityBox(),
]);
})
];
}
/**
* Get bundle product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getBundleProductInfo($product)
{
return [
'currency_options' => core()->getAccountJsSymbols(),
'bundle_options' => app('Webkul\Product\Helpers\BundleOption')->getBundleConfig($product)
];
}
/**
* Get configurable product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getConfigurableProductInfo($product)
{
return [
'variants' => $product->variants
];
}
/**
* Get downloadable product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getDownloadableProductInfo($product)
{
return [
'downloadable_links' => $product->downloadable_links->map(function ($downloadableLink) {
$data = $downloadableLink->toArray();
if (isset($data['sample_file'])) {
$data['price'] = core()->currency($downloadableLink->price);
$data['sample_download_url'] = route('shop.downloadable.download_sample', ['type' => 'link', 'id' => $downloadableLink['id']]);
}
return $data;
}),
'downloadable_samples' => $product->downloadable_samples->map(function ($downloadableSample) {
$sample = $downloadableSample->toArray();
$data = $sample;
$data['download_url'] = route('shop.downloadable.download_sample', ['type' => 'sample', 'id' => $sample['id']]);
return $data;
})
];
}
/**
* Get booking product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getBookingProductInfo($product)
{
$bookingProduct = app('\Webkul\BookingProduct\Repositories\BookingProductRepository')->findOneByField('product_id', $product->id);
$data['slot_index_route'] = route('booking_product.slots.index', $bookingProduct->id);
if ($bookingProduct->type == 'appointment') {
$bookingSlotHelper = app('\Webkul\BookingProduct\Helpers\AppointmentSlot');
$data['today_slots_html'] = $bookingSlotHelper->getTodaySlotsHtml($bookingProduct);
$data['week_slot_durations'] = $bookingSlotHelper->getWeekSlotDurations($bookingProduct);
$data['appointment_slot'] = $bookingProduct->appointment_slot;
}
if ($bookingProduct->type == 'event') {
$bookingSlotHelper = app('\Webkul\BookingProduct\Helpers\EventTicket');
$data['tickets'] = $bookingSlotHelper->getTickets($bookingProduct);
$data['event_date'] = $bookingSlotHelper->getEventDate($bookingProduct);
}
if ($bookingProduct->type == 'rental') {
$data['renting_type'] = $bookingProduct->rental_slot->renting_type;
}
if ($bookingProduct->type == 'table') {
$bookingSlotHelper = app('\Webkul\BookingProduct\Helpers\TableSlot');
$data['today_slots_html'] = $bookingSlotHelper->getTodaySlotsHtml($bookingProduct);
$data['week_slot_durations'] = $bookingSlotHelper->getWeekSlotDurations($bookingProduct);
$data['table_slot'] = $bookingProduct->table_slot;
}
return $data;
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductImage extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'path' => $this->path,
'url' => $this->url,
'original_image_url' => $this->url,
'small_image_url' => url('cache/small/' . $this->path),
'medium_image_url' => url('cache/medium/' . $this->path),
'large_image_url' => url('cache/large/' . $this->path)
];
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
class ProductReview extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'rating' => number_format($this->rating, 1, '.', ''),
'comment' => $this->comment,
'name' => $this->name,
'status' => $this->status,
'product' => new Product($this->product),
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductVideo extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'type' => $this->type,
'url' => $this->url
];
}
}

View File

@ -1,100 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Core\ChannelResource as ChannelResource;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
use Webkul\Tax\Helpers\Tax;
class Cart extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request): array
{
$taxes = Tax::getTaxRatesWithAmount($this, false);
$baseTaxes = Tax::getTaxRatesWithAmount($this, true);
$formatedTaxes = $this->formatTaxAmounts($taxes, false);
$formatedBaseTaxes = $this->formatTaxAmounts($baseTaxes, true);
return [
'id' => $this->id,
'customer_email' => $this->customer_email,
'customer_first_name' => $this->customer_first_name,
'customer_last_name' => $this->customer_last_name,
'shipping_method' => $this->shipping_method,
'coupon_code' => $this->coupon_code,
'is_gift' => $this->is_gift,
'items_count' => $this->items_count,
'items_qty' => $this->items_qty,
'exchange_rate' => $this->exchange_rate,
'global_currency_code' => $this->global_currency_code,
'base_currency_code' => $this->base_currency_code,
'channel_currency_code' => $this->channel_currency_code,
'cart_currency_code' => $this->cart_currency_code,
'grand_total' => $this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->cart_currency_code),
'base_grand_total' => $this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'sub_total' => $this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->cart_currency_code),
'base_sub_total' => $this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'tax_total' => $this->tax_total,
'formated_tax_total' => core()->formatPrice($this->tax_total, $this->cart_currency_code),
'base_tax_total' => $this->base_tax_total,
'formated_base_tax_total' => core()->formatBasePrice($this->base_tax_total),
'discount' => $this->discount_amount,
'formated_discount' => core()->formatPrice($this->discount_amount, $this->cart_currency_code),
'base_discount' => $this->base_discount_amount,
'formated_base_discount' => core()->formatBasePrice($this->base_discount_amount),
'checkout_method' => $this->checkout_method,
'is_guest' => $this->is_guest,
'is_active' => $this->is_active,
'conversion_time' => $this->conversion_time,
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'channel' => $this->when($this->channel_id, new ChannelResource($this->channel)),
'items' => CartItem::collection($this->items),
'selected_shipping_rate' => new CartShippingRate($this->selected_shipping_rate),
'payment' => new CartPayment($this->payment),
'billing_address' => new CartAddress($this->billing_address),
'shipping_address' => new CartAddress($this->shipping_address),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'taxes' => json_encode($taxes, JSON_FORCE_OBJECT),
'formated_taxes' => json_encode($formatedTaxes, JSON_FORCE_OBJECT),
'base_taxes' => json_encode($baseTaxes, JSON_FORCE_OBJECT),
'formated_base_taxes' => json_encode($formatedBaseTaxes, JSON_FORCE_OBJECT),
'formated_discounted_sub_total' => core()->formatPrice($this->sub_total - $this->discount_amount, $this->cart_currency_code),
'formated_base_discounted_sub_total' => core()->formatPrice($this->base_sub_total - $this->base_discount_amount, $this->cart_currency_code),
];
}
/**
* @param array $taxes
* @param bool $isBase
*
* @return array
*/
private function formatTaxAmounts(array $taxes, bool $isBase = false): array
{
$result = [];
foreach ($taxes as $taxRate => $taxAmount) {
if ($isBase === true) {
$result[$taxRate] = core()->formatBasePrice($taxAmount);
} else {
$result[$taxRate] = core()->formatPrice($taxAmount, $this->cart_currency_code);
}
}
return $result;
}
}

View File

@ -1,34 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
class CartAddress extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'name' => $this->name,
'email' => $this->email,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => core()->country_name($this->country),
'state' => $this->state,
'city' => $this->city,
'postcode' => $this->postcode,
'phone' => $this->phone,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,57 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Catalog\Product as ProductResource;
class CartItem extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'quantity' => $this->quantity,
'sku' => $this->sku,
'type' => $this->type,
'name' => $this->name,
'coupon_code' => $this->coupon_code,
'weight' => $this->weight,
'total_weight' => $this->total_weight,
'base_total_weight' => $this->base_total_weight,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->cart->cart_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'custom_price' => $this->custom_price,
'formated_custom_price' => core()->formatPrice($this->custom_price, $this->cart->cart_currency_code),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->cart->cart_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'tax_percent' => $this->tax_percent,
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->cart->cart_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->cart->cart_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'child' => new self($this->child),
'product' => $this->when($this->product_id, new ProductResource($this->product)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,25 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
class CartPayment extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'method' => $this->method,
'method_title' => core()->getConfigData('sales.paymentmethods.' . $this->method . '.title'),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}

View File

@ -1,35 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Cart;
class CartShippingRate extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$cart = Cart::getCart();
return [
'id' => $this->id,
'carrier' => $this->carrier,
'carrier_title' => $this->carrier_title,
'method' => $this->method,
'method_title' => $this->method_title,
'method_description' => $this->method_description,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $cart->cart_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Core;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Core\Locale as LocaleResource;
use Webkul\API\Http\Resources\Core\Currency as CurrencyResource;
use Webkul\API\Http\Resources\Catalog\Category as CategoryResource;
class Channel extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name,
'description' => $this->description,
'timezone' => $this->timezone,
'theme' => $this->theme,
'home_page_content' => $this->home_page_content,
'footer_content' => $this->footer_content,
'hostname' => $this->hostname,
'logo' => $this->logo,
'logo_url' => $this->logo_url,
'favicon' => $this->favicon,
'favicon_url' => $this->favicon_url,
'default_locale' => $this->when($this->default_locale_id, new LocaleResource($this->default_locale)),
'base_currency' => $this->when($this->default_currency_id, new CurrencyResource($this->default_currency)),
'root_category_id' => $this->root_category_id,
'root_category' => $this->when($this->root_category_id, new CategoryResource($this->root_category)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Core;
use Illuminate\Http\Resources\Json\JsonResource;
class Country extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name
];
}
}

View File

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

View File

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

View File

@ -1,24 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Core;
use Illuminate\Http\Resources\Json\JsonResource;
class Slider extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'title' => $this->title,
'image_url' => $this->image_url,
'content' => $this->content
];
}
}

View File

@ -1,32 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Customer;
use Illuminate\Http\Resources\Json\JsonResource;
class Customer extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'email' => $this->email,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'name' => $this->name,
'gender' => $this->gender,
'date_of_birth' => $this->date_of_birth,
'phone' => $this->phone,
'status' => $this->status,
'group' => $this->when($this->customer_group_id, new CustomerGroup($this->group)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,35 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Customer;
use Illuminate\Http\Resources\Json\JsonResource;
class CustomerAddress extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'company_name' => $this->company_name,
'vat_id' => $this->vat_id,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => core()->country_name($this->country),
'state' => $this->state,
'city' => $this->city,
'postcode' => $this->postcode,
'phone' => $this->phone,
'is_default' => $this->default_address,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

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

View File

@ -1,25 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Customer;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Catalog\Product as ProductResource;
class Wishlist extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'product' => new ProductResource($this->product),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,39 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Inventory;
use Illuminate\Http\Resources\Json\JsonResource;
class InventorySource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name,
'description' => $this->description,
'contact_name' => $this->contact_name,
'contact_email' => $this->contact_email,
'contact_number' => $this->contact_number,
'contact_fax' => $this->contact_fax,
'country' => $this->country,
'state' => $this->state,
'city' => $this->city,
'street' => $this->street,
'postcode' => $this->postcode,
'priority' => $this->priority,
'latitude' => $this->latitude,
'longitude' => $this->collongitudeongitudeuntry,
'status' => $this->status,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
class Invoice extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'state' => $this->state,
'email_sent' => $this->email_sent,
'total_qty' => $this->total_qty,
'base_currency_code' => $this->base_currency_code,
'channel_currency_code' => $this->channel_currency_code,
'order_currency_code' => $this->order_currency_code,
'sub_total' => $this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->order_currency_code),
'base_sub_total' => $this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'grand_total' => $this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->order_currency_code),
'base_grand_total' => $this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'shipping_amount' => $this->shipping_amount,
'formated_shipping_amount' => core()->formatPrice($this->shipping_amount, $this->order_currency_code),
'base_shipping_amount' => $this->base_shipping_amount,
'formated_base_shipping_amount' => core()->formatBasePrice($this->base_shipping_amount),
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'order_address' => new OrderAddress($this->address),
'transaction_id' => $this->transaction_id,
'items' => InvoiceItem::collection($this->items),
'created_at' => $this->created_at
];
}
}

View File

@ -1,48 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
class InvoiceItem extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
// 'product' => $this->when($this->product, new ProductResource($this->product)),
'description' => $this->description,
'sku' => $this->sku,
'description' => $this->description,
'qty' => $this->qty,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->invoice->order_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->invoice->order_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->invoice->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'grand_total' => $this->total + $this->tax_amount,
'formated_grand_total' => core()->formatPrice($this->total + $this->tax_amount, $this->invoice->order_currency_code),
'base_grand_total' => $this->base_total + $this->base_tax_amount,
'formated_base_grand_total' => core()->formatBasePrice($this->base_total + $this->base_tax_amount),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'child' => new self($this->child),
'children' => Self::collection($this->children)
];
}
}

View File

@ -1,111 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Core\ChannelResource as ChannelResource;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
class Order extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'increment_id' => $this->increment_id,
'status' => $this->status,
'status_label' => $this->status_label,
'channel_name' => $this->channel_name,
'is_guest' => $this->is_guest,
'customer_email' => $this->customer_email,
'customer_first_name' => $this->customer_first_name,
'customer_last_name' => $this->customer_last_name,
'shipping_method' => $this->shipping_method,
'shipping_title' => $this->shipping_title,
'payment_title' => core()->getConfigData('sales.paymentmethods.' . $this->payment->method . '.title'),
'shipping_description' => $this->shipping_description,
'coupon_code' => $this->coupon_code,
'is_gift' => $this->is_gift,
'total_item_count' => $this->total_item_count,
'total_qty_ordered' => $this->total_qty_ordered,
'base_currency_code' => $this->base_currency_code,
'channel_currency_code' => $this->channel_currency_code,
'order_currency_code' => $this->order_currency_code,
'grand_total' => $this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->order_currency_code),
'base_grand_total' => $this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'grand_total_invoiced' => $this->grand_total_invoiced,
'formated_grand_total_invoiced' => core()->formatPrice($this->grand_total_invoiced, $this->order_currency_code),
'base_grand_total_invoiced' => $this->base_grand_total_invoiced,
'formated_base_grand_total_invoiced' => core()->formatBasePrice($this->base_grand_total_invoiced),
'grand_total_refunded' => $this->grand_total_refunded,
'formated_grand_total_refunded' => core()->formatPrice($this->grand_total_refunded, $this->order_currency_code),
'base_grand_total_refunded' => $this->base_grand_total_refunded,
'formated_base_grand_total_refunded' => core()->formatBasePrice($this->base_grand_total_refunded),
'sub_total' => $this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->order_currency_code),
'base_sub_total' => $this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'sub_total_invoiced' => $this->sub_total_invoiced,
'formated_sub_total_invoiced' => core()->formatPrice($this->sub_total_invoiced, $this->order_currency_code),
'base_sub_total_invoiced' => $this->base_sub_total_invoiced,
'formated_base_sub_total_invoiced' => core()->formatBasePrice($this->base_sub_total_invoiced),
'sub_total_refunded' => $this->sub_total_refunded,
'formated_sub_total_refunded' => core()->formatPrice($this->sub_total_refunded, $this->order_currency_code),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'discount_invoiced' => $this->discount_invoiced,
'formated_discount_invoiced' => core()->formatPrice($this->discount_invoiced, $this->order_currency_code),
'base_discount_invoiced' => $this->base_discount_invoiced,
'formated_base_discount_invoiced' => core()->formatBasePrice($this->base_discount_invoiced),
'discount_refunded' => $this->discount_refunded,
'formated_discount_refunded' => core()->formatPrice($this->discount_refunded, $this->order_currency_code),
'base_discount_refunded' => $this->base_discount_refunded,
'formated_base_discount_refunded' => core()->formatBasePrice($this->base_discount_refunded),
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'tax_amount_invoiced' => $this->tax_amount_invoiced,
'formated_tax_amount_invoiced' => core()->formatPrice($this->tax_amount_invoiced, $this->order_currency_code),
'base_tax_amount_invoiced' => $this->base_tax_amount_invoiced,
'formated_base_tax_amount_invoiced' => core()->formatBasePrice($this->base_tax_amount_invoiced),
'tax_amount_refunded' => $this->tax_amount_refunded,
'formated_tax_amount_refunded' => core()->formatPrice($this->tax_amount_refunded, $this->order_currency_code),
'base_tax_amount_refunded' => $this->base_tax_amount_refunded,
'formated_base_tax_amount_refunded' => core()->formatBasePrice($this->base_tax_amount_refunded),
'shipping_amount' => $this->shipping_amount,
'formated_shipping_amount' => core()->formatPrice($this->shipping_amount, $this->order_currency_code),
'base_shipping_amount' => $this->base_shipping_amount,
'formated_base_shipping_amount' => core()->formatBasePrice($this->base_shipping_amount),
'shipping_invoiced' => $this->shipping_invoiced,
'formated_shipping_invoiced' => core()->formatPrice($this->shipping_invoiced, $this->order_currency_code),
'base_shipping_invoiced' => $this->base_shipping_invoiced,
'formated_base_shipping_invoiced' => core()->formatBasePrice($this->base_shipping_invoiced),
'shipping_refunded' => $this->shipping_refunded,
'formated_shipping_refunded' => core()->formatPrice($this->shipping_refunded, $this->order_currency_code),
'base_shipping_refunded' => $this->base_shipping_refunded,
'formated_base_shipping_refunded' => core()->formatBasePrice($this->base_shipping_refunded),
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'channel' => $this->when($this->channel_id, new ChannelResource($this->channel)),
'shipping_address' => new OrderAddress($this->shipping_address),
'billing_address' => new OrderAddress($this->billing_address),
'items' => OrderItem::collection($this->items),
'invoices' => Invoice::collection($this->invoices),
'shipments' => Shipment::collection($this->shipments),
'updated_at' => $this->updated_at,
'created_at' => $this->created_at,
];
}
}

View File

@ -1,33 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
class OrderAddress extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'email' => $this->email,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => core()->country_name($this->country),
'state' => $this->state,
'city' => $this->city,
'postcode' => $this->postcode,
'phone' => $this->phone,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -1,87 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Catalog\Product as ProductResource;
class OrderItem extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
*
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'sku' => $this->sku,
'type' => $this->type,
'name' => $this->name,
'product' => $this->when($this->product, new ProductResource($this->product)),
'coupon_code' => $this->coupon_code,
'weight' => $this->weight,
'total_weight' => $this->total_weight,
'qty_ordered' => $this->qty_ordered,
'qty_canceled' => $this->qty_canceled,
'qty_invoiced' => $this->qty_invoiced,
'qty_shipped' => $this->qty_shipped,
'qty_refunded' => $this->qty_refunded,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->order->order_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->order->order_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'total_invoiced' => $this->total_invoiced,
'formated_total_invoiced' => core()->formatPrice($this->total_invoiced, $this->order->order_currency_code),
'base_total_invoiced' => $this->base_total_invoiced,
'formated_base_total_invoiced' => core()->formatBasePrice($this->base_total_invoiced),
'amount_refunded' => $this->amount_refunded,
'formated_amount_refunded' => core()->formatPrice($this->amount_refunded, $this->order->order_currency_code),
'base_amount_refunded' => $this->base_amount_refunded,
'formated_base_amount_refunded' => core()->formatBasePrice($this->base_amount_refunded),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order->order_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'discount_invoiced' => $this->discount_invoiced,
'formated_discount_invoiced' => core()->formatPrice($this->discount_invoiced, $this->order->order_currency_code),
'base_discount_invoiced' => $this->base_discount_invoiced,
'formated_base_discount_invoiced' => core()->formatBasePrice($this->base_discount_invoiced),
'discount_refunded' => $this->discount_refunded,
'formated_discount_refunded' => core()->formatPrice($this->discount_refunded, $this->order->order_currency_code),
'base_discount_refunded' => $this->base_discount_refunded,
'formated_base_discount_refunded' => core()->formatBasePrice($this->base_discount_refunded),
'tax_percent' => $this->tax_percent,
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'tax_amount_invoiced' => $this->tax_amount_invoiced,
'formated_tax_amount_invoiced' => core()->formatPrice($this->tax_amount_invoiced, $this->order->order_currency_code),
'base_tax_amount_invoiced' => $this->base_tax_amount_invoiced,
'formated_base_tax_amount_invoiced' => core()->formatBasePrice($this->base_tax_amount_invoiced),
'tax_amount_refunded' => $this->tax_amount_refunded,
'formated_tax_amount_refunded' => core()->formatPrice($this->tax_amount_refunded, $this->order->order_currency_code),
'base_tax_amount_refunded' => $this->base_tax_amount_refunded,
'formated_base_tax_amount_refunded' => core()->formatBasePrice($this->base_tax_amount_refunded),
'grant_total' => $this->total + $this->tax_amount,
'formated_grant_total' => core()->formatPrice($this->total + $this->tax_amount, $this->order->order_currency_code),
'base_grant_total' => $this->base_total + $this->base_tax_amount,
'formated_base_grant_total' => core()->formatPrice($this->base_total + $this->base_tax_amount, $this->order->order_currency_code),
'downloadable_links' => $this->downloadable_link_purchased,
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'child' => new self($this->child),
'children' => Self::collection($this->children)
];
}
}

View File

@ -1,28 +0,0 @@
<?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

@ -1,33 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
use Webkul\API\Http\Resources\Inventory\InventorySource as InventorySourceResource;
class Shipment extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'status' => $this->status,
'total_qty' => $this->total_qty,
'total_weight' => $this->total_weight,
'carrier_code' => $this->carrier_code,
'carrier_title' => $this->carrier_title,
'track_number' => $this->track_number,
'email_sent' => $this->email_sent,
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'inventory_source' => $this->when($this->inventory_source_id, new InventorySourceResource($this->inventory_source)),
'items' => ShipmentItem::collection($this->items),
];
}
}

View File

@ -1,37 +0,0 @@
<?php
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
class ShipmentItem extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'sku' => $this->sku,
'qty' => $this->qty,
'weight' => $this->weight,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->shipment->order->order_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->shipment->order->order_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true)
];
}
}

View File

@ -1,348 +0,0 @@
<?php
// Controllers
use Webkul\API\Http\Controllers\Shop\AddressController;
use Webkul\API\Http\Controllers\Shop\CartController;
use Webkul\API\Http\Controllers\Shop\CategoryController;
use Webkul\API\Http\Controllers\Shop\CheckoutController;
use Webkul\API\Http\Controllers\Shop\CoreController;
use Webkul\API\Http\Controllers\Shop\CustomerController;
use Webkul\API\Http\Controllers\Shop\ForgotPasswordController;
use Webkul\API\Http\Controllers\Shop\InvoiceController;
use Webkul\API\Http\Controllers\Shop\OrderController;
use Webkul\API\Http\Controllers\Shop\ProductController;
use Webkul\API\Http\Controllers\Shop\ResourceController;
use Webkul\API\Http\Controllers\Shop\ReviewController;
use Webkul\API\Http\Controllers\Shop\SessionController;
use Webkul\API\Http\Controllers\Shop\TransactionController;
use Webkul\API\Http\Controllers\Shop\WishlistController;
// Resources
use Webkul\API\Http\Resources\Catalog\Attribute;
use Webkul\API\Http\Resources\Catalog\AttributeFamily;
use Webkul\API\Http\Resources\Catalog\Category;
use Webkul\API\Http\Resources\Catalog\ProductReview;
use Webkul\API\Http\Resources\Core\ChannelResource;
use Webkul\API\Http\Resources\Core\Country;
use Webkul\API\Http\Resources\Core\Currency;
use Webkul\API\Http\Resources\Core\Locale;
use Webkul\API\Http\Resources\Core\Slider;
use Webkul\API\Http\Resources\Customer\Customer;
use Webkul\API\Http\Resources\Customer\CustomerAddress;
use Webkul\API\Http\Resources\Customer\Wishlist;
use Webkul\API\Http\Resources\Sales\Invoice;
use Webkul\API\Http\Resources\Sales\Order;
use Webkul\API\Http\Resources\Sales\OrderTransaction;
use Webkul\API\Http\Resources\Sales\Shipment;
// Repositories
use Webkul\Attribute\Repositories\AttributeRepository;
use Webkul\Attribute\Repositories\AttributeFamilyRepository;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Core\Repositories\CountryRepository;
use Webkul\Core\Repositories\CurrencyRepository;
use Webkul\Core\Repositories\LocaleRepository;
use Webkul\Core\Repositories\SliderRepository;
use Webkul\Customer\Repositories\CustomerRepository;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\Customer\Repositories\WishlistRepository;
use Webkul\Product\Repositories\ProductReviewRepository;
use Webkul\Sales\Repositories\InvoiceRepository;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\OrderTransactionRepository;
use Webkul\Sales\Repositories\ShipmentRepository;
Route::group(['prefix' => 'api'], function ($router) {
Route::group(['middleware' => ['locale', 'theme', 'currency']], function ($router) {
//Currency and Locale switcher
Route::get('switch-currency', [CoreController::class, 'switchCurrency']);
Route::get('switch-locale', [CoreController::class, 'switchLocale']);
//Category routes
Route::get('categories', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => CategoryRepository::class,
'resource' => Category::class,
]);
Route::get('descendant-categories', [CategoryController::class, 'index']);
Route::get('categories/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => CategoryRepository::class,
'resource' => Category::class,
]);
//Attribute routes
Route::get('attributes', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => AttributeRepository::class,
'resource' => Attribute::class,
]);
Route::get('attributes/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => AttributeRepository::class,
'resource' => Attribute::class,
]);
//AttributeFamily routes
Route::get('families', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => AttributeFamilyRepository::class,
'resource' => AttributeFamily::class,
]);
Route::get('families/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => AttributeFamilyRepository::class,
'resource' => AttributeFamily::class,
]);
//Product routes
Route::get('products', [ProductController::class, 'index']);
Route::get('products/{id}', [ProductController::class, 'get']);
Route::get('product-additional-information/{id}', [ProductController::class, 'additionalInformation']);
Route::get('product-configurable-config/{id}', [ProductController::class, 'configurableConfig']);
//Product Review routes
Route::get('reviews', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => ProductReviewRepository::class,
'resource' => ProductReview::class,
]);
Route::get('reviews/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => ProductReviewRepository::class,
'resource' => ProductReview::class,
]);
Route::post('reviews/{id}/create', [ReviewController::class, 'store']);
Route::delete('reviews/{id}', [ResourceController::class, 'destroy'])->defaults('_config', [
'repository' => ProductReviewRepository::class,
'resource' => ProductReview::class,
'authorization_required' => true
]);
//Channel routes
Route::get('channels', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => ChannelRepository::class,
'resource' => ChannelResource::class,
]);
Route::get('channels/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => ChannelRepository::class,
'resource' => ChannelResource::class,
]);
//Locale routes
Route::get('locales', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => LocaleRepository::class,
'resource' => Locale::class,
]);
Route::get('locales/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => LocaleRepository::class,
'resource' => Locale::class,
]);
//Country routes
Route::get('countries', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => CountryRepository::class,
'resource' => Country::class,
]);
Route::get('countries/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => CountryRepository::class,
'resource' => Country::class,
]);
Route::get('country-states', [CoreController::class, 'getCountryStateGroup']);
//Slider routes
Route::get('sliders', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => SliderRepository::class,
'resource' => Slider::class,
]);
Route::get('sliders/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => SliderRepository::class,
'resource' => Slider::class,
]);
//Currency routes
Route::get('currencies', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => CurrencyRepository::class,
'resource' => Currency::class,
]);
Route::get('currencies/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => CurrencyRepository::class,
'resource' => Currency::class,
]);
Route::get('config', [CoreController::class, 'getConfig']);
//Customer routes
Route::post('customer/login', [SessionController::class, 'create']);
Route::post('customer/forgot-password', [ForgotPasswordController::class, 'store']);
Route::get('customer/logout', [SessionController::class, 'destroy']);
Route::get('customer/get', [SessionController::class, 'get']);
Route::put('customer/profile', [SessionController::class, 'update']);
Route::post('customer/register', [CustomerController::class, 'create']);
Route::get('customers/{id}', [CustomerController::class, 'get'])->defaults('_config', [
'repository' => CustomerRepository::class,
'resource' => Customer::class,
'authorization_required' => true
]);
//Customer Address routes
Route::get('addresses', [AddressController::class, 'get'])->defaults('_config', [
'authorization_required' => true
]);
Route::get('addresses/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => CustomerAddressRepository::class,
'resource' => CustomerAddress::class,
'authorization_required' => true
]);
Route::delete('addresses/{id}', [ResourceController::class, 'destroy'])->defaults('_config', [
'repository' => CustomerAddressRepository::class,
'resource' => CustomerAddress::class,
'authorization_required' => true
]);
Route::put('addresses/{id}', [AddressController::class, 'update'])->defaults('_config', [
'authorization_required' => true
]);
Route::post('addresses/create', [AddressController::class, 'store'])->defaults('_config', [
'authorization_required' => true
]);
//Order routes
Route::get('orders', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => OrderRepository::class,
'resource' => Order::class,
'authorization_required' => true
]);
Route::get('orders/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => OrderRepository::class,
'resource' => Order::class,
'authorization_required' => true
]);
Route::post('orders/{id}/cancel', [OrderController::class, 'cancel'])->defaults('_config', [
'repository' => OrderRepository::class,
'resource' => Order::class,
'authorization_required' => true
]);
//Invoice routes
Route::get('invoices', [InvoiceController::class, 'index'])->defaults('_config', [
'repository' => InvoiceRepository::class,
'resource' => Invoice::class,
'authorization_required' => true
]);
Route::get('invoices/{id}', [InvoiceController::class, 'get'])->defaults('_config', [
'repository' => InvoiceRepository::class,
'resource' => Invoice::class,
'authorization_required' => true
]);
//Shipment routes
Route::get('shipments', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => ShipmentRepository::class,
'resource' => Shipment::class,
'authorization_required' => true
]);
Route::get('shipments/{id}', [ResourceController::class, 'get'])->defaults('_config', [
'repository' => ShipmentRepository::class,
'resource' => Shipment::class,
'authorization_required' => true
]);
//Transaction routes
Route::get('transactions', [TransactionController::class, 'index'])->defaults('_config', [
'repository' => OrderTransactionRepository::class,
'resource' => OrderTransaction::class,
'authorization_required' => true
]);
Route::get('transactions/{id}', [TransactionController::class, 'get'])->defaults('_config', [
'repository' => OrderTransactionRepository::class,
'resource' => OrderTransaction::class,
'authorization_required' => true
]);
//Wishlist routes
Route::get('wishlist', [ResourceController::class, 'index'])->defaults('_config', [
'repository' => WishlistRepository::class,
'resource' => Wishlist::class,
'authorization_required' => true
]);
Route::delete('wishlist/{id}', [ResourceController::class, 'destroy'])->defaults('_config', [
'repository' => WishlistRepository::class,
'resource' => Wishlist::class,
'authorization_required' => true
]);
Route::get('move-to-cart/{id}', [WishlistController::class, 'moveToCart']);
Route::get('wishlist/add/{id}', [WishlistController::class, 'create']);
//Checkout routes
Route::group(['prefix' => 'checkout'], function ($router) {
Route::post('cart/add/{id}', [CartController::class, 'store']);
Route::get('cart', [CartController::class, 'get']);
Route::get('cart/empty', [CartController::class, 'destroy']);
Route::put('cart/update', [CartController::class, 'update']);
Route::get('cart/remove-item/{id}', [CartController::class, 'destroyItem']);
Route::post('cart/coupon', [CartController::class, 'applyCoupon']);
Route::delete('cart/coupon', [CartController::class, 'removeCoupon']);
Route::get('cart/move-to-wishlist/{id}', [CartController::class, 'moveToWishlist']);
Route::post('save-address', [CheckoutController::class, 'saveAddress']);
Route::post('save-shipping', [CheckoutController::class, 'saveShipping']);
Route::post('save-payment', [CheckoutController::class, 'savePayment']);
Route::post('check-minimum-order', [CheckoutController::class, 'checkMinimumOrder']);
Route::post('save-order', [CheckoutController::class, 'saveOrder']);
});
});
});

View File

@ -1,27 +0,0 @@
<?php
namespace Webkul\API\Providers;
use Illuminate\Support\ServiceProvider;
class APIServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/../Http/routes.php');
}
/**
* Register services.
*
* @return void
*/
public function register()
{
}
}

View File

@ -1,11 +0,0 @@
<?php
namespace Webkul\API\Providers;
use Webkul\Core\Providers\CoreModuleServiceProvider;
class ModuleServiceProvider extends CoreModuleServiceProvider
{
protected $models = [
];
}

View File

@ -1,34 +0,0 @@
{
"name": "bagisto/laravel-api",
"license": "MIT",
"authors": [
{
"name": "Prashant Singh",
"email": "prashant.singh852@webkul.com"
}
],
"require": {
"bagisto/laravel-user": "dev-master",
"bagisto/laravel-core": "dev-master",
"bagisto/laravel-product": "dev-master",
"bagisto/laravel-shop": "dev-master",
"bagisto/laravel-category": "dev-master",
"bagisto/laravel-tax": "dev-master",
"bagisto/laravel-inventory": "dev-master",
"bagisto/laravel-checkout": "dev-master"
},
"autoload": {
"psr-4": {
"Webkul\\API\\": "/"
}
},
"extra": {
"laravel": {
"providers": [
"Webkul\\API\\Providers\\APIServiceProvider"
],
"aliases": {}
}
},
"minimum-stability": "dev"
}

View File

@ -21,6 +21,10 @@
"vue-template-compiler": "^2.6.14"
},
"dependencies": {
"laravel-echo": "^1.11.3",
"laravel-vue-pagination": "^2.3.1",
"moment": "^2.29.1",
"pusher-js": "^7.0.3",
"vee-validate": "^2.2.15"
}
}

2
packages/Webkul/Admin/publishable/assets/css/admin.css vendored Executable file → Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 11H7V13H5V11ZM8 11H10V13H8V11ZM11 11H13V13H11V11ZM14 11H16V13H14V11ZM17 11H19V13H17V11ZM5 14H7V16H5V14ZM8 14H10V16H8V14ZM11 14H13V16H11V14ZM14 14H16V16H14V14ZM17 14H19V16H17V14ZM14 17H16V19H14V17ZM5 17H7V19H5V17ZM8 17H10V19H8V17ZM11 17H13V19H11V17Z" fill="#9497B8"/>
<path d="M19 4H5C3.89543 4 3 4.89543 3 6V20C3 21.1046 3.89543 22 5 22H19C20.1046 22 21 21.1046 21 20V6C21 4.89543 20.1046 4 19 4Z" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 9H20.2234" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8.05518 2.0166V4" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16 2V3.91915" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 960 B

View File

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 7H19" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M5 12H19" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M5 17H19" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 408 B

View File

@ -0,0 +1 @@
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 28 28" xml:space="preserve"><style></style><path d="M15.4 14l7.9-7.9c.4-.4.4-1 0-1.4s-1-.4-1.4 0L14 12.6l-7.9-8c-.4-.4-1-.4-1.4 0s-.4 1 0 1.4l7.9 7.9-7.9 7.9c-.4.4-.4 1 0 1.4.2.2.5.3.7.3s.5-.1.7-.3l7.9-7.9 7.9 7.9c.2.2.5.3.7.3s.5-.1.7-.3c.4-.4.4-1 0-1.4L15.4 14z"/></svg>

After

Width:  |  Height:  |  Size: 363 B

View File

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 4L23 4" stroke="#3C41FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M1 12L23 12" stroke="#3C41FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M1 20L23 20" stroke="#3C41FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 416 B

View File

@ -0,0 +1 @@
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 28 28" xml:space="preserve"><style></style><path d="M26.3 25.2l-5.6-5.7c1.6-2 2.5-4.5 2.5-7.2 0-3.1-1.2-6-3.4-8.2-2.1-2-4.7-3.1-7.5-3-6 0-10.9 5-10.9 11.2 0 6.2 4.9 11.2 10.9 11.2 2.6 0 5.1-.9 7-2.6l5.6 5.7c.2.2.5.3.7.3.3 0 .5-.1.7-.3.4-.4.4-1 0-1.4zM3.4 12.3c0-5.1 4-9.2 8.9-9.2h.2c2.2 0 4.3.9 5.9 2.5 1.8 1.7 2.8 4.2 2.8 6.7s-1 4.8-2.6 6.5c-1.6 1.7-3.9 2.7-6.3 2.7-4.9 0-8.9-4.1-8.9-9.2z"/></svg>

After

Width:  |  Height:  |  Size: 490 B

View File

@ -0,0 +1 @@
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 28 28" xml:space="preserve"><style></style><path d="M17.7 13.9c1.3-1.1 2.1-2.7 2.1-4.5 0-3.2-2.6-5.8-5.8-5.8S8.2 6.2 8.2 9.4c0 1.8.8 3.4 2.1 4.5-3.9 1.5-6.6 5.2-6.6 9.6 0 .6.4 1 1 1s1-.4 1-1c0-3.2 1.9-6.1 4.6-7.4l2.6 2.1v3.4c0 .6.4 1 1 1s1-.4 1-1v-3.5l2.4-2.2c2.8 1.3 4.8 4.2 4.8 7.5 0 .6.4 1 1 1s1-.4 1-1c.2-4.3-2.6-8.1-6.4-9.5zm-7.5-4.5c0-2.1 1.7-3.8 3.8-3.8s3.8 1.7 3.8 3.8-1.7 3.8-3.8 3.8-3.8-1.7-3.8-3.8zm3.8 6.9l-1.3-1.1c.4-.1.9-.1 1.4-.1.4 0 .8 0 1.2.1L14 16.3z"/></svg>

After

Width:  |  Height:  |  Size: 569 B

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,11 @@
/*!
* Pusher JavaScript Library v7.0.3
* https://pusher.com/
*
* Copyright 2020, Pusher
* Released under the MIT licence.
*/
/*!
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
@ -37,3 +45,7 @@
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
//! moment.js
//! moment.js locale configuration

View File

@ -1,4 +1,4 @@
{
"/js/admin.js": "/js/admin.js?id=8bcdcf3b86191d1739a5",
"/css/admin.css": "/css/admin.css?id=4ed7566377c765482303"
"/js/admin.js": "/js/admin.js?id=94da304c8b02ad3ba649",
"/css/admin.css": "/css/admin.css?id=df6b15e0f1deaef7b05c"
}

View File

@ -350,10 +350,21 @@ return [
'key' => 'customer.settings',
'name' => 'admin::app.admin.system.settings',
'sort' => 1,
], [
'key' => 'customer.settings.wishlist',
'name' => 'admin::app.admin.system.wishlist',
'sort' => 1,
'fields' => [
[
'name' => 'share',
'title' => 'admin::app.admin.system.wishlist-share',
'type' => 'boolean',
],
],
], [
'key' => 'customer.settings.address',
'name' => 'admin::app.admin.system.address',
'sort' => 1,
'sort' => 2,
'fields' => [
[
'name' => 'street_lines',
@ -366,7 +377,7 @@ return [
], [
'key' => 'customer.settings.newsletter',
'name' => 'admin::app.admin.system.newsletter',
'sort' => 2,
'sort' => 3,
'fields' => [
[
'name' => 'subscription',
@ -377,7 +388,7 @@ return [
], [
'key' => 'customer.settings.email',
'name' => 'admin::app.admin.system.email',
'sort' => 3,
'sort' => 4,
'fields' => [
[
'name' => 'verification',
@ -388,7 +399,7 @@ return [
], [
'key' => 'emails',
'name' => 'admin::app.admin.emails.email',
'sort' => 6,
'sort' => 5,
], [
'key' => 'emails.configure',
'name' => 'admin::app.admin.system.email-settings',

View File

@ -88,6 +88,15 @@ class AddressDataGrid extends DataGrid
*/
public function addColumns()
{
$this->addColumn([
'index' => 'address_id',
'label' => trans('admin::app.datagrid.id'),
'type' => 'number',
'searchable' => true,
'sortable' => true,
'filterable' => true,
]);
$this->addColumn([
'index' => 'company_name',
'label' => trans('admin::app.customers.addresses.company-name'),

View File

@ -63,7 +63,8 @@ class SliderDataGrid extends DataGrid
/* finding channel code */
if ($this->channel !== 'all') {
$this->channel = Channel::query()->find($this->channel);
$this->channel = Channel::where('code', $this->channel)->first();
$this->channel = $this->channel ? $this->channel->code : 'all';
}
}
@ -140,7 +141,7 @@ class SliderDataGrid extends DataGrid
'type' => 'string',
'searchable' => true,
'sortable' => true,
'filterable' => true
'filterable' => true,
]);
}

View File

@ -2,11 +2,10 @@
namespace Webkul\Admin\Http\Controllers;
use Webkul\Core\Tree;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Storage;
use Webkul\Admin\Http\Requests\ConfigurationForm;
use Webkul\Core\Repositories\CoreConfigRepository;
use Webkul\Core\Tree;
class ConfigurationController extends Controller
{
@ -113,12 +112,8 @@ class ConfigurationController extends Controller
*/
public function store(ConfigurationForm $request)
{
Event::dispatch('core.configuration.save.before');
$this->coreConfigRepository->create($request->except(['_token', 'admin_locale']));
Event::dispatch('core.configuration.save.after');
session()->flash('success', trans('admin::app.configuration.save-message'));
return redirect()->back();

View File

@ -2,52 +2,48 @@
namespace Webkul\Admin\Http\Controllers\Customer;
use Illuminate\Support\Facades\Event;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Customer\Repositories\CustomerRepository;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Admin\Mail\NewCustomerNotification;
use Mail;
use Webkul\Admin\DataGrids\CustomerOrderDataGrid;
use Webkul\Admin\DataGrids\CustomersInvoicesDataGrid;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Mail\NewCustomerNotification;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Customer\Repositories\CustomerRepository;
class CustomerController extends Controller
{
/**
* Contains route related configuration
* Contains route related configuration.
*
* @var array
*/
protected $_config;
/**
* CustomerRepository object
* Customer repository instance.
*
* @var \Webkul\Customer\Repositories\CustomerRepository
*/
protected $customerRepository;
/**
* CustomerAddress Repository object
* Customer address repository instance.
*
* @var \Webkul\Customer\Repositories\CustomerAddressRepository
*/
protected $customerAddressRepository;
/**
* CustomerGroupRepository object
* Customer group repository instance.
*
* @var \Webkul\Customer\Repositories\CustomerGroupRepository
*/
protected $customerGroupRepository;
/**
* ChannelRepository object
* Channel repository instance.
*
* @var \Webkul\Core\Repositories\ChannelRepository
*/
@ -66,15 +62,17 @@ class CustomerController extends Controller
CustomerAddressRepository $customerAddressRepository,
CustomerGroupRepository $customerGroupRepository,
ChannelRepository $channelRepository
)
{
) {
$this->_config = request('_config');
$this->middleware('admin');
$this->customerRepository = $customerRepository;
$this->customerAddressRepository = $customerAddressRepository;
$this->customerGroupRepository = $customerGroupRepository;
$this->channelRepository = $channelRepository;
}
@ -125,12 +123,8 @@ class CustomerController extends Controller
$data['is_verified'] = 1;
Event::dispatch('customer.registration.before');
$customer = $this->customerRepository->create($data);
Event::dispatch('customer.registration.after', $customer);
try {
$configKey = 'emails.general.notifications.emails.general.notifications.customer';
if (core()->getConfigData($configKey)) {
@ -181,11 +175,7 @@ class CustomerController extends Controller
$data['status'] = ! isset($data['status']) ? 0 : 1;
Event::dispatch('customer.update.before');
$customer = $this->customerRepository->update($data, $id);
Event::dispatch('customer.update.after', $customer);
$this->customerRepository->update($data, $id);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));
@ -224,7 +214,7 @@ class CustomerController extends Controller
}
/**
* To load the note taking screen for the customers
* To load the note taking screen for the customers.
*
* @param int $id
* @return \Illuminate\View\View
@ -237,7 +227,7 @@ class CustomerController extends Controller
}
/**
* To store the response of the note in storage
* To store the response of the note in storage.
*
* @return \Illuminate\Http\Response
*/
@ -261,7 +251,7 @@ class CustomerController extends Controller
}
/**
* To mass update the customer
* To mass update the customer.
*
* @return \Illuminate\Http\Response
*/
@ -282,7 +272,7 @@ class CustomerController extends Controller
}
/**
* To mass delete the customer
* To mass delete the customer.
*
* @return \Illuminate\Http\Response
*/

View File

@ -8,14 +8,14 @@ use Webkul\Customer\Repositories\CustomerGroupRepository;
class CustomerGroupController extends Controller
{
/**
* Contains route related configuration
* Contains route related configuration.
*
* @var array
*/
protected $_config;
/**
* CustomerGroupRepository object
* Customer group repository instance.
*
* @var \Webkul\Customer\Repositories\CustomerGroupRepository
*/

View File

@ -32,7 +32,7 @@ class ExportController extends Controller
$path = '\Webkul\Admin\DataGrids' . '\\' . last($gridName);
$gridInstance = new $path;
$gridInstance = app($path);
$records = $gridInstance->export();

View File

@ -2,13 +2,17 @@
namespace Webkul\Admin\Http\Controllers\Sales;
use PDF;
use Illuminate\Http\Request;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Traits\Mails;
use Webkul\Core\Traits\PDFHandler;
use Webkul\Sales\Repositories\InvoiceRepository;
use Webkul\Sales\Repositories\OrderRepository;
class InvoiceController extends Controller
{
use Mails, PDFHandler;
/**
* Display a listing of the resource.
*
@ -99,21 +103,18 @@ class InvoiceController extends Controller
$data = request()->all();
$haveProductToInvoice = false;
foreach ($data['invoice']['items'] as $itemId => $qty) {
if ($qty) {
$haveProductToInvoice = true;
break;
}
}
if (! $haveProductToInvoice) {
if (! $this->invoiceRepository->haveProductToInvoice($data)) {
session()->flash('error', trans('admin::app.sales.invoices.product-error'));
return redirect()->back();
}
if (! $this->invoiceRepository->isValidQuantity($data)) {
session()->flash('error', trans('admin::app.sales.invoices.invalid-qty'));
return redirect()->back();
}
$this->invoiceRepository->create(array_merge($data, ['order_id' => $orderId]));
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Invoice']));
@ -134,40 +135,47 @@ class InvoiceController extends Controller
return view($this->_config['view'], compact('invoice'));
}
/**
* Send duplicate invoice.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function sendDuplicateInvoice(Request $request, $id)
{
$request->validate([
'email' => 'required|email',
]);
$invoice = $this->invoiceRepository->findOrFail($id);
if ($invoice) {
$this->sendDuplicateInvoiceMail($invoice, $request->email);
session()->flash('success', __('admin::app.sales.invoices.invoice-sent'));
return redirect()->back();
}
session()->flash('error', __('admin::app.response.something-went-wrong'));
return redirect()->back();
}
/**
* Print and download the for the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function print($id)
public function printInvoice($id)
{
$invoice = $this->invoiceRepository->findOrFail($id);
$html = view('admin::sales.invoices.pdf', compact('invoice'))->render();
return PDF::loadHTML($this->adjustArabicAndPersianContent($html))
->setPaper('a4')
->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
}
/**
* Adjust arabic and persian content.
*
* @param string $html
* @return string
*/
private function adjustArabicAndPersianContent($html)
{
$arabic = new \ArPHP\I18N\Arabic();
$p = $arabic->arIdentify($html);
for ($i = count($p) - 1; $i >= 0; $i -= 2) {
$utf8ar = $arabic->utf8Glyphs(substr($html, $p[$i - 1], $p[$i] - $p[$i - 1]));
$html = substr_replace($html, $utf8ar, $p[$i - 1], $p[$i] - $p[$i - 1]);
}
return $html;
return $this->downloadPDF(
view('admin::sales.invoices.pdf', compact('invoice'))->render(),
'invoice-' . $invoice->created_at->format('d-m-Y')
);
}
}

View File

@ -3,8 +3,8 @@
namespace Webkul\Admin\Http\Controllers\Sales;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\OrderItemRepository;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\RefundRepository;
class RefundController extends Controller
@ -17,21 +17,21 @@ class RefundController extends Controller
protected $_config;
/**
* OrderRepository object
* Order repository instance.
*
* @var \Webkul\Sales\Repositories\OrderRepository
*/
protected $orderRepository;
/**
* OrderItemRepository object
* Order item repository instance.
*
* @var \Webkul\Sales\Repositories\OrderItemRepository
*/
protected $orderItemRepository;
/**
* RefundRepository object
* Refund repository instance.
*
* @var \Webkul\Sales\Repositories\RefundRepository
*/
@ -49,8 +49,7 @@ class RefundController extends Controller
OrderRepository $orderRepository,
OrderItemRepository $orderItemRepository,
RefundRepository $refundRepository
)
{
) {
$this->middleware('admin');
$this->_config = request('_config');
@ -113,6 +112,12 @@ class RefundController extends Controller
$totals = $this->refundRepository->getOrderItemsRefundSummary($data['refund']['items'], $orderId);
if (! $totals) {
session()->flash('error', trans('admin::app.sales.refunds.invalid-qty'));
return redirect()->back();
}
$maxRefundAmount = $totals['grand_total']['price'] - $order->refunds()->sum('base_adjustment_refund');
$refundAmount = $totals['grand_total']['price'] - $totals['shipping']['price'] + $data['refund']['shipping'] + $data['refund']['adjustment_refund'] - $data['refund']['adjustment_fee'];

View File

@ -3,8 +3,8 @@
namespace Webkul\Admin\Http\Controllers\Sales;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\OrderItemRepository;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\ShipmentRepository;
class ShipmentController extends Controller
@ -17,21 +17,21 @@ class ShipmentController extends Controller
protected $_config;
/**
* OrderRepository object
* Order repository instance.
*
* @var \Webkul\Sales\Repositories\OrderRepository
*/
protected $orderRepository;
/**
* OrderItemRepository object
* Order item repository instance.
*
* @var \Webkul\Sales\Repositories\OrderItemRepository
*/
protected $orderItemRepository;
/**
* ShipmentRepository object
* Shipment repository instance.
*
* @var \Webkul\Sales\Repositories\ShipmentRepository
*/
@ -49,8 +49,7 @@ class ShipmentController extends Controller
ShipmentRepository $shipmentRepository,
OrderRepository $orderRepository,
OrderItemRepository $orderItemRepository
)
{
) {
$this->middleware('admin');
$this->_config = request('_config');
@ -128,7 +127,7 @@ class ShipmentController extends Controller
}
/**
* Checks if requested quantity available or not
* Checks if requested quantity available or not.
*
* @param array $data
* @return bool
@ -144,7 +143,9 @@ class ShipmentController extends Controller
$inventorySourceId = $data['shipment']['source'];
foreach ($data['shipment']['items'] as $itemId => $inventorySource) {
if ($qty = $inventorySource[$inventorySourceId]) {
$qty = $inventorySource[$inventorySourceId];
if ((int) $qty) {
$orderItem = $this->orderItemRepository->find($itemId);
if ($orderItem->qty_to_ship < $qty) {

View File

@ -3,30 +3,10 @@
namespace Webkul\Admin\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Factory as ValidationFactory;
use Webkul\Core\Contracts\Validations\CommaSeperatedInteger;
class ConfigurationForm extends FormRequest
{
/*
Added custom validator.
*/
public function __construct(ValidationFactory $validationFactory)
{
/* added custom comma seperated integer validator */
$validationFactory->extend(
'comma_seperated_integer',
function ($attribute, $value, $parameters) {
$pages = explode(',', $value);
foreach($pages as $page){
if (! is_numeric($page)) {
return false;
}
}
return true;
}
);
}
/**
* Determine if the Configuraion is authorized to make this request.
*
@ -50,7 +30,7 @@ class ConfigurationForm extends FormRequest
&& ! empty(request()->input('catalog.products.storefront.products_per_page'))
) {
$this->rules = [
'catalog.products.storefront.products_per_page' => 'comma_seperated_integer',
'catalog.products.storefront.products_per_page' => [new CommaSeperatedInteger],
];
}
@ -90,7 +70,6 @@ class ConfigurationForm extends FormRequest
{
return [
'general.design.admin_logo.logo_image.mimes' => 'Invalid file format. Use only bmp, jpeg, jpg, png and webp.',
'catalog.products.storefront.products_per_page.comma_seperated_integer' => 'The "Product Per Page" field must be numeric and may contain comma.'
];
}
@ -102,7 +81,8 @@ class ConfigurationForm extends FormRequest
return [
'general.design.admin_logo.logo_image' => 'Logo Image',
'general.design.admin_logo.favicon' => 'Favicon Image',
'sales.invoice_setttings.invoice_slip_design.logo' => 'Invoice Logo'
'sales.invoice_setttings.invoice_slip_design.logo' => 'Invoice Logo',
'catalog.products.storefront.products_per_page' => 'Product Per Page',
];
}
}

View File

@ -0,0 +1,57 @@
<?php
namespace Webkul\Admin\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class DuplicateInvoiceNotification extends Mailable
{
use Queueable, SerializesModels;
/**
* The invoice instance.
*
* @var \Webkul\Customer\Contracts\Invoice
*/
public $invoice;
/**
* Customer email.
*
* @var string
*/
public $customerEmail;
/**
* Create a new message instance.
*
* @param \Webkul\Customer\Contracts\Invoice $invoice
* @param string $customerEmail
* @return void
*/
public function __construct($invoice, $customerEmail)
{
$this->invoice = $invoice;
$this->customerEmail = $customerEmail;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$order = $this->invoice->order;
$email = $this->customerEmail ?? $order->customer_email;
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($email, $order->customer_full_name)
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-invoice');
}
}

View File

@ -85,7 +85,7 @@ class AdminServiceProvider extends ServiceProvider
*/
protected function composeView()
{
view()->composer(['admin::layouts.nav-left', 'admin::layouts.nav-aside', 'admin::layouts.tabs'], function ($view) {
view()->composer(['admin::layouts.nav-left','admin::layouts.tabs','admin::layouts.mobile-nav'], function ($view) {
$tree = Tree::create();
$permissionType = auth()->guard('admin')->user()->role->permission_type;

View File

@ -0,0 +1,7 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 11H7V13H5V11ZM8 11H10V13H8V11ZM11 11H13V13H11V11ZM14 11H16V13H14V11ZM17 11H19V13H17V11ZM5 14H7V16H5V14ZM8 14H10V16H8V14ZM11 14H13V16H11V14ZM14 14H16V16H14V14ZM17 14H19V16H17V14ZM14 17H16V19H14V17ZM5 17H7V19H5V17ZM8 17H10V19H8V17ZM11 17H13V19H11V17Z" fill="#9497B8"/>
<path d="M19 4H5C3.89543 4 3 4.89543 3 6V20C3 21.1046 3.89543 22 5 22H19C20.1046 22 21 21.1046 21 20V6C21 4.89543 20.1046 4 19 4Z" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M3 9H20.2234" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8.05518 2.0166V4" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M16 2V3.91915" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 960 B

View File

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 7H19" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M5 12H19" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M5 17H19" stroke="#9497B8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 408 B

View File

@ -0,0 +1 @@
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="0 0 28 28" xml:space="preserve"><style></style><path d="M15.4 14l7.9-7.9c.4-.4.4-1 0-1.4s-1-.4-1.4 0L14 12.6l-7.9-8c-.4-.4-1-.4-1.4 0s-.4 1 0 1.4l7.9 7.9-7.9 7.9c-.4.4-.4 1 0 1.4.2.2.5.3.7.3s.5-.1.7-.3l7.9-7.9 7.9 7.9c.2.2.5.3.7.3s.5-.1.7-.3c.4-.4.4-1 0-1.4L15.4 14z"/></svg>

After

Width:  |  Height:  |  Size: 363 B

View File

@ -0,0 +1,5 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 4L23 4" stroke="#3C41FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M1 12L23 12" stroke="#3C41FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M1 20L23 20" stroke="#3C41FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 416 B

Some files were not shown because too many files have changed in this diff Show More