Refactor code standard
This commit is contained in:
parent
f08a8036e6
commit
366a5fdd20
|
|
@ -106,7 +106,7 @@ class WishlistController extends Controller
|
|||
|
||||
$result = Cart::moveToCart($wishlistItem);
|
||||
|
||||
if ($result == 1) {
|
||||
if ($result) {
|
||||
if ($wishlistItem->delete()) {
|
||||
Cart::collectTotals();
|
||||
|
||||
|
|
@ -120,15 +120,10 @@ class WishlistController extends Controller
|
|||
'error' => trans('shop::app.wishlist.move-error')
|
||||
], 400);
|
||||
}
|
||||
} else if ($result == 0) {
|
||||
return response()->json([
|
||||
'data' => 0,
|
||||
'error' => trans('shop::app.wishlist.error')
|
||||
], 400);
|
||||
} else if ($result == -1) {
|
||||
} else {
|
||||
return response()->json([
|
||||
'data' => -1,
|
||||
'error' => trans('shop::app.checkout.cart.add-config-warning')
|
||||
'error' => trans('shop::app.wishlist.option-missing')
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
namespace Webkul\Admin\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Admin\Facades\Configuration;
|
||||
use Webkul\Core\Repositories\CoreConfigRepository as CoreConfig;
|
||||
use Webkul\Core\Repositories\CoreConfigRepository;
|
||||
use Webkul\Core\Tree;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
|
@ -28,7 +27,7 @@ class ConfigurationController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $coreConfig;
|
||||
protected $coreConfigRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -39,14 +38,14 @@ class ConfigurationController extends Controller
|
|||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\CoreConfigRepository $coreConfig
|
||||
* @param \Webkul\Core\Repositories\CoreConfigRepository $coreConfigRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CoreConfig $coreConfig)
|
||||
public function __construct(CoreConfigRepository $coreConfigRepository)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->coreConfig = $coreConfig;
|
||||
$this->coreConfigRepository = $coreConfigRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
|
|
@ -121,7 +120,7 @@ class ConfigurationController extends Controller
|
|||
{
|
||||
Event::fire('core.configuration.save.before');
|
||||
|
||||
$this->coreConfig->create(request()->all());
|
||||
$this->coreConfigRepository->create(request()->all());
|
||||
|
||||
Event::fire('core.configuration.save.after');
|
||||
|
||||
|
|
@ -141,7 +140,7 @@ class ConfigurationController extends Controller
|
|||
|
||||
$fileName = 'configuration/'. $path;
|
||||
|
||||
$config = $this->coreConfig->findOneByField('value', $fileName);
|
||||
$config = $this->coreConfigRepository->findOneByField('value', $fileName);
|
||||
|
||||
return Storage::download($config['value']);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Customer;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository as CustomerGroup;
|
||||
use Webkul\Core\Repositories\ChannelRepository as Channel;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository;
|
||||
use Webkul\Core\Repositories\ChannelRepository;
|
||||
|
||||
/**
|
||||
* Customer controlller
|
||||
|
|
@ -29,40 +27,44 @@ class CustomerController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customer;
|
||||
protected $customerRepository;
|
||||
|
||||
/**
|
||||
* CustomerGroupRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customerGroup;
|
||||
protected $customerGroupRepository;
|
||||
|
||||
/**
|
||||
* ChannelRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $channel;
|
||||
protected $channelRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroup
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channel
|
||||
* @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository
|
||||
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
|
||||
*/
|
||||
public function __construct(Customer $customer, CustomerGroup $customerGroup, Channel $channel)
|
||||
public function __construct(
|
||||
CustomerRepository $customerRepository,
|
||||
CustomerGroupRepository $customerGroupRepository,
|
||||
ChannelRepository $channelRepository
|
||||
)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->customer = $customer;
|
||||
$this->customerRepository = $customerRepository;
|
||||
|
||||
$this->customerGroup = $customerGroup;
|
||||
$this->customerGroupRepository = $customerGroupRepository;
|
||||
|
||||
$this->channel = $channel;
|
||||
$this->channelRepository = $channelRepository;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -83,9 +85,9 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$customerGroup = $this->customerGroup->findWhere([['code', '<>', 'guest']]);
|
||||
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
|
||||
|
||||
$channelName = $this->channel->all();
|
||||
$channelName = $this->channelRepository->all();
|
||||
|
||||
return view($this->_config['view'], compact('customerGroup','channelName'));
|
||||
}
|
||||
|
|
@ -114,7 +116,7 @@ class CustomerController extends Controller
|
|||
|
||||
$data['is_verified'] = 1;
|
||||
|
||||
$this->customer->create($data);
|
||||
$this->customerRepository->create($data);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer']));
|
||||
|
||||
|
|
@ -129,11 +131,11 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$customer = $this->customer->findOrFail($id);
|
||||
$customer = $this->customerRepository->findOrFail($id);
|
||||
|
||||
$customerGroup = $this->customerGroup->findWhere([['code', '<>', 'guest']]);
|
||||
$customerGroup = $this->customerGroupRepository->findWhere([['code', '<>', 'guest']]);
|
||||
|
||||
$channelName = $this->channel->all();
|
||||
$channelName = $this->channelRepository->all();
|
||||
|
||||
return view($this->_config['view'], compact('customer', 'customerGroup', 'channelName'));
|
||||
}
|
||||
|
|
@ -141,11 +143,10 @@ class CustomerController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'channel_id' => 'required',
|
||||
|
|
@ -156,7 +157,7 @@ class CustomerController extends Controller
|
|||
'date_of_birth' => 'date|before:today'
|
||||
]);
|
||||
|
||||
$this->customer->update(request()->all(), $id);
|
||||
$this->customerRepository->update(request()->all(), $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));
|
||||
|
||||
|
|
@ -171,10 +172,10 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$customer = $this->customer->findorFail($id);
|
||||
$customer = $this->customerRepository->findorFail($id);
|
||||
|
||||
try {
|
||||
$this->customer->delete($id);
|
||||
$this->customerRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer']));
|
||||
|
||||
|
|
@ -193,7 +194,7 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function createNote($id)
|
||||
{
|
||||
$customer = $this->customer->find($id);
|
||||
$customer = $this->customerRepository->find($id);
|
||||
|
||||
return view($this->_config['view'])->with('customer', $customer);
|
||||
}
|
||||
|
|
@ -209,7 +210,7 @@ class CustomerController extends Controller
|
|||
'notes' => 'string|nullable'
|
||||
]);
|
||||
|
||||
$customer = $this->customer->find(request()->input('_customer'));
|
||||
$customer = $this->customerRepository->find(request()->input('_customer'));
|
||||
|
||||
$noteTaken = $customer->update([
|
||||
'notes' => request()->input('notes')
|
||||
|
|
@ -235,7 +236,7 @@ class CustomerController extends Controller
|
|||
$updateOption = request()->input('update-options');
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$customer = $this->customer->find($customerId);
|
||||
$customer = $this->customerRepository->find($customerId);
|
||||
|
||||
$customer->update([
|
||||
'status' => $updateOption
|
||||
|
|
@ -257,7 +258,7 @@ class CustomerController extends Controller
|
|||
$customerIds = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$this->customer->deleteWhere([
|
||||
$this->customerRepository->deleteWhere([
|
||||
'id' => $customerId
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Customer;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository as CustomerGroup;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository;
|
||||
|
||||
/**
|
||||
* Customer Group controlller
|
||||
|
|
@ -27,21 +25,21 @@ class CustomerGroupController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customerGroup;
|
||||
protected $customerGroupRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\CustomerGroupRepository as customerGroup;
|
||||
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository;
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CustomerGroup $customerGroup)
|
||||
public function __construct(CustomerGroupRepository $customerGroupRepository)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->customerGroup = $customerGroup;
|
||||
$this->customerGroupRepository = $customerGroupRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -80,7 +78,7 @@ class CustomerGroupController extends Controller
|
|||
|
||||
$data['is_user_defined'] = 1;
|
||||
|
||||
$this->customerGroup->create($data);
|
||||
$this->customerGroupRepository->create($data);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Customer Group']));
|
||||
|
||||
|
|
@ -95,7 +93,7 @@ class CustomerGroupController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$group = $this->customerGroup->findOrFail($id);
|
||||
$group = $this->customerGroupRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('group'));
|
||||
}
|
||||
|
|
@ -103,18 +101,17 @@ class CustomerGroupController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:customer_groups,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
'name' => 'required',
|
||||
]);
|
||||
|
||||
$this->customerGroup->update(request()->all(), $id);
|
||||
$this->customerGroupRepository->update(request()->all(), $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer Group']));
|
||||
|
||||
|
|
@ -129,7 +126,7 @@ class CustomerGroupController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$customerGroup = $this->customerGroup->findOrFail($id);
|
||||
$customerGroup = $this->customerGroupRepository->findOrFail($id);
|
||||
|
||||
if ($customerGroup->is_user_defined == 0) {
|
||||
session()->flash('warning', trans('admin::app.customers.customers.group-default'));
|
||||
|
|
@ -137,7 +134,7 @@ class CustomerGroupController extends Controller
|
|||
session()->flash('warning', trans('admin::app.response.customer-associate', ['name' => 'Customer Group']));
|
||||
} else {
|
||||
try {
|
||||
$this->customerGroup->delete($id);
|
||||
$this->customerGroupRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer Group']));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
|
|
@ -30,56 +27,56 @@ class DashboardController extends Controller
|
|||
/**
|
||||
* OrderRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* OrderItemRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $orderItemRepository;
|
||||
|
||||
/**
|
||||
* CustomerRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $customerRepository;
|
||||
|
||||
/**
|
||||
* ProductInventoryRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $productInventoryRepository;
|
||||
|
||||
/**
|
||||
* string object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $startDate;
|
||||
|
||||
/**
|
||||
* string object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $lastStartDate;
|
||||
|
||||
/**
|
||||
* string object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $endDate;
|
||||
|
||||
/**
|
||||
* string object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $lastEndDate;
|
||||
|
||||
|
|
@ -112,6 +109,11 @@ class DashboardController extends Controller
|
|||
$this->productInventoryRepository = $productInventoryRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns percentage difference
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getPercentageChange($previous, $current)
|
||||
{
|
||||
if (! $previous)
|
||||
|
|
@ -171,7 +173,7 @@ class DashboardController extends Controller
|
|||
/**
|
||||
* Returns the list of top selling categories
|
||||
*
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTopSellingCategories()
|
||||
{
|
||||
|
|
@ -196,7 +198,7 @@ class DashboardController extends Controller
|
|||
/**
|
||||
* Return stock threshold.
|
||||
*
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function getStockThreshold()
|
||||
{
|
||||
|
|
@ -213,7 +215,7 @@ class DashboardController extends Controller
|
|||
|
||||
/**
|
||||
* Returns top selling products
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function getTopSellingProducts()
|
||||
{
|
||||
|
|
@ -232,7 +234,7 @@ class DashboardController extends Controller
|
|||
/**
|
||||
* Returns top selling products
|
||||
*
|
||||
* @return mixed
|
||||
* @return Collection
|
||||
*/
|
||||
public function getCustomerWithMostSales()
|
||||
{
|
||||
|
|
@ -273,16 +275,31 @@ class DashboardController extends Controller
|
|||
// $this->lastEndDate->subDays($this->lastStartDate->diffInDays($this->lastEndDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns previous order query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function previousOrders()
|
||||
{
|
||||
return $this->getOrdersBetweenDate($this->lastStartDate, $this->lastEndDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current order query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function currentOrders()
|
||||
{
|
||||
return $this->getOrdersBetweenDate($this->startDate, $this->endDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns orders between two dates
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getOrdersBetweenDate($start, $end)
|
||||
{
|
||||
return $this->orderRepository->scopeQuery(function ($query) use ($start, $end) {
|
||||
|
|
@ -290,6 +307,11 @@ class DashboardController extends Controller
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns customers between two dates
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function getCustomersBetweenDates($start, $end)
|
||||
{
|
||||
return $this->customerRepository->scopeQuery(function ($query) use ($start, $end) {
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Admin\DataGrids\TestDataGrid;
|
||||
|
||||
/**
|
||||
* TestDataGrid controller
|
||||
*
|
||||
* @author Nikhil Malik <nikhil@webkul.com> @ysmnikhil
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class DataGridController extends Controller
|
||||
{
|
||||
protected $_config;
|
||||
protected $testgrid;
|
||||
|
||||
public function __construct(TestDataGrid $testgrid)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->testgrid = $testgrid;
|
||||
}
|
||||
|
||||
public function massDelete() {
|
||||
dd(request()->all());
|
||||
}
|
||||
|
||||
public function massUpdate() {
|
||||
dd(request()->all());
|
||||
}
|
||||
|
||||
public function testGrid() {
|
||||
return $this->testgrid->render();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Admin\Exports\DataGridExport;
|
||||
use Excel;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Sales;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Sales\Repositories\OrderRepository as Order;
|
||||
use Webkul\Sales\Repositories\InvoiceRepository as Invoice;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
use Webkul\Sales\Repositories\InvoiceRepository;
|
||||
use PDF;
|
||||
|
||||
/**
|
||||
|
|
@ -29,31 +27,34 @@ class InvoiceController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order;
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* InvoiceRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $invoice;
|
||||
protected $invoiceRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Sales\Repositories\OrderRepository $order
|
||||
* @param \Webkul\Sales\Repositories\InvoiceRepository $invoice
|
||||
* @param \Webkul\Sales\Repositories\OrderRepository $orderRepository
|
||||
* @param \Webkul\Sales\Repositories\InvoiceRepository $invoiceRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Invoice $invoice, Order $order)
|
||||
public function __construct(
|
||||
OrderRepository $orderRepository,
|
||||
InvoiceRepository $invoiceRepository
|
||||
)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->order = $order;
|
||||
$this->orderRepository = $orderRepository;
|
||||
|
||||
$this->invoice = $invoice;
|
||||
$this->invoiceRepository = $invoiceRepository;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +76,7 @@ class InvoiceController extends Controller
|
|||
*/
|
||||
public function create($orderId)
|
||||
{
|
||||
$order = $this->order->findOrFail($orderId);
|
||||
$order = $this->orderRepository->findOrFail($orderId);
|
||||
|
||||
return view($this->_config['view'], compact('order'));
|
||||
}
|
||||
|
|
@ -84,12 +85,11 @@ class InvoiceController extends Controller
|
|||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param int $orderId
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request, $orderId)
|
||||
public function store($orderId)
|
||||
{
|
||||
$order = $this->order->findOrFail($orderId);
|
||||
$order = $this->orderRepository->findOrFail($orderId);
|
||||
|
||||
if (! $order->canInvoice()) {
|
||||
session()->flash('error', trans('admin::app.sales.invoices.creation-error'));
|
||||
|
|
@ -117,7 +117,7 @@ class InvoiceController extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
|
||||
$this->invoice->create(array_merge($data, ['order_id' => $orderId]));
|
||||
$this->invoiceRepository->create(array_merge($data, ['order_id' => $orderId]));
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Invoice']));
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class InvoiceController extends Controller
|
|||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$invoice = $this->invoice->findOrFail($id);
|
||||
$invoice = $this->invoiceRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('invoice'));
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ class InvoiceController extends Controller
|
|||
*/
|
||||
public function print($id)
|
||||
{
|
||||
$invoice = $this->invoice->findOrFail($id);
|
||||
$invoice = $this->invoiceRepository->findOrFail($id);
|
||||
|
||||
$pdf = PDF::loadView('admin::sales.invoices.pdf', compact('invoice'))->setPaper('a4');
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Sales;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Sales\Repositories\OrderRepository as Order;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
|
||||
/**
|
||||
* Sales Order controller
|
||||
|
|
@ -27,21 +25,21 @@ class OrderController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $order;
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Sales\Repositories\OrderRepository $order
|
||||
* @param \Webkul\Sales\Repositories\OrderRepository $orderRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
public function __construct(OrderRepository $orderRepository)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->order = $order;
|
||||
$this->orderRepository = $orderRepository;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +61,7 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$order = $this->order->findOrFail($id);
|
||||
$order = $this->orderRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('order'));
|
||||
}
|
||||
|
|
@ -76,7 +74,7 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function cancel($id)
|
||||
{
|
||||
$result = $this->order->cancel($id);
|
||||
$result = $this->orderRepository->cancel($id);
|
||||
|
||||
if ($result) {
|
||||
session()->flash('success', trans('admin::app.response.cancel-success', ['name' => 'Order']));
|
||||
|
|
|
|||
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
namespace Webkul\Admin\Http\Controllers\Sales;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Admin\Http\Controllers\Controller;
|
||||
use Webkul\Sales\Repositories\ShipmentRepository as Shipment;
|
||||
use Webkul\Sales\Repositories\OrderRepository as Order;
|
||||
use Webkul\Sales\Repositories\OrderItemRepository as OrderItem;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
use Webkul\Sales\Repositories\OrderItemRepository;
|
||||
use Webkul\Sales\Repositories\ShipmentRepository;
|
||||
|
||||
/**
|
||||
* Sales Shipment controller
|
||||
|
|
@ -24,51 +22,50 @@ class ShipmentController extends Controller
|
|||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* ShipmentRepository object
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $shipment;
|
||||
|
||||
/**
|
||||
* OrderRepository object
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $order;
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* OrderItemRepository object
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $orderItem;
|
||||
protected $orderItemRepository;
|
||||
|
||||
/**
|
||||
* ShipmentRepository object
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $shipmentRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Sales\Repositories\ShipmentRepository $shipment
|
||||
* @param \Webkul\Sales\Repositories\OrderRepository $order
|
||||
* @param \Webkul\Sales\Repositories\OrderitemRepository $orderItem
|
||||
* @param \Webkul\Sales\Repositories\ShipmentRepository $shipmentRepository
|
||||
* @param \Webkul\Sales\Repositories\OrderRepository $orderRepository
|
||||
* @param \Webkul\Sales\Repositories\OrderitemRepository $orderItemRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Shipment $shipment,
|
||||
Order $order,
|
||||
OrderItem $orderItem
|
||||
ShipmentRepository $shipmentRepository,
|
||||
OrderRepository $orderRepository,
|
||||
OrderItemRepository $orderItemRepository
|
||||
)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->order = $order;
|
||||
$this->orderRepository = $orderRepository;
|
||||
|
||||
$this->orderItem = $orderItem;
|
||||
|
||||
$this->shipment = $shipment;
|
||||
$this->orderItemRepository = $orderItemRepository;
|
||||
|
||||
$this->shipmentRepository = $shipmentRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -89,7 +86,7 @@ class ShipmentController extends Controller
|
|||
*/
|
||||
public function create($orderId)
|
||||
{
|
||||
$order = $this->order->findOrFail($orderId);
|
||||
$order = $this->orderRepository->findOrFail($orderId);
|
||||
|
||||
if (! $order->channel || !$order->canShip()) {
|
||||
session()->flash('error', trans('admin::app.sales.shipments.creation-error'));
|
||||
|
|
@ -104,12 +101,11 @@ class ShipmentController extends Controller
|
|||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param int $orderId
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request, $orderId)
|
||||
public function store($orderId)
|
||||
{
|
||||
$order = $this->order->findOrFail($orderId);
|
||||
$order = $this->orderRepository->findOrFail($orderId);
|
||||
|
||||
if (! $order->canShip()) {
|
||||
session()->flash('error', trans('admin::app.sales.shipments.order-error'));
|
||||
|
|
@ -132,7 +128,7 @@ class ShipmentController extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
|
||||
$this->shipment->create(array_merge($data, ['order_id' => $orderId]));
|
||||
$this->shipmentRepository->create(array_merge($data, ['order_id' => $orderId]));
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Shipment']));
|
||||
|
||||
|
|
@ -154,7 +150,7 @@ class ShipmentController extends Controller
|
|||
|
||||
foreach ($data['shipment']['items'] as $itemId => $inventorySource) {
|
||||
if ($qty = $inventorySource[$data['shipment']['source']]) {
|
||||
$orderItem = $this->orderItem->find($itemId);
|
||||
$orderItem = $this->orderItemRepository->find($itemId);
|
||||
|
||||
$product = ($orderItem->type == 'configurable')
|
||||
? $orderItem->child->product
|
||||
|
|
@ -185,7 +181,7 @@ class ShipmentController extends Controller
|
|||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$shipment = $this->shipment->findOrFail($id);
|
||||
$shipment = $this->shipmentRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('shipment'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,12 +130,12 @@
|
|||
<div class="graph-stats">
|
||||
|
||||
<div class="left-card-container graph">
|
||||
<div class="card">
|
||||
<div class="card" style="overflow: hidden;">
|
||||
<div class="card-title" style="margin-bottom: 30px;">
|
||||
{{ __('admin::app.dashboard.sales') }}
|
||||
</div>
|
||||
|
||||
<div class="card-info">
|
||||
<div class="card-info" style="height: 100%;">
|
||||
|
||||
<canvas id="myChart" style="width: 100%; height: 87%"></canvas>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Attribute\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
|
||||
use Event;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
/**
|
||||
* Catalog attribute controller
|
||||
|
|
@ -27,17 +25,17 @@ class AttributeController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attribute;
|
||||
protected $attributeRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Attribute $attribute)
|
||||
public function __construct(AttributeRepository $attributeRepository)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
$this->attributeRepository = $attributeRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -79,7 +77,7 @@ class AttributeController extends Controller
|
|||
|
||||
$data['is_user_defined'] = 1;
|
||||
|
||||
$attribute = $this->attribute->create($data);
|
||||
$attribute = $this->attributeRepository->create($data);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Attribute']));
|
||||
|
||||
|
|
@ -94,7 +92,7 @@ class AttributeController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$attribute = $this->attribute->findOrFail($id);
|
||||
$attribute = $this->attributeRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('attribute'));
|
||||
}
|
||||
|
|
@ -102,11 +100,10 @@ class AttributeController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:attributes,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
|
|
@ -114,7 +111,7 @@ class AttributeController extends Controller
|
|||
'type' => 'required'
|
||||
]);
|
||||
|
||||
$attribute = $this->attribute->update(request()->all(), $id);
|
||||
$attribute = $this->attributeRepository->update(request()->all(), $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Attribute']));
|
||||
|
||||
|
|
@ -129,13 +126,13 @@ class AttributeController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$attribute = $this->attribute->findOrFail($id);
|
||||
$attribute = $this->attributeRepository->findOrFail($id);
|
||||
|
||||
if (! $attribute->is_user_defined) {
|
||||
session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'Attribute']));
|
||||
} else {
|
||||
try {
|
||||
$this->attribute->delete($id);
|
||||
$this->attributeRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Attribute']));
|
||||
|
||||
|
|
@ -161,13 +158,13 @@ class AttributeController extends Controller
|
|||
$indexes = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($indexes as $key => $value) {
|
||||
$attribute = $this->attribute->find($value);
|
||||
$attribute = $this->attributeRepository->find($value);
|
||||
|
||||
try {
|
||||
if (! $attribute->is_user_defined) {
|
||||
continue;
|
||||
} else {
|
||||
$this->attribute->delete($value);
|
||||
$this->attributeRepository->delete($value);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$suppressFlash = true;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
namespace Webkul\Attribute\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
|
||||
|
||||
use Webkul\Attribute\Repositories\AttributeFamilyRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
/**
|
||||
* Catalog family controller
|
||||
|
|
@ -26,19 +23,32 @@ class AttributeFamilyController extends Controller
|
|||
/**
|
||||
* AttributeFamilyRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $attributeFamily;
|
||||
protected $attributeFamilyRepository;
|
||||
|
||||
/**
|
||||
* AttributeRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $attributeRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Attribute\Repositories\AttributeFamilyRepository $attributeFamily
|
||||
* @param \Webkul\Attribute\Repositories\AttributeFamilyRepository $attributeFamilyRepository
|
||||
* @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AttributeFamily $attributeFamily)
|
||||
public function __construct(
|
||||
AttributeFamilyRepository $attributeFamilyRepository,
|
||||
AttributeRepository $attributeRepository
|
||||
)
|
||||
{
|
||||
$this->attributeFamily = $attributeFamily;
|
||||
$this->attributeFamilyRepository = $attributeFamilyRepository;
|
||||
|
||||
$this->attributeRepository = $attributeRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -56,14 +66,13 @@ class AttributeFamilyController extends Controller
|
|||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create(Attribute $attribute)
|
||||
public function create()
|
||||
{
|
||||
$attributeFamily = $this->attributeFamily->with(['attribute_groups.custom_attributes'])->findOneByField('code', 'default');
|
||||
$attributeFamily = $this->attributeFamilyRepository->with(['attribute_groups.custom_attributes'])->findOneByField('code', 'default');
|
||||
|
||||
$custom_attributes = $attribute->all(['id', 'code', 'admin_name', 'type']);
|
||||
$custom_attributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
|
||||
|
||||
return view($this->_config['view'], compact('custom_attributes', 'attributeFamily'));
|
||||
}
|
||||
|
|
@ -80,7 +89,7 @@ class AttributeFamilyController extends Controller
|
|||
'name' => 'required'
|
||||
]);
|
||||
|
||||
$attributeFamily = $this->attributeFamily->create(request()->all());
|
||||
$attributeFamily = $this->attributeFamilyRepository->create(request()->all());
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Family']));
|
||||
|
||||
|
|
@ -90,15 +99,14 @@ class AttributeFamilyController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Attribute $attribute, $id)
|
||||
public function edit($id)
|
||||
{
|
||||
$attributeFamily = $this->attributeFamily->with(['attribute_groups.custom_attributes'])->findOrFail($id, ['*']);
|
||||
$attributeFamily = $this->attributeFamilyRepository->with(['attribute_groups.custom_attributes'])->findOrFail($id, ['*']);
|
||||
|
||||
$custom_attributes = $attribute->all(['id', 'code', 'admin_name', 'type']);
|
||||
$custom_attributes = $this->attributeRepository->all(['id', 'code', 'admin_name', 'type']);
|
||||
|
||||
return view($this->_config['view'], compact('attributeFamily', 'custom_attributes'));
|
||||
}
|
||||
|
|
@ -106,18 +114,17 @@ class AttributeFamilyController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:attribute_families,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
'name' => 'required'
|
||||
]);
|
||||
|
||||
$attributeFamily = $this->attributeFamily->update(request()->all(), $id);
|
||||
$attributeFamily = $this->attributeFamilyRepository->update(request()->all(), $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Family']));
|
||||
|
||||
|
|
@ -132,16 +139,16 @@ class AttributeFamilyController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$attributeFamily = $this->attributeFamily->findOrFail($id);
|
||||
$attributeFamily = $this->attributeFamilyRepository->findOrFail($id);
|
||||
|
||||
if ($this->attributeFamily->count() == 1) {
|
||||
if ($this->attributeFamilyRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Family']));
|
||||
|
||||
} else if ($attributeFamily->products()->count()) {
|
||||
session()->flash('error', trans('admin::app.response.attribute-product-error', ['name' => 'Attribute family']));
|
||||
} else {
|
||||
try {
|
||||
$this->attributeFamily->delete($id);
|
||||
$this->attributeFamilyRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Family']));
|
||||
|
||||
|
|
@ -159,7 +166,8 @@ class AttributeFamilyController extends Controller
|
|||
*
|
||||
* @return response \Illuminate\Http\Response
|
||||
*/
|
||||
public function massDestroy() {
|
||||
public function massDestroy()
|
||||
{
|
||||
$suppressFlash = false;
|
||||
|
||||
if (request()->isMethod('delete')) {
|
||||
|
|
@ -167,7 +175,7 @@ class AttributeFamilyController extends Controller
|
|||
|
||||
foreach ($indexes as $key => $value) {
|
||||
try {
|
||||
$this->attributeFamily->delete($value);
|
||||
$this->attributeFamilyRepository->delete($value);
|
||||
} catch (\Exception $e) {
|
||||
$suppressFlash = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,29 +19,33 @@ class AttributeFamilyRepository extends Repository
|
|||
/**
|
||||
* AttributeRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $attribute;
|
||||
protected $attributeRepository;
|
||||
|
||||
/**
|
||||
* AttributeGroupRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $attributeGroup;
|
||||
protected $attributeGroupRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @param Webkul\Attribute\Repositories\AttributeGroupRepository $attributeGroup
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param Webkul\Attribute\Repositories\AttributeGroupRepository $attributeGroupRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AttributeRepository $attribute, AttributeGroupRepository $attributeGroup, App $app)
|
||||
public function __construct(
|
||||
AttributeRepository $attributeRepository,
|
||||
AttributeGroupRepository $attributeGroupRepository,
|
||||
App $app
|
||||
)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
$this->attributeRepository = $attributeRepository;
|
||||
|
||||
$this->attributeGroup = $attributeGroup;
|
||||
$this->attributeGroupRepository = $attributeGroupRepository;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
|
@ -75,9 +79,9 @@ class AttributeFamilyRepository extends Repository
|
|||
|
||||
foreach ($custom_attributes as $key => $attribute) {
|
||||
if (isset($attribute['id'])) {
|
||||
$attributeModel = $this->attribute->find($attribute['id']);
|
||||
$attributeModel = $this->attributeRepository->find($attribute['id']);
|
||||
} else {
|
||||
$attributeModel = $this->attribute->findOneByField('code', $attribute['code']);
|
||||
$attributeModel = $this->attributeRepository->findOneByField('code', $attribute['code']);
|
||||
}
|
||||
|
||||
$attributeGroup->custom_attributes()->save($attributeModel, ['position' => $key + 1]);
|
||||
|
|
@ -112,7 +116,7 @@ class AttributeFamilyRepository extends Repository
|
|||
|
||||
if (isset($attributeGroupInputs['custom_attributes'])) {
|
||||
foreach ($attributeGroupInputs['custom_attributes'] as $key => $attribute) {
|
||||
$attributeModel = $this->attribute->find($attribute['id']);
|
||||
$attributeModel = $this->attributeRepository->find($attribute['id']);
|
||||
$attributeGroup->custom_attributes()->save($attributeModel, ['position' => $key + 1]);
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +125,7 @@ class AttributeFamilyRepository extends Repository
|
|||
$previousAttributeGroupIds->forget($index);
|
||||
}
|
||||
|
||||
$attributeGroup = $this->attributeGroup->find($attributeGroupId);
|
||||
$attributeGroup = $this->attributeGroupRepository->find($attributeGroupId);
|
||||
$attributeGroup->update($attributeGroupInputs);
|
||||
|
||||
$attributeIds = $attributeGroup->custom_attributes()->get()->pluck('id');
|
||||
|
|
@ -131,7 +135,7 @@ class AttributeFamilyRepository extends Repository
|
|||
if (is_numeric($index = $attributeIds->search($attribute['id']))) {
|
||||
$attributeIds->forget($index);
|
||||
} else {
|
||||
$attributeModel = $this->attribute->find($attribute['id']);
|
||||
$attributeModel = $this->attributeRepository->find($attribute['id']);
|
||||
$attributeGroup->custom_attributes()->save($attributeModel, ['position' => $key + 1]);
|
||||
}
|
||||
}
|
||||
|
|
@ -145,7 +149,7 @@ class AttributeFamilyRepository extends Repository
|
|||
}
|
||||
|
||||
foreach ($previousAttributeGroupIds as $attributeGroupId) {
|
||||
$this->attributeGroup->delete($attributeGroupId);
|
||||
$this->attributeGroupRepository->delete($attributeGroupId);
|
||||
}
|
||||
|
||||
Event::fire('catalog.attribute_family.update.after', $family);
|
||||
|
|
@ -158,7 +162,7 @@ class AttributeFamilyRepository extends Repository
|
|||
$attributeFamilies = $this->model->all();
|
||||
$trimmed = array();
|
||||
|
||||
foreach($attributeFamilies as $key => $attributeFamily) {
|
||||
foreach ($attributeFamilies as $key => $attributeFamily) {
|
||||
if ($attributeFamily->name != null || $attributeFamily->name != "") {
|
||||
$trimmed[$key] = [
|
||||
'id' => $attributeFamily->id,
|
||||
|
|
|
|||
|
|
@ -18,19 +18,22 @@ class AttributeRepository extends Repository
|
|||
/**
|
||||
* AttributeOptionRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $attributeOption;
|
||||
protected $attributeOptionRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOption
|
||||
* @param Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOptionRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AttributeOptionRepository $attributeOption, App $app)
|
||||
public function __construct(
|
||||
AttributeOptionRepository $attributeOptionRepository,
|
||||
App $app
|
||||
)
|
||||
{
|
||||
$this->attributeOption = $attributeOption;
|
||||
$this->attributeOptionRepository = $attributeOptionRepository;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
|
@ -61,7 +64,7 @@ class AttributeRepository extends Repository
|
|||
|
||||
if (in_array($attribute->type, ['select', 'multiselect', 'checkbox']) && count($options)) {
|
||||
foreach ($options as $optionInputs) {
|
||||
$this->attributeOption->create(array_merge([
|
||||
$this->attributeOptionRepository->create(array_merge([
|
||||
'attribute_id' => $attribute->id
|
||||
], $optionInputs));
|
||||
}
|
||||
|
|
@ -94,7 +97,7 @@ class AttributeRepository extends Repository
|
|||
if (isset($data['options'])) {
|
||||
foreach ($data['options'] as $optionId => $optionInputs) {
|
||||
if (str_contains($optionId, 'option_')) {
|
||||
$this->attributeOption->create(array_merge([
|
||||
$this->attributeOptionRepository->create(array_merge([
|
||||
'attribute_id' => $attribute->id,
|
||||
], $optionInputs));
|
||||
} else {
|
||||
|
|
@ -102,14 +105,14 @@ class AttributeRepository extends Repository
|
|||
$previousOptionIds->forget($index);
|
||||
}
|
||||
|
||||
$this->attributeOption->update($optionInputs, $optionId);
|
||||
$this->attributeOptionRepository->update($optionInputs, $optionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($previousOptionIds as $optionId) {
|
||||
$this->attributeOption->delete($optionId);
|
||||
$this->attributeOptionRepository->delete($optionId);
|
||||
}
|
||||
|
||||
Event::fire('catalog.attribute.update.after', $attribute);
|
||||
|
|
@ -166,7 +169,7 @@ class AttributeRepository extends Repository
|
|||
{
|
||||
$attributeColumns = ['id', 'code', 'value_per_channel', 'value_per_locale', 'type', 'is_filterable'];
|
||||
|
||||
if (! is_array($codes) && !$codes)
|
||||
if (! is_array($codes) && ! $codes)
|
||||
return $this->findWhereIn('code', [
|
||||
'name',
|
||||
'description',
|
||||
|
|
@ -220,7 +223,12 @@ class AttributeRepository extends Repository
|
|||
$trimmed = array();
|
||||
|
||||
foreach($attributes as $key => $attribute) {
|
||||
if ($attribute->code != 'tax_category_id' && ($attribute->type == 'select' || $attribute->type == 'multiselect' || $attribute->code == 'sku')) {
|
||||
if ($attribute->code != 'tax_category_id'
|
||||
&& (
|
||||
$attribute->type == 'select'
|
||||
|| $attribute->type == 'multiselect'
|
||||
|| $attribute->code == 'sku'
|
||||
)) {
|
||||
array_push($trimmed, [
|
||||
'id' => $attribute->id,
|
||||
'name' => $attribute->name,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Webkul\Category\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Category\Repositories\CategoryRepository as Category;
|
||||
use Webkul\Category\Repositories\CategoryRepository;
|
||||
use Webkul\Category\Models\CategoryTranslation;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
|
|
@ -28,17 +26,17 @@ class CategoryController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $category;
|
||||
protected $categoryRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Category\Repositories\CategoryRepository $category
|
||||
* @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Category $category)
|
||||
public function __construct(CategoryRepository $categoryRepository)
|
||||
{
|
||||
$this->category = $category;
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -60,7 +58,7 @@ class CategoryController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$categories = $this->category->getCategoryTree(null, ['id']);
|
||||
$categories = $this->categoryRepository->getCategoryTree(null, ['id']);
|
||||
|
||||
return view($this->_config['view'], compact('categories'));
|
||||
}
|
||||
|
|
@ -91,7 +89,7 @@ class CategoryController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$category = $this->category->create(request()->all());
|
||||
$category = $this->categoryRepository->create(request()->all());
|
||||
|
||||
session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Category']));
|
||||
|
||||
|
|
@ -106,9 +104,9 @@ class CategoryController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$categories = $this->category->getCategoryTree($id);
|
||||
$categories = $this->categoryRepository->getCategoryTree($id);
|
||||
|
||||
$category = $this->category->findOrFail($id);
|
||||
$category = $this->categoryRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('category', 'categories'));
|
||||
}
|
||||
|
|
@ -116,17 +114,16 @@ class CategoryController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
$this->validate(request(), [
|
||||
$locale . '.slug' => ['required', new \Webkul\Core\Contracts\Validations\Slug, function ($attribute, $value, $fail) use ($id) {
|
||||
if (! $this->category->isSlugUnique($id, $value)) {
|
||||
if (! $this->categoryRepository->isSlugUnique($id, $value)) {
|
||||
$fail(trans('admin::app.response.already-taken', ['name' => 'Category']));
|
||||
}
|
||||
}],
|
||||
|
|
@ -134,7 +131,7 @@ class CategoryController extends Controller
|
|||
'image.*' => 'mimes:jpeg,jpg,bmp,png'
|
||||
]);
|
||||
|
||||
$this->category->update(request()->all(), $id);
|
||||
$this->categoryRepository->update(request()->all(), $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Category']));
|
||||
|
||||
|
|
@ -149,7 +146,7 @@ class CategoryController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$category = $this->category->findOrFail($id);
|
||||
$category = $this->categoryRepository->findOrFail($id);
|
||||
|
||||
if(strtolower($category->name) == "root") {
|
||||
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
|
||||
|
|
@ -157,7 +154,7 @@ class CategoryController extends Controller
|
|||
try {
|
||||
Event:: fire('catalog.category.delete.before', $id);
|
||||
|
||||
$this->category->delete($id);
|
||||
$this->categoryRepository->delete($id);
|
||||
|
||||
Event::fire('catalog.category.delete.after', $id);
|
||||
|
||||
|
|
@ -187,7 +184,7 @@ class CategoryController extends Controller
|
|||
try {
|
||||
Event::fire('catalog.category.delete.before', $value);
|
||||
|
||||
$this->category->delete($value);
|
||||
$this->categoryRepository->delete($value);
|
||||
|
||||
Event::fire('catalog.category.delete.after', $value);
|
||||
} catch(\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace Webkul\Checkout;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Webkul\Checkout\Repositories\CartRepository;
|
||||
use Webkul\Checkout\Repositories\CartItemRepository;
|
||||
use Webkul\Checkout\Repositories\CartAddressRepository;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository;
|
||||
use Webkul\Checkout\Models\CartItem;
|
||||
|
|
@ -29,61 +27,49 @@ class Cart {
|
|||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $cart;
|
||||
protected $cartRepository;
|
||||
|
||||
/**
|
||||
* CartItemRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $cartItem;
|
||||
|
||||
/**
|
||||
* CustomerRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $customer;
|
||||
protected $cartItemRepository;
|
||||
|
||||
/**
|
||||
* CartAddressRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $cartAddress;
|
||||
protected $cartAddressRepository;
|
||||
|
||||
/**
|
||||
* ProductRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $product;
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* TaxCategoryRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $taxCategory;
|
||||
protected $taxCategoryRepository;
|
||||
|
||||
/**
|
||||
* WishlistRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $wishlist;
|
||||
protected $wishlistRepository;
|
||||
|
||||
/**
|
||||
* CustomerAddressRepository instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $customerAddress;
|
||||
|
||||
/**
|
||||
* Suppress the session flash messages
|
||||
*/
|
||||
protected $suppressFlash;
|
||||
protected $customerAddressRepository;
|
||||
|
||||
/**
|
||||
* Product price helper instance
|
||||
|
|
@ -93,49 +79,43 @@ class Cart {
|
|||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Checkout\Repositories\CartRepository $cart
|
||||
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItem
|
||||
* @param Webkul\Checkout\Repositories\CartAddressRepository $cartAddress
|
||||
* @param Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @param Webkul\Product\Repositories\TaxCategoryRepository $taxCategory
|
||||
* @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress
|
||||
* @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress
|
||||
* @param Webkul\Discount\Repositories\CartRuleRepository $cartRule
|
||||
* @param Webkul\Helpers\Discount $discount
|
||||
* @param Webkul\Checkout\Repositories\CartRepository $cart
|
||||
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItem
|
||||
* @param Webkul\Checkout\Repositories\CartAddressRepository $cartAddress
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @param Webkul\Product\Repositories\TaxCategoryRepository $taxCategory
|
||||
* @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress
|
||||
* @param Webkul\Product\Repositories\CustomerAddressRepository $customerAddress
|
||||
* @param Webkul\Discount\Repositories\CartRuleRepository $cartRule
|
||||
* @param Webkul\Helpers\Discount $discount
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
CartRepository $cart,
|
||||
CartItemRepository $cartItem,
|
||||
CartAddressRepository $cartAddress,
|
||||
CustomerRepository $customer,
|
||||
ProductRepository $product,
|
||||
TaxCategoryRepository $taxCategory,
|
||||
WishlistRepository $wishlist,
|
||||
CustomerAddressRepository $customerAddress,
|
||||
CartRepository $cartRepository,
|
||||
CartItemRepository $cartItemRepository,
|
||||
CartAddressRepository $cartAddressRepository,
|
||||
ProductRepository $productRepository,
|
||||
TaxCategoryRepository $taxCategoryRepository,
|
||||
WishlistRepository $wishlistRepository,
|
||||
CustomerAddressRepository $customerAddressRepository,
|
||||
Price $price
|
||||
)
|
||||
{
|
||||
$this->customer = $customer;
|
||||
$this->cartRepository = $cartRepository;
|
||||
|
||||
$this->cart = $cart;
|
||||
$this->cartItemRepository = $cartItemRepository;
|
||||
|
||||
$this->cartItem = $cartItem;
|
||||
$this->cartAddressRepository = $cartAddressRepository;
|
||||
|
||||
$this->cartAddress = $cartAddress;
|
||||
$this->productRepository = $productRepository;
|
||||
|
||||
$this->product = $product;
|
||||
$this->taxCategoryRepository = $taxCategoryRepository;
|
||||
|
||||
$this->taxCategory = $taxCategory;
|
||||
$this->wishlistRepository = $wishlistRepository;
|
||||
|
||||
$this->wishlist = $wishlist;
|
||||
|
||||
$this->customerAddress = $customerAddress;
|
||||
$this->customerAddressRepository = $customerAddressRepository;
|
||||
|
||||
$this->price = $price;
|
||||
|
||||
$this->suppressFlash = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -162,13 +142,9 @@ class Cart {
|
|||
{
|
||||
$cartData = [
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
|
||||
'global_currency_code' => core()->getBaseCurrencyCode(),
|
||||
|
||||
'base_currency_code' => core()->getBaseCurrencyCode(),
|
||||
|
||||
'channel_currency_code' => core()->getChannelBaseCurrencyCode(),
|
||||
|
||||
'cart_currency_code' => core()->getCurrentCurrencyCode(),
|
||||
'items_count' => 1
|
||||
];
|
||||
|
|
@ -184,7 +160,7 @@ class Cart {
|
|||
$cartData['is_guest'] = 1;
|
||||
}
|
||||
|
||||
$result = $this->cart->create($cartData);
|
||||
$result = $this->cartRepository->create($cartData);
|
||||
|
||||
$this->putCart($result);
|
||||
|
||||
|
|
@ -214,7 +190,7 @@ class Cart {
|
|||
$ifExists = $this->checkIfItemExists($id, $data);
|
||||
|
||||
if ($ifExists) {
|
||||
$item = $this->cartItem->findOneByField('id', $ifExists);
|
||||
$item = $this->cartItemRepository->findOneByField('id', $ifExists);
|
||||
|
||||
$data['quantity'] = $data['quantity'] + $item->quantity;
|
||||
|
||||
|
|
@ -240,10 +216,10 @@ class Cart {
|
|||
|
||||
foreach ($items as $item) {
|
||||
if ($id == $item->product_id) {
|
||||
$product = $this->product->findOnebyField('id', $id);
|
||||
$product = $this->productRepository->findOnebyField('id', $id);
|
||||
|
||||
if ($product->type == 'configurable') {
|
||||
$variant = $this->product->findOneByField('id', $data['selected_configurable_option']);
|
||||
$variant = $this->productRepository->findOneByField('id', $data['selected_configurable_option']);
|
||||
|
||||
if ($item->child->product_id == $data['selected_configurable_option'])
|
||||
return $item->id;
|
||||
|
|
@ -268,14 +244,14 @@ class Cart {
|
|||
{
|
||||
$childProduct = $configurable = false;
|
||||
|
||||
$product = $this->product->findOneByField('id', $id);
|
||||
$product = $this->productRepository->findOneByField('id', $id);
|
||||
|
||||
if ($product->type == 'configurable') {
|
||||
if (! isset($data['selected_configurable_option']) || ! $data['selected_configurable_option']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$childProduct = $this->product->findOneByField('id', $data['selected_configurable_option']);
|
||||
$childProduct = $this->productRepository->findOneByField('id', $data['selected_configurable_option']);
|
||||
|
||||
if (! $childProduct->haveSufficientQuantity($data['quantity'])) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
|
|
@ -351,12 +327,12 @@ class Cart {
|
|||
$parentData['additional'] = array_merge($parentData['additional'], ['link_lables' => $this->getDownloadableDetails($product)]);
|
||||
}
|
||||
|
||||
$item = $this->cartItem->create($parentData);
|
||||
$item = $this->cartItemRepository->create($parentData);
|
||||
|
||||
if (is_array($childData)) {
|
||||
$childData['parent_id'] = $item->id;
|
||||
|
||||
$this->cartItem->create($childData);
|
||||
$this->cartItemRepository->create($childData);
|
||||
}
|
||||
|
||||
return $item;
|
||||
|
|
@ -372,16 +348,12 @@ class Cart {
|
|||
*/
|
||||
public function updateItem($id, $data, $itemId)
|
||||
{
|
||||
$item = $this->cartItem->findOneByField('id', $itemId);
|
||||
$item = $this->cartItemRepository->findOneByField('id', $itemId);
|
||||
|
||||
if (isset($data['product'])) {
|
||||
$additional = $data;
|
||||
} else {
|
||||
$additional = $item->additional;
|
||||
}
|
||||
$additional = isset($data['product']) ? $data : $item->additional;
|
||||
|
||||
if ($item->type == 'configurable') {
|
||||
$product = $this->product->findOneByField('id', $item->child->product_id);
|
||||
$product = $this->productRepository->findOneByField('id', $item->child->product_id);
|
||||
|
||||
if (! $product->haveSufficientQuantity($data['quantity'])) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
|
|
@ -396,7 +368,7 @@ class Cart {
|
|||
} else if ($item->type == 'downloadable') {
|
||||
$additional = array_merge($additional, ['link_lables' => $this->getDownloadableDetails($item)]);
|
||||
} else {
|
||||
$product = $this->product->findOneByField('id', $item->product_id);
|
||||
$product = $this->productRepository->findOneByField('id', $item->product_id);
|
||||
|
||||
if ($product->isStockable() && ! $product->haveSufficientQuantity($data['quantity'])) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
|
|
@ -437,11 +409,11 @@ class Cart {
|
|||
public function removeItem($itemId)
|
||||
{
|
||||
if ($cart = $this->getCart()) {
|
||||
$this->cartItem->delete($itemId);
|
||||
$this->cartItemRepository->delete($itemId);
|
||||
|
||||
//delete the cart instance if no items are there
|
||||
if ($cart->items()->get()->count() == 0) {
|
||||
$this->cart->delete($cart->id);
|
||||
$this->cartRepository->delete($cart->id);
|
||||
|
||||
// $this->deActivateCart();
|
||||
if (session()->has('cart')) {
|
||||
|
|
@ -465,13 +437,9 @@ class Cart {
|
|||
public function mergeCart()
|
||||
{
|
||||
if (session()->has('cart')) {
|
||||
$cart = $this->cart->findWhere(['customer_id' => $this->getCurrentCustomer()->user()->id, 'is_active' => 1]);
|
||||
$cart = $this->cartRepository->findWhere(['customer_id' => $this->getCurrentCustomer()->user()->id, 'is_active' => 1]);
|
||||
|
||||
if ($cart->count()) {
|
||||
$cart = $cart->first();
|
||||
} else {
|
||||
$cart = false;
|
||||
}
|
||||
$cart = $cart->count() ? $cart->first() : false;
|
||||
|
||||
$guestCart = session()->get('cart');
|
||||
|
||||
|
|
@ -494,62 +462,63 @@ class Cart {
|
|||
|
||||
$guestCartId = $guestCart->id;
|
||||
|
||||
$guestCartItems = $this->cart->findOneByField('id', $guestCartId)->items;
|
||||
$guestCartItems = $this->cartRepository->findOneByField('id', $guestCartId)->items;
|
||||
|
||||
foreach ($guestCartItems as $key => $guestCartItem) {
|
||||
foreach ($cartItems as $cartItem) {
|
||||
|
||||
if ($guestCartItem->type == "simple") {
|
||||
if ($cartItem->product_id == $guestCartItem->product_id) {
|
||||
$prevQty = $cartItem->quantity;
|
||||
$newQty = $guestCartItem->quantity;
|
||||
|
||||
$product = $this->product->findOneByField('id', $cartItem->product_id);
|
||||
|
||||
if ($product->isStockable() && ! $product->haveSufficientQuantity($prevQty + $newQty)) {
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['quantity'] = $newQty + $prevQty;
|
||||
|
||||
$this->updateItem($cartItem->product_id, $data, $cartItem->id);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
}
|
||||
} else if ($guestCartItem->type == "configurable" && $cartItem->type == "configurable") {
|
||||
if ($guestCartItem->type == "configurable" && $cartItem->type == "configurable") {
|
||||
$guestCartItemChild = $guestCartItem->child;
|
||||
|
||||
$cartItemChild = $cartItem->child;
|
||||
|
||||
if ($guestCartItemChild->product_id == $cartItemChild->product_id) {
|
||||
$prevQty = $guestCartItem->quantity;
|
||||
$newQty = $cartItem->quantity;
|
||||
if ($guestCartItemChild->product_id != $cartItemChild->product_id)
|
||||
continue;
|
||||
|
||||
$product = $this->product->findOneByField('id', $cartItem->child->product_id);
|
||||
$prevQty = $guestCartItem->quantity;
|
||||
$newQty = $cartItem->quantity;
|
||||
|
||||
if ($product->isStockable() && ! $product->haveSufficientQuantity($prevQty + $newQty)) {
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
continue;
|
||||
}
|
||||
$product = $this->productRepository->findOneByField('id', $cartItem->child->product_id);
|
||||
|
||||
$data['quantity'] = $newQty + $prevQty;
|
||||
|
||||
$this->updateItem($cartItem->product_id, $data, $cartItem->id);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
if ($product->isStockable() && ! $product->haveSufficientQuantity($prevQty + $newQty)) {
|
||||
$this->cartItemRepository->delete($guestCartItem->id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['quantity'] = $newQty + $prevQty;
|
||||
|
||||
$this->updateItem($cartItem->product_id, $data, $cartItem->id);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
|
||||
$this->cartItemRepository->delete($guestCartItem->id);
|
||||
} else {
|
||||
if ($cartItem->product_id == $guestCartItem->product_id)
|
||||
continue;
|
||||
|
||||
$prevQty = $cartItem->quantity;
|
||||
$newQty = $guestCartItem->quantity;
|
||||
|
||||
$product = $this->productRepository->findOneByField('id', $cartItem->product_id);
|
||||
|
||||
if ($product->isStockable() && ! $product->haveSufficientQuantity($prevQty + $newQty)) {
|
||||
$this->cartItemRepository->delete($guestCartItem->id);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['quantity'] = $newQty + $prevQty;
|
||||
|
||||
$this->updateItem($cartItem->product_id, $data, $cartItem->id);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
$this->cartItemRepository->delete($guestCartItem->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//now handle the products that are not removed from the list of items in the guest cart.
|
||||
foreach ($guestCartItems as $guestCartItem) {
|
||||
|
||||
if ($guestCartItem->type == "configurable") {
|
||||
$guestCartItem->update(['cart_id' => $cart->id]);
|
||||
|
||||
|
|
@ -560,7 +529,7 @@ class Cart {
|
|||
}
|
||||
|
||||
//delete the guest cart instance.
|
||||
$this->cart->delete($guestCartId);
|
||||
$this->cartRepository->delete($guestCartId);
|
||||
|
||||
//forget the guest cart instance
|
||||
session()->forget('cart');
|
||||
|
|
@ -595,13 +564,13 @@ class Cart {
|
|||
$cart = null;
|
||||
|
||||
if ($this->getCurrentCustomer()->check()) {
|
||||
$cart = $this->cart->findOneWhere([
|
||||
$cart = $this->cartRepository->findOneWhere([
|
||||
'customer_id' => $this->getCurrentCustomer()->user()->id,
|
||||
'is_active' => 1
|
||||
]);
|
||||
|
||||
} elseif (session()->has('cart')) {
|
||||
$cart = $this->cart->find(session()->get('cart')->id);
|
||||
$cart = $this->cartRepository->find(session()->get('cart')->id);
|
||||
}
|
||||
|
||||
return $cart && $cart->is_active ? $cart : null;
|
||||
|
|
@ -700,7 +669,7 @@ class Cart {
|
|||
$billingAddress['cart_id'] = $cart->id;
|
||||
|
||||
if (isset($data['billing']['address_id']) && $data['billing']['address_id']) {
|
||||
$address = $this->customerAddress->findOneWhere(['id'=> $data['billing']['address_id']])->toArray();
|
||||
$address = $this->customerAddressRepository->findOneWhere(['id'=> $data['billing']['address_id']])->toArray();
|
||||
|
||||
$billingAddress['first_name'] = $this->getCurrentCustomer()->user()->first_name;
|
||||
$billingAddress['last_name'] = $this->getCurrentCustomer()->user()->last_name;
|
||||
|
|
@ -715,7 +684,7 @@ class Cart {
|
|||
|
||||
if (isset($data['billing']['save_as_address']) && $data['billing']['save_as_address']) {
|
||||
$billingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id;
|
||||
$this->customerAddress->create($billingAddress);
|
||||
$this->customerAddressRepository->create($billingAddress);
|
||||
}
|
||||
|
||||
if ($cart->haveStockableItems()) {
|
||||
|
|
@ -723,7 +692,7 @@ class Cart {
|
|||
$shippingAddress['cart_id'] = $cart->id;
|
||||
|
||||
if (isset($data['shipping']['address_id']) && $data['shipping']['address_id']) {
|
||||
$address = $this->customerAddress->findOneWhere(['id'=> $data['shipping']['address_id']])->toArray();
|
||||
$address = $this->customerAddressRepository->findOneWhere(['id'=> $data['shipping']['address_id']])->toArray();
|
||||
|
||||
$shippingAddress['first_name'] = $this->getCurrentCustomer()->user()->first_name;
|
||||
$shippingAddress['last_name'] = $this->getCurrentCustomer()->user()->last_name;
|
||||
|
|
@ -739,36 +708,36 @@ class Cart {
|
|||
if (isset($data['shipping']['save_as_address']) && $data['shipping']['save_as_address']) {
|
||||
$shippingAddress['customer_id'] = $this->getCurrentCustomer()->user()->id;
|
||||
|
||||
$this->customerAddress->create($shippingAddress);
|
||||
$this->customerAddressRepository->create($shippingAddress);
|
||||
}
|
||||
}
|
||||
|
||||
if ($billingAddressModel = $cart->billing_address) {
|
||||
$this->cartAddress->update($billingAddress, $billingAddressModel->id);
|
||||
$this->cartAddressRepository->update($billingAddress, $billingAddressModel->id);
|
||||
|
||||
if ($cart->haveStockableItems()) {
|
||||
if ($shippingAddressModel = $cart->shipping_address) {
|
||||
if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
|
||||
$this->cartAddress->update($billingAddress, $shippingAddressModel->id);
|
||||
$this->cartAddressRepository->update($billingAddress, $shippingAddressModel->id);
|
||||
} else {
|
||||
$this->cartAddress->update($shippingAddress, $shippingAddressModel->id);
|
||||
$this->cartAddressRepository->update($shippingAddress, $shippingAddressModel->id);
|
||||
}
|
||||
} else {
|
||||
if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
|
||||
$this->cartAddress->create(array_merge($billingAddress, ['address_type' => 'shipping']));
|
||||
$this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'shipping']));
|
||||
} else {
|
||||
$this->cartAddress->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
|
||||
$this->cartAddressRepository->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->cartAddress->create(array_merge($billingAddress, ['address_type' => 'billing']));
|
||||
$this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'billing']));
|
||||
|
||||
if ($cart->haveStockableItems()) {
|
||||
if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
|
||||
$this->cartAddress->create(array_merge($billingAddress, ['address_type' => 'shipping']));
|
||||
$this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'shipping']));
|
||||
} else {
|
||||
$this->cartAddress->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
|
||||
$this->cartAddressRepository->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -892,13 +861,12 @@ class Cart {
|
|||
{
|
||||
$cart = $this->getCart();
|
||||
|
||||
if (! $cart) {
|
||||
if (! $cart)
|
||||
return false;
|
||||
}
|
||||
|
||||
//rare case of accident-->used when there are no items.
|
||||
if (count($cart->items) == 0) {
|
||||
$this->cart->delete($cart->id);
|
||||
$this->cartRepository->delete($cart->id);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -931,7 +899,7 @@ class Cart {
|
|||
]);
|
||||
}
|
||||
|
||||
} else if ($productFlat->type == 'simple') {
|
||||
} else {
|
||||
if ($productFlat->sku != $item->sku) {
|
||||
$item->update(['sku' => $productFlat->sku]);
|
||||
|
||||
|
|
@ -975,7 +943,7 @@ class Cart {
|
|||
return;
|
||||
|
||||
foreach ($cart->items()->get() as $item) {
|
||||
$taxCategory = $this->taxCategory->find($item->product->tax_category_id);
|
||||
$taxCategory = $this->taxCategoryRepository->find($item->product->tax_category_id);
|
||||
|
||||
if (! $taxCategory)
|
||||
continue;
|
||||
|
|
@ -1064,7 +1032,7 @@ class Cart {
|
|||
public function deActivateCart()
|
||||
{
|
||||
if ($cart = $this->getCart()) {
|
||||
$this->cart->update(['is_active' => false], $cart->id);
|
||||
$this->cartRepository->update(['is_active' => false], $cart->id);
|
||||
|
||||
if (session()->has('cart')) {
|
||||
session()->forget('cart');
|
||||
|
|
@ -1083,14 +1051,12 @@ class Cart {
|
|||
|
||||
$finalData = [
|
||||
'cart_id' => $this->getCart()->id,
|
||||
|
||||
'customer_id' => $data['customer_id'],
|
||||
'is_guest' => $data['is_guest'],
|
||||
'customer_email' => $data['customer_email'],
|
||||
'customer_first_name' => $data['customer_first_name'],
|
||||
'customer_last_name' => $data['customer_last_name'],
|
||||
'customer' => $this->getCurrentCustomer()->check() ? $this->getCurrentCustomer()->user() : null,
|
||||
|
||||
'total_item_count' => $data['items_count'],
|
||||
'total_qty_ordered' => $data['items_qty'],
|
||||
'base_currency_code' => $data['base_currency_code'],
|
||||
|
|
@ -1104,10 +1070,8 @@ class Cart {
|
|||
'base_tax_amount' => $data['base_tax_total'],
|
||||
'discount_amount' => $data['discount_amount'],
|
||||
'base_discount_amount' => $data['base_discount_amount'],
|
||||
|
||||
'billing_address' => array_except($data['billing_address'], ['id', 'cart_id']),
|
||||
'payment' => array_except($data['payment'], ['id', 'cart_id']),
|
||||
|
||||
'channel' => core()->getCurrentChannel(),
|
||||
];
|
||||
|
||||
|
|
@ -1137,7 +1101,7 @@ class Cart {
|
|||
public function prepareDataForOrderItem($data)
|
||||
{
|
||||
$finalData = [
|
||||
'product' => $this->product->find($data['product_id']),
|
||||
'product' => $this->productRepository->find($data['product_id']),
|
||||
'sku' => $data['sku'],
|
||||
'type' => $data['type'],
|
||||
'name' => $data['name'],
|
||||
|
|
@ -1173,23 +1137,20 @@ class Cart {
|
|||
{
|
||||
$product = $wishlistItem->product;
|
||||
|
||||
if ($product->type == 'simple') {
|
||||
$data['quantity'] = 1;
|
||||
$data['product'] = $product->id;
|
||||
if ($product->getTypeInstance()->canBeMovedFromWishlistToCart()) {
|
||||
\Event::fire('checkout.cart.add.before', $product->id);
|
||||
|
||||
\Event::fire('checkout.cart.add.after', $product->id);
|
||||
|
||||
$result = $this->add($product->id, $data);
|
||||
$result = $this->add($product->id, ['quantity' => 1, 'product' => $product->id]);
|
||||
|
||||
if ($result) {
|
||||
\Event::fire('checkout.cart.add.after', $result);
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
} else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
} else if ($product->type == 'configurable' && $product->parent_id == null) {
|
||||
return -1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1209,27 +1170,27 @@ class Cart {
|
|||
|
||||
foreach ($cart->items as $item) {
|
||||
if ($item->id == $itemId) {
|
||||
if (is_null($item['parent_id']) && $item['type'] == 'simple') {
|
||||
$wishlist['product_id'] = $item->product_id;
|
||||
} else {
|
||||
if ($item->type == 'configurable') {
|
||||
$wishlist['product_id'] = $item->child->product_id;
|
||||
$wishtlist['options'] = $item->additional;
|
||||
} else {
|
||||
$wishlist['product_id'] = $item->product_id;
|
||||
}
|
||||
|
||||
$shouldBe = $this->wishlist->findWhere([
|
||||
$shouldBe = $this->wishlistRepository->findWhere([
|
||||
'customer_id' => $this->getCurrentCustomer()->user()->id,
|
||||
'product_id' => $wishlist['product_id']
|
||||
]);
|
||||
|
||||
if ($shouldBe->isEmpty()) {
|
||||
$wishlist = $this->wishlist->create($wishlist);
|
||||
$wishlist = $this->wishlistRepository->create($wishlist);
|
||||
}
|
||||
|
||||
$result = $this->cartItem->delete($itemId);
|
||||
$result = $this->cartItemRepository->delete($itemId);
|
||||
|
||||
if ($result) {
|
||||
if ($cart->items()->count() == 0)
|
||||
$this->cart->delete($cart->id);
|
||||
$this->cartRepository->delete($cart->id);
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.move-to-wishlist-success'));
|
||||
|
||||
|
|
@ -1250,14 +1211,14 @@ class Cart {
|
|||
*/
|
||||
public function proceedToBuyNow($id, $quantity)
|
||||
{
|
||||
$product = $this->product->findOneByField('id', $id);
|
||||
$product = $this->productRepository->findOneByField('id', $id);
|
||||
|
||||
if ($product->type == 'configurable') {
|
||||
session()->flash('warning', trans('shop::app.buynow.no-options'));
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$simpleOrVariant = $this->product->find($id);
|
||||
$simpleOrVariant = $this->productRepository->find($id);
|
||||
|
||||
if ($simpleOrVariant->parent_id != null) {
|
||||
$parent = $simpleOrVariant->parent;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Repositories\ChannelRepository as Channel;
|
||||
use Webkul\Core\Repositories\ChannelRepository;
|
||||
|
||||
/**
|
||||
* Channel controller
|
||||
|
|
@ -27,17 +25,17 @@ class ChannelController extends Controller
|
|||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $channel;
|
||||
protected $channelRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channel
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Channel $channel)
|
||||
public function __construct(ChannelRepository $channelRepository)
|
||||
{
|
||||
$this->channel = $channel;
|
||||
$this->channelRepository = $channelRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -83,7 +81,7 @@ class ChannelController extends Controller
|
|||
|
||||
Event::fire('core.channel.create.before');
|
||||
|
||||
$channel = $this->channel->create(request()->all());
|
||||
$channel = $this->channelRepository->create(request()->all());
|
||||
|
||||
Event::fire('core.channel.create.after', $channel);
|
||||
|
||||
|
|
@ -100,7 +98,7 @@ class ChannelController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$channel = $this->channel->with(['locales', 'currencies'])->findOrFail($id);
|
||||
$channel = $this->channelRepository->with(['locales', 'currencies'])->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('channel'));
|
||||
}
|
||||
|
|
@ -108,11 +106,10 @@ class ChannelController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:channels,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
|
|
@ -129,7 +126,7 @@ class ChannelController extends Controller
|
|||
|
||||
Event::fire('core.channel.update.before', $id);
|
||||
|
||||
$channel = $this->channel->update(request()->all(), $id);
|
||||
$channel = $this->channelRepository->update(request()->all(), $id);
|
||||
|
||||
Event::fire('core.channel.update.after', $channel);
|
||||
|
||||
|
|
@ -146,7 +143,7 @@ class ChannelController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$channel = $this->channel->findOrFail($id);
|
||||
$channel = $this->channelRepository->findOrFail($id);
|
||||
|
||||
if ($channel->code == config('app.channel')) {
|
||||
session()->flash('error', trans('admin::app.settings.channels.last-delete-error'));
|
||||
|
|
@ -154,7 +151,7 @@ class ChannelController extends Controller
|
|||
try {
|
||||
Event::fire('core.channel.delete.before', $id);
|
||||
|
||||
$this->channel->delete($id);
|
||||
$this->channelRepository->delete($id);
|
||||
|
||||
Event::fire('core.channel.delete.after', $id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Core\Repositories\CountryRepository as Country;
|
||||
use Webkul\Core\Repositories\CountryStateRepository as State;
|
||||
use Webkul\Core\Repositories\CountryRepository;
|
||||
use Webkul\Core\Repositories\CountryStateRepository;
|
||||
|
||||
/**
|
||||
* Country controller
|
||||
|
|
@ -27,26 +25,30 @@ class CountryStateController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $country;
|
||||
protected $countryRepository;
|
||||
|
||||
/**
|
||||
* StateRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $state;
|
||||
protected $stateRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\CountryRepository $country
|
||||
* @param \Webkul\Core\Repositories\CountryRepository $countryRepository
|
||||
* @param \Webkul\Core\Repositories\StateRepository $stateRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Country $country, State $state)
|
||||
public function __construct(
|
||||
CountryRepository $countryRepository,
|
||||
StateRepository $stateRepository
|
||||
)
|
||||
{
|
||||
$this->country = $country;
|
||||
$this->countryRepository = $countryRepository;
|
||||
|
||||
$this->state = $state;
|
||||
$this->stateRepository = $stateRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -58,8 +60,9 @@ class CountryStateController extends Controller
|
|||
*/
|
||||
public function getCountries()
|
||||
{
|
||||
$countries = $this->country->all();
|
||||
$states = $this->state->all();
|
||||
$countries = $this->countryRepository->all();
|
||||
|
||||
$states = $this->stateRepository->all();
|
||||
|
||||
$nestedArray = [];
|
||||
|
||||
|
|
@ -76,8 +79,9 @@ class CountryStateController extends Controller
|
|||
|
||||
public function getStates($country)
|
||||
{
|
||||
$countries = $this->country->all();
|
||||
$states = $this->state->all();
|
||||
$countries = $this->countryRepository->all();
|
||||
|
||||
$states = $this->stateRepository->all();
|
||||
|
||||
$nestedArray = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Repositories\CurrencyRepository as Currency;
|
||||
use Webkul\Core\Repositories\CurrencyRepository;
|
||||
|
||||
/**
|
||||
* Currency controller
|
||||
|
|
@ -27,17 +25,17 @@ class CurrencyController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $currency;
|
||||
protected $currencyRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\CurrencyRepository $currency
|
||||
* @param \Webkul\Core\Repositories\CurrencyRepository $currencyRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Currency $currency)
|
||||
public function __construct(CurrencyRepository $currencyRepository)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
$this->currencyRepository = $currencyRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -77,7 +75,7 @@ class CurrencyController extends Controller
|
|||
|
||||
Event::fire('core.channel.create.before');
|
||||
|
||||
$currency = $this->currency->create(request()->all());
|
||||
$currency = $this->currencyRepository->create(request()->all());
|
||||
|
||||
Event::fire('core.currency.create.after', $currency);
|
||||
|
||||
|
|
@ -94,7 +92,7 @@ class CurrencyController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$currency = $this->currency->findOrFail($id);
|
||||
$currency = $this->currencyRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('currency'));
|
||||
}
|
||||
|
|
@ -102,11 +100,10 @@ class CurrencyController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:currencies,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
|
|
@ -115,7 +112,7 @@ class CurrencyController extends Controller
|
|||
|
||||
Event::fire('core.currency.update.before', $id);
|
||||
|
||||
$currency = $this->currency->update(request()->all(), $id);
|
||||
$currency = $this->currencyRepository->update(request()->all(), $id);
|
||||
|
||||
Event::fire('core.currency.update.after', $currency);
|
||||
|
||||
|
|
@ -132,15 +129,15 @@ class CurrencyController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$currency = $this->currency->findOrFail($id);
|
||||
$currency = $this->currencyRepository->findOrFail($id);
|
||||
|
||||
if ($this->currency->count() == 1) {
|
||||
if ($this->currencyRepository->count() == 1) {
|
||||
session()->flash('warning', trans('admin::app.settings.currencies.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
Event::fire('core.currency.delete.before', $id);
|
||||
|
||||
$this->currency->delete($id);
|
||||
$this->currencyRepository->delete($id);
|
||||
|
||||
Event::fire('core.currency.delete.after', $id);
|
||||
|
||||
|
|
@ -170,7 +167,7 @@ class CurrencyController extends Controller
|
|||
try {
|
||||
Event::fire('core.currency.delete.before', $value);
|
||||
|
||||
$this->currency->delete($value);
|
||||
$this->currencyRepository->delete($value);
|
||||
|
||||
Event::fire('core.currency.delete.after', $value);
|
||||
} catch(\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Repositories\ExchangeRateRepository as ExchangeRate;
|
||||
use Webkul\Core\Repositories\CurrencyRepository as Currency;
|
||||
use Webkul\Core\Repositories\ExchangeRateRepository;
|
||||
use Webkul\Core\Repositories\CurrencyRepository;
|
||||
|
||||
/**
|
||||
* ExchangeRate controller
|
||||
|
|
@ -28,27 +26,30 @@ class ExchangeRateController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $exchangeRate;
|
||||
protected $exchangeRateRepository;
|
||||
|
||||
/**
|
||||
* CurrencyRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $currency;
|
||||
protected $currencyRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\ExchangeRateRepository $exchangeRate
|
||||
* @param \Webkul\Core\Repositories\CurrencyRepository $currency
|
||||
* @param \Webkul\Core\Repositories\ExchangeRateRepository $exchangeRateRepository
|
||||
* @param \Webkul\Core\Repositories\CurrencyRepository $currencyRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ExchangeRate $exchangeRate, Currency $currency)
|
||||
public function __construct(
|
||||
ExchangeRateRepository $exchangeRateRepository,
|
||||
CurrencyRepository $currencyRepository
|
||||
)
|
||||
{
|
||||
$this->exchangeRate = $exchangeRate;
|
||||
$this->exchangeRateRepository = $exchangeRateRepository;
|
||||
|
||||
$this->currency = $currency;
|
||||
$this->currencyRepository = $currencyRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -70,7 +71,7 @@ class ExchangeRateController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$currencies = $this->currency->with('CurrencyExchangeRate')->all();
|
||||
$currencies = $this->currencyRepository->with('CurrencyExchangeRate')->all();
|
||||
|
||||
return view($this->_config['view'], compact('currencies'));
|
||||
}
|
||||
|
|
@ -78,10 +79,9 @@ class ExchangeRateController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'target_currency' => ['required', 'unique:currency_exchange_rates,target_currency'],
|
||||
|
|
@ -90,7 +90,7 @@ class ExchangeRateController extends Controller
|
|||
|
||||
Event::fire('core.exchange_rate.create.before');
|
||||
|
||||
$exchangeRate = $this->exchangeRate->create(request()->all());
|
||||
$exchangeRate = $this->exchangeRateRepository->create(request()->all());
|
||||
|
||||
Event::fire('core.exchange_rate.create.after', $exchangeRate);
|
||||
|
||||
|
|
@ -107,9 +107,9 @@ class ExchangeRateController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$currencies = $this->currency->all();
|
||||
$currencies = $this->currencyRepository->all();
|
||||
|
||||
$exchangeRate = $this->exchangeRate->findOrFail($id);
|
||||
$exchangeRate = $this->exchangeRateRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('currencies', 'exchangeRate'));
|
||||
}
|
||||
|
|
@ -117,11 +117,10 @@ class ExchangeRateController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'target_currency' => ['required', 'unique:currency_exchange_rates,target_currency,' . $id],
|
||||
|
|
@ -130,7 +129,7 @@ class ExchangeRateController extends Controller
|
|||
|
||||
Event::fire('core.exchange_rate.update.before', $id);
|
||||
|
||||
$exchangeRate = $this->exchangeRate->update(request()->all(), $id);
|
||||
$exchangeRate = $this->exchangeRateRepository->update(request()->all(), $id);
|
||||
|
||||
Event::fire('core.exchange_rate.update.after', $exchangeRate);
|
||||
|
||||
|
|
@ -147,15 +146,15 @@ class ExchangeRateController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$exchangeRate = $this->exchangeRate->findOrFail($id);
|
||||
$exchangeRate = $this->exchangeRateRepository->findOrFail($id);
|
||||
|
||||
if ($this->exchangeRate->count() == 1) {
|
||||
if ($this->exchangeRateRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.settings.exchange_rates.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
Event::fire('core.exchange_rate.delete.before', $id);
|
||||
|
||||
$this->exchangeRate->delete($id);
|
||||
$this->exchangeRateRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.exchange_rates.delete-success'));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Core\Repositories\LocaleRepository as Locale;
|
||||
use Webkul\Core\Repositories\LocaleRepository;
|
||||
|
||||
/**
|
||||
* Locale controller
|
||||
|
|
@ -27,17 +25,17 @@ class LocaleController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $locale;
|
||||
protected $localeRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\LocaleRepository $locale
|
||||
* @param \Webkul\Core\Repositories\LocaleRepository $localeRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Locale $locale)
|
||||
public function __construct(LocaleRepository $localeRepository)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
$this->localeRepository = $localeRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -65,10 +63,9 @@ class LocaleController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:locales,code', new \Webkul\Core\Contracts\Validations\Code],
|
||||
|
|
@ -77,7 +74,7 @@ class LocaleController extends Controller
|
|||
|
||||
Event::fire('core.locale.create.before');
|
||||
|
||||
$locale = $this->locale->create(request()->all());
|
||||
$locale = $this->localeRepository->create(request()->all());
|
||||
|
||||
Event::fire('core.locale.create.after', $locale);
|
||||
|
||||
|
|
@ -94,7 +91,7 @@ class LocaleController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$locale = $this->locale->findOrFail($id);
|
||||
$locale = $this->localeRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('locale'));
|
||||
}
|
||||
|
|
@ -102,11 +99,10 @@ class LocaleController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:locales,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
|
|
@ -115,7 +111,7 @@ class LocaleController extends Controller
|
|||
|
||||
Event::fire('core.locale.update.before', $id);
|
||||
|
||||
$locale = $this->locale->update(request()->all(), $id);
|
||||
$locale = $this->localeRepository->update(request()->all(), $id);
|
||||
|
||||
Event::fire('core.locale.update.after', $locale);
|
||||
|
||||
|
|
@ -132,15 +128,15 @@ class LocaleController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$locale = $this->locale->findOrFail($id);
|
||||
$locale = $this->localeRepository->findOrFail($id);
|
||||
|
||||
if ($this->locale->count() == 1) {
|
||||
if ($this->localeRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.settings.locales.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
Event::fire('core.locale.delete.before', $id);
|
||||
|
||||
$this->locale->delete($id);
|
||||
$this->localeRepository->delete($id);
|
||||
|
||||
Event::fire('core.locale.delete.after', $id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Core\Repositories\SliderRepository as Slider;
|
||||
use Webkul\Core\Repositories\SliderRepository;
|
||||
|
||||
/**
|
||||
* Slider controller for managing the slider controls.
|
||||
|
|
@ -22,10 +20,11 @@ class SliderController extends Controller
|
|||
protected $_config;
|
||||
|
||||
/**
|
||||
* SliderRepository object
|
||||
* SliderRepository
|
||||
*
|
||||
* Object
|
||||
*/
|
||||
protected $slider;
|
||||
protected $sliderRepository;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
|
|
@ -35,12 +34,12 @@ class SliderController extends Controller
|
|||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\SliderRepository $slider
|
||||
* @param \Webkul\Core\Repositories\SliderRepository $sliderRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Slider $slider)
|
||||
public function __construct(SliderRepository $sliderRepository)
|
||||
{
|
||||
$this->slider = $slider;
|
||||
$this->sliderRepository = $sliderRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -80,7 +79,7 @@ class SliderController extends Controller
|
|||
'image.*' => 'required|mimes:jpeg,bmp,png,jpg'
|
||||
]);
|
||||
|
||||
$result = $this->slider->save(request()->all());
|
||||
$result = $this->sliderRepository->save(request()->all());
|
||||
|
||||
if ($result)
|
||||
session()->flash('success', trans('admin::app.settings.sliders.created-success'));
|
||||
|
|
@ -97,7 +96,7 @@ class SliderController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$slider = $this->slider->findOrFail($id);
|
||||
$slider = $this->sliderRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'])->with('slider', $slider);
|
||||
}
|
||||
|
|
@ -115,7 +114,7 @@ class SliderController extends Controller
|
|||
'image.*' => 'sometimes|mimes:jpeg,bmp,png,jpg'
|
||||
]);
|
||||
|
||||
$result = $this->slider->updateItem(request()->all(), $id);
|
||||
$result = $this->sliderRepository->updateItem(request()->all(), $id);
|
||||
|
||||
if ($result) {
|
||||
session()->flash('success', trans('admin::app.settings.sliders.update-success'));
|
||||
|
|
@ -133,13 +132,13 @@ class SliderController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$slider = $this->slider->findOrFail($id);
|
||||
$slider = $this->sliderRepository->findOrFail($id);
|
||||
|
||||
if ($this->slider->findWhere(['channel_id' => core()->getCurrentChannel()->id])->count() == 1) {
|
||||
if ($this->sliderRepository->findWhere(['channel_id' => core()->getCurrentChannel()->id])->count() == 1) {
|
||||
session()->flash('warning', trans('admin::app.settings.sliders.delete-success'));
|
||||
} else {
|
||||
try {
|
||||
$this->slider->delete($id);
|
||||
$this->sliderRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Slider']));
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ namespace Webkul\Core\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Core\Repositories\SubscribersListRepository as Subscribers;
|
||||
use Webkul\Core\Repositories\SubscribersListRepository;
|
||||
|
||||
/**
|
||||
* Subscription controller
|
||||
*
|
||||
|
|
@ -21,15 +22,21 @@ class SubscriptionController extends Controller
|
|||
protected $_config;
|
||||
|
||||
/**
|
||||
* Subscription repository instance
|
||||
* SubscribersListRepository
|
||||
*
|
||||
* @var instanceof SubscribersListRepository
|
||||
* @var Object
|
||||
*/
|
||||
protected $subscribers;
|
||||
protected $subscribersListRepository;
|
||||
|
||||
public function __construct(Subscribers $subscribers)
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\SubscribersListRepository $subscribersListRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(SubscribersListRepository $subscribersListRepository)
|
||||
{
|
||||
$this->subscribers = $subscribers;
|
||||
$this->subscribersListRepository = $subscribersListRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -51,8 +58,9 @@ class SubscriptionController extends Controller
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function edit($id) {
|
||||
$subscriber = $this->subscribers->findOrFail($id);
|
||||
public function edit($id)
|
||||
{
|
||||
$subscriber = $this->subscribersListRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'])->with('subscriber', $subscriber);
|
||||
}
|
||||
|
|
@ -64,10 +72,11 @@ class SubscriptionController extends Controller
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($id) {
|
||||
public function update($id)
|
||||
{
|
||||
$data = request()->all();
|
||||
|
||||
$subscriber = $this->subscribers->findOrFail($id);
|
||||
$subscriber = $this->subscribersListRepository->findOrFail($id);
|
||||
|
||||
$result = $subscriber->update($data);
|
||||
|
||||
|
|
@ -88,7 +97,7 @@ class SubscriptionController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$subscriber = $this->subscribers->findOrFail($id);
|
||||
$subscriber = $this->subscribersListRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
$this->subscriber->delete($id);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Webkul\Core\Repositories;
|
|||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Core\Repositories\ChannelRepository as Channel;
|
||||
use Webkul\Core\Repositories\ChannelRepository;
|
||||
use Storage;
|
||||
|
||||
/**
|
||||
|
|
@ -15,14 +15,25 @@ use Storage;
|
|||
*/
|
||||
class SliderRepository extends Repository
|
||||
{
|
||||
protected $channel;
|
||||
/**
|
||||
* ChannelRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $channelRepository;
|
||||
|
||||
/**
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channelRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Channel $channel,
|
||||
ChannelRepository $channelRepository,
|
||||
App $app
|
||||
)
|
||||
{
|
||||
$this->channel = $channel;
|
||||
$this->channelRepository = $channelRepository;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
|
@ -43,7 +54,7 @@ class SliderRepository extends Repository
|
|||
*/
|
||||
public function save(array $data)
|
||||
{
|
||||
$channelName = $this->channel->find($data['channel_id'])->name;
|
||||
$channelName = $this->channelRepository->find($data['channel_id'])->name;
|
||||
|
||||
$dir = 'slider_images/' . $channelName;
|
||||
|
||||
|
|
@ -80,19 +91,15 @@ class SliderRepository extends Repository
|
|||
*/
|
||||
public function updateItem(array $data, $id)
|
||||
{
|
||||
$channelName = $this->channel->find($data['channel_id'])->name;
|
||||
$channelName = $this->channelRepository->find($data['channel_id'])->name;
|
||||
|
||||
$dir = 'slider_images/' . $channelName;
|
||||
|
||||
$uploaded = false;
|
||||
$image = false;
|
||||
$uploaded = $image = false;
|
||||
|
||||
if (isset($data['image'])) {
|
||||
$image = $first = array_first($data['image'], function ($value, $key) {
|
||||
if ($value)
|
||||
return $value;
|
||||
else
|
||||
return false;
|
||||
return $value ? $value : false;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -122,8 +129,8 @@ class SliderRepository extends Repository
|
|||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public function destroy($id) {
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$sliderItem = $this->find($id);
|
||||
|
||||
$sliderItemImage = $sliderItem->path;
|
||||
|
|
|
|||
|
|
@ -2,12 +2,6 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Customer\Repositories\CustomerAddressRepository;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Account Controlller for the customers
|
||||
* basically will control the landing
|
||||
|
|
@ -20,27 +14,31 @@ use Auth;
|
|||
class AccountController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
protected $customer;
|
||||
protected $address;
|
||||
|
||||
|
||||
public function __construct(CustomerRepository $customer, CustomerAddressRepository $address)
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
public function index() {
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace Webkul\Customer\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Customer\Repositories\CustomerAddressRepository;
|
||||
use Auth;
|
||||
|
||||
|
|
@ -18,28 +17,29 @@ use Auth;
|
|||
class AddressController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
protected $customer;
|
||||
/**
|
||||
* CustomerAddressRepository object
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
|
||||
* @var Object
|
||||
*/
|
||||
protected $customerAddressRepository;
|
||||
|
||||
protected $address;
|
||||
|
||||
public function __construct(
|
||||
CustomerRepository $customer,
|
||||
CustomerAddressRepository $address
|
||||
)
|
||||
public function __construct(CustomerAddressRepository $customerAddressRepository)
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = auth()->guard('customer')->user();
|
||||
$this->customerAddressRepository = $customerAddressRepository;
|
||||
|
||||
$this->address = $address;
|
||||
$this->customer = auth()->guard('customer')->user();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -89,7 +89,7 @@ class AddressController extends Controller
|
|||
$data['default_address'] = 1;
|
||||
}
|
||||
|
||||
if ($this->address->create($data)) {
|
||||
if ($this->customerAddressRepository->create($data)) {
|
||||
session()->flash('success', trans('shop::app.customer.account.address.create.success'));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
@ -107,7 +107,7 @@ class AddressController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$address = $this->address->findOneWhere([
|
||||
$address = $this->customerAddressRepository->findOneWhere([
|
||||
'id' => $id,
|
||||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
]);
|
||||
|
|
@ -145,7 +145,7 @@ class AddressController extends Controller
|
|||
if ($id == $address->id) {
|
||||
session()->flash('success', trans('shop::app.customer.account.address.edit.success'));
|
||||
|
||||
$this->address->update($data, $id);
|
||||
$this->customerAddressRepository->update($data, $id);
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
}
|
||||
|
|
@ -163,11 +163,10 @@ class AddressController extends Controller
|
|||
*/
|
||||
public function makeDefault($id)
|
||||
{
|
||||
if ($default = $this->customer->default_address) {
|
||||
$this->address->find($default->id)->update(['default_address' => 0]);
|
||||
}
|
||||
if ($default = $this->customer->default_address)
|
||||
$this->customerAddressRepository->find($default->id)->update(['default_address' => 0]);
|
||||
|
||||
if ($address = $this->address->find($id)) {
|
||||
if ($address = $this->customerAddressRepository->find($id)) {
|
||||
$address->update(['default_address' => 1]);
|
||||
} else {
|
||||
session()->flash('success', trans('shop::app.customer.account.address.index.default-delete'));
|
||||
|
|
@ -185,7 +184,7 @@ class AddressController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$address = $this->address->findOneWhere([
|
||||
$address = $this->customerAddressRepository->findOneWhere([
|
||||
'id' => $id,
|
||||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
]);
|
||||
|
|
@ -193,7 +192,7 @@ class AddressController extends Controller
|
|||
if (! $address)
|
||||
abort(404);
|
||||
|
||||
$this->address->delete($id);
|
||||
$this->customerAddressRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('shop::app.customer.account.address.delete.success'));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,8 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Auth;
|
||||
use Hash;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
|
||||
/**
|
||||
* Customer controlller for the customer basically for the tasks of customers which will be done after customer authentication.
|
||||
|
|
@ -19,45 +14,32 @@ use Hash;
|
|||
class CustomerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* CustomerRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $customer;
|
||||
protected $customerRepository;
|
||||
|
||||
/**
|
||||
* ProductReviewRepository object
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $productReview;
|
||||
|
||||
/**
|
||||
* Create a new Repository instance.
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param \Webkul\Product\Repositories\ProductReviewRepository $productReview
|
||||
* @param \Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
CustomerRepository $customer,
|
||||
ProductReview $productReview
|
||||
)
|
||||
public function __construct(CustomerRepository $customerRepository)
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->productReview = $productReview;
|
||||
$this->customerRepository = $customerRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -67,7 +49,7 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$customer = $this->customer->find(auth()->guard('customer')->user()->id);
|
||||
$customer = $this->customerRepository->find(auth()->guard('customer')->user()->id);
|
||||
|
||||
return view($this->_config['view'], compact('customer'));
|
||||
}
|
||||
|
|
@ -79,7 +61,7 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function edit()
|
||||
{
|
||||
$customer = $this->customer->find(auth()->guard('customer')->user()->id);
|
||||
$customer = $this->customerRepository->find(auth()->guard('customer')->user()->id);
|
||||
|
||||
return view($this->_config['view'], compact('customer'));
|
||||
}
|
||||
|
|
@ -87,7 +69,7 @@ class CustomerController extends Controller
|
|||
/**
|
||||
* Edit function for editing customer profile.
|
||||
*
|
||||
* @return Redirect.
|
||||
* @return response
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
|
|
@ -105,9 +87,8 @@ class CustomerController extends Controller
|
|||
|
||||
$data = collect(request()->input())->except('_token')->toArray();
|
||||
|
||||
if ($data['date_of_birth'] == "") {
|
||||
if ($data['date_of_birth'] == "")
|
||||
unset($data['date_of_birth']);
|
||||
}
|
||||
|
||||
if ($data['oldpassword'] != "" || $data['oldpassword'] != null) {
|
||||
if(Hash::check($data['oldpassword'], auth()->guard('customer')->user()->password)) {
|
||||
|
|
@ -121,7 +102,7 @@ class CustomerController extends Controller
|
|||
unset($data['password']);
|
||||
}
|
||||
|
||||
if ($this->customer->update($data, $id)) {
|
||||
if ($this->customerRepository->update($data, $id)) {
|
||||
Session()->flash('success', trans('shop::app.customer.account.profile.edit-success'));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
|
|
@ -59,7 +57,7 @@ class ForgotPasswordController extends Controller
|
|||
$response = $this->broker()->sendResetLink(
|
||||
request(['email'])
|
||||
);
|
||||
//dd($response);
|
||||
|
||||
if ($response == Password::RESET_LINK_SENT) {
|
||||
session()->flash('success', trans($response));
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Webkul\Customer\Mail\VerificationEmail;
|
||||
|
|
@ -21,22 +19,43 @@ use Cookie;
|
|||
class RegistrationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
protected $customer;
|
||||
protected $customerGroup;
|
||||
|
||||
/**
|
||||
* @param CustomerRepository object $customer
|
||||
*/
|
||||
public function __construct(CustomerRepository $customer, CustomerGroupRepository $customerGroup)
|
||||
* CustomerRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $customerRepository;
|
||||
|
||||
/**
|
||||
* CustomerGroupRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $customerGroupRepository;
|
||||
|
||||
/**
|
||||
* Create a new Repository instance.
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
CustomerRepository $customerRepository,
|
||||
CustomerGroupRepository $customerGroupRepository
|
||||
)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
$this->customer = $customer;
|
||||
$this->customerGroup = $customerGroup;
|
||||
|
||||
$this->customerRepository = $customerRepository;
|
||||
|
||||
$this->customerGroupRepository = $customerGroupRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -52,11 +71,11 @@ class RegistrationController extends Controller
|
|||
/**
|
||||
* Method to store user's sign up form data to DB.
|
||||
*
|
||||
* @return Mixed
|
||||
* @return Response
|
||||
*/
|
||||
public function create(Request $request)
|
||||
public function create()
|
||||
{
|
||||
$request->validate([
|
||||
$this->validate(request(), [
|
||||
'first_name' => 'string|required',
|
||||
'last_name' => 'string|required',
|
||||
'email' => 'email|required|unique:customers,email',
|
||||
|
|
@ -75,7 +94,7 @@ class RegistrationController extends Controller
|
|||
$data['is_verified'] = 1;
|
||||
}
|
||||
|
||||
$data['customer_group_id'] = $this->customerGroup->findOneWhere(['code' => 'general'])->id;
|
||||
$data['customer_group_id'] = $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id;
|
||||
|
||||
$verificationData['email'] = $data['email'];
|
||||
$verificationData['token'] = md5(uniqid(rand(), true));
|
||||
|
|
@ -83,7 +102,7 @@ class RegistrationController extends Controller
|
|||
|
||||
Event::fire('customer.registration.before');
|
||||
|
||||
$customer = $this->customer->create($data);
|
||||
$customer = $this->customerRepository->create($data);
|
||||
|
||||
Event::fire('customer.registration.after', $customer);
|
||||
|
||||
|
|
@ -115,7 +134,7 @@ class RegistrationController extends Controller
|
|||
*/
|
||||
public function verifyAccount($token)
|
||||
{
|
||||
$customer = $this->customer->findOneByField('token', $token);
|
||||
$customer = $this->customerRepository->findOneByField('token', $token);
|
||||
|
||||
if ($customer) {
|
||||
$customer->update(['is_verified' => 1, 'token' => 'NULL']);
|
||||
|
|
@ -133,9 +152,9 @@ class RegistrationController extends Controller
|
|||
$verificationData['email'] = $email;
|
||||
$verificationData['token'] = md5(uniqid(rand(), true));
|
||||
|
||||
$customer = $this->customer->findOneByField('email', $email);
|
||||
$customer = $this->customerRepository->findOneByField('email', $email);
|
||||
|
||||
$this->customer->update(['token' => $verificationData['token']], $customer->id);
|
||||
$this->customerRepository->update(['token' => $verificationData['token']], $customer->id);
|
||||
|
||||
try {
|
||||
Mail::queue(new VerificationEmail($verificationData));
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
|
@ -16,10 +14,8 @@ use Illuminate\Support\Str;
|
|||
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
|
|
@ -44,14 +40,13 @@ class ResetPasswordController extends Controller
|
|||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $token
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create(Request $request, $token = null)
|
||||
public function create($token = null)
|
||||
{
|
||||
return view($this->_config['view'])->with(
|
||||
['token' => $token, 'email' => $request->email]
|
||||
['token' => $token, 'email' => request('email')]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,8 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\Customer\Http\Listeners\CustomerEventsHandler;
|
||||
use Cart;
|
||||
use Cookie;
|
||||
|
||||
/**
|
||||
|
|
@ -19,15 +15,21 @@ use Cookie;
|
|||
class SessionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* Create a new Repository instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('customer')->except(['show','create']);
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$subscriber = new CustomerEventsHandler;
|
||||
|
|
@ -35,6 +37,11 @@ class SessionController extends Controller
|
|||
Event::subscribe($subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
if (auth()->guard('customer')->check()) {
|
||||
|
|
@ -44,9 +51,14 @@ class SessionController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$request->validate([
|
||||
$this->validate(request(), [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required'
|
||||
]);
|
||||
|
|
@ -70,7 +82,7 @@ class SessionController extends Controller
|
|||
|
||||
Cookie::queue(Cookie::make('enable-resend', 'true', 1));
|
||||
|
||||
Cookie::queue(Cookie::make('email-for-resend', $request->input('email'), 1));
|
||||
Cookie::queue(Cookie::make('email-for-resend', request('email'), 1));
|
||||
|
||||
auth()->guard('customer')->logout();
|
||||
|
||||
|
|
@ -78,11 +90,17 @@ class SessionController extends Controller
|
|||
}
|
||||
|
||||
//Event passed to prepare cart after login
|
||||
Event::fire('customer.after.login', $request->input('email'));
|
||||
Event::fire('customer.after.login', request('email'));
|
||||
|
||||
return redirect()->intended(route($this->_config['redirect']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
auth()->guard('customer')->logout();
|
||||
|
|
|
|||
|
|
@ -2,13 +2,9 @@
|
|||
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Customer\Repositories\WishlistRepository;
|
||||
use Cart;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Customer controller
|
||||
|
|
@ -19,36 +15,54 @@ use Auth;
|
|||
|
||||
class WishlistController extends Controller
|
||||
{
|
||||
/**
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
protected $customer;
|
||||
|
||||
protected $wishlist;
|
||||
|
||||
protected $product;
|
||||
/**
|
||||
* ProductRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $wishlistRepository;
|
||||
|
||||
/**
|
||||
* Initializes the required repository instances.
|
||||
* WishlistRepository object
|
||||
*
|
||||
* @param $customer
|
||||
* @param $wishlist
|
||||
* @var Object
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Customer\Repositories\WishlistRepository $wishlistRepository
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CustomerRepository $customer, WishlistRepository $wishlist, ProductRepository $product)
|
||||
public function __construct(
|
||||
WishlistRepository $wishlistRepository,
|
||||
ProductRepository $productRepository
|
||||
)
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->wishlist = $wishlist;
|
||||
$this->wishlistRepository = $wishlistRepository;
|
||||
|
||||
$this->product = $product;
|
||||
$this->productRepository = $productRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the listing resources if the customer having items in wishlist.
|
||||
*/
|
||||
public function index() {
|
||||
$wishlistItems = $this->wishlist->findWhere([
|
||||
public function index()
|
||||
{
|
||||
$wishlistItems = $this->wishlistRepository->findWhere([
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'customer_id' => auth()->guard('customer')->user()->id]
|
||||
);
|
||||
|
|
@ -61,10 +75,11 @@ class WishlistController extends Controller
|
|||
*
|
||||
* @param integer $itemId
|
||||
*/
|
||||
public function add($itemId) {
|
||||
$product = $this->product->findOneByField('id', $itemId);
|
||||
public function add($itemId)
|
||||
{
|
||||
$product = $this->productRepository->findOneByField('id', $itemId);
|
||||
|
||||
if(!$product->status) {
|
||||
if (! $product->status) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
|
@ -74,16 +89,20 @@ class WishlistController extends Controller
|
|||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
];
|
||||
|
||||
$checked = $this->wishlist->findWhere(['channel_id' => core()->getCurrentChannel()->id, 'product_id' => $itemId, 'customer_id' => auth()->guard('customer')->user()->id]);
|
||||
$checked = $this->wishlistRepository->findWhere([
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'product_id' => $itemId,
|
||||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
]);
|
||||
|
||||
//accidental case if some one adds id of the product in the anchor tag amd gives id of a variant.
|
||||
if ($product->parent_id != null) {
|
||||
$product = $this->product->findOneByField('id', $product->parent_id);
|
||||
$product = $this->productRepository->findOneByField('id', $product->parent_id);
|
||||
$data['product_id'] = $product->id;
|
||||
}
|
||||
|
||||
if ($checked->isEmpty()) {
|
||||
if ($this->wishlist->create($data)) {
|
||||
if ($this->wishlistRepository->create($data)) {
|
||||
session()->flash('success', trans('customer::app.wishlist.success'));
|
||||
|
||||
return redirect()->back();
|
||||
|
|
@ -104,13 +123,13 @@ class WishlistController extends Controller
|
|||
*
|
||||
* @param integer $itemId
|
||||
*/
|
||||
public function remove($itemId) {
|
||||
|
||||
public function remove($itemId)
|
||||
{
|
||||
$customerWishlistItems = auth()->guard('customer')->user()->wishlist_items;
|
||||
|
||||
foreach($customerWishlistItems as $customerWishlistItem) {
|
||||
if($itemId == $customerWishlistItem->id) {
|
||||
$this->wishlist->delete($itemId);
|
||||
foreach ($customerWishlistItems as $customerWishlistItem) {
|
||||
if ($itemId == $customerWishlistItem->id) {
|
||||
$this->wishlistRepository->delete($itemId);
|
||||
|
||||
session()->flash('success', trans('customer::app.wishlist.removed'));
|
||||
|
||||
|
|
@ -128,10 +147,11 @@ class WishlistController extends Controller
|
|||
*
|
||||
* @param integer $itemId
|
||||
*/
|
||||
public function move($itemId) {
|
||||
$wishlistItem = $this->wishlist->findOneByField('id', $itemId);
|
||||
public function move($itemId)
|
||||
{
|
||||
$wishlistItem = $this->wishlistRepository->findOneByField('id', $itemId);
|
||||
|
||||
if(!isset($wishlistItem) || $wishlistItem->customer_id != auth()->guard('customer')->user()->id) {
|
||||
if (! isset($wishlistItem) || $wishlistItem->customer_id != auth()->guard('customer')->user()->id) {
|
||||
session()->flash('warning', trans('shop::app.security-warning'));
|
||||
|
||||
return redirect()->route( 'customer.wishlist.index');
|
||||
|
|
@ -139,7 +159,7 @@ class WishlistController extends Controller
|
|||
|
||||
$result = Cart::moveToCart($wishlistItem);
|
||||
|
||||
if ($result == 1) {
|
||||
if ($result) {
|
||||
if ($wishlistItem->delete()) {
|
||||
session()->flash('success', trans('shop::app.wishlist.moved'));
|
||||
|
||||
|
|
@ -151,12 +171,8 @@ class WishlistController extends Controller
|
|||
|
||||
return redirect()->back();
|
||||
}
|
||||
} else if ($result == 0) {
|
||||
session()->flash('error', trans('shop::app.wishlist.error'));
|
||||
|
||||
return redirect()->back();
|
||||
} else if ($result == -1) {
|
||||
session()->flash('info', trans('shop::app.checkout.cart.add-config-warning'));
|
||||
} else {
|
||||
session()->flash('info', trans('shop::app.wishlist.option-missing'));
|
||||
|
||||
return redirect()->route('shop.products.index', $wishlistItem->product->url_key);
|
||||
}
|
||||
|
|
@ -167,16 +183,18 @@ class WishlistController extends Controller
|
|||
*
|
||||
* @return Mixed Response & Boolean
|
||||
*/
|
||||
public function removeAll() {
|
||||
public function removeAll()
|
||||
{
|
||||
$wishlistItems = auth()->guard('customer')->user()->wishlist_items;
|
||||
|
||||
if ($wishlistItems->count() > 0) {
|
||||
foreach ($wishlistItems as $wishlistItem) {
|
||||
$this->wishlist->delete($wishlistItem->id);
|
||||
$this->wishlistRepository->delete($wishlistItem->id);
|
||||
}
|
||||
}
|
||||
|
||||
session()->flash('success', trans('customer::app.wishlist.remove-all-success'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Inventory\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource;
|
||||
use Webkul\Inventory\Repositories\InventorySourceRepository;
|
||||
|
||||
/**
|
||||
* Inventory source controller
|
||||
|
|
@ -27,17 +25,17 @@ class InventorySourceController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $inventorySource;
|
||||
protected $inventorySourceRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Inventory\Repositories\InventorySourceRepository $inventorySource
|
||||
* @param \Webkul\Inventory\Repositories\InventorySourceRepository $inventorySourceRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(InventorySource $inventorySource)
|
||||
public function __construct(InventorySourceRepository $inventorySourceRepository)
|
||||
{
|
||||
$this->inventorySource = $inventorySource;
|
||||
$this->inventorySourceRepository = $inventorySourceRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -88,7 +86,7 @@ class InventorySourceController extends Controller
|
|||
|
||||
Event::fire('inventory.inventory_source.create.before');
|
||||
|
||||
$inventorySource = $this->inventorySource->create($data);
|
||||
$inventorySource = $this->inventorySourceRepository->create($data);
|
||||
|
||||
Event::fire('inventory.inventory_source.create.after', $inventorySource);
|
||||
|
||||
|
|
@ -105,7 +103,7 @@ class InventorySourceController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$inventorySource = $this->inventorySource->findOrFail($id);
|
||||
$inventorySource = $this->inventorySourceRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('inventorySource'));
|
||||
}
|
||||
|
|
@ -113,11 +111,10 @@ class InventorySourceController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'code' => ['required', 'unique:inventory_sources,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
|
||||
|
|
@ -138,7 +135,7 @@ class InventorySourceController extends Controller
|
|||
|
||||
Event::fire('inventory.inventory_source.update.before', $id);
|
||||
|
||||
$inventorySource = $this->inventorySource->update($data, $id);
|
||||
$inventorySource = $this->inventorySourceRepository->update($data, $id);
|
||||
|
||||
Event::fire('inventory.inventory_source.update.after', $inventorySource);
|
||||
|
||||
|
|
@ -155,15 +152,15 @@ class InventorySourceController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$inventorySource = $this->inventorySource->findOrFail($id);
|
||||
$inventorySource = $this->inventorySourceRepository->findOrFail($id);
|
||||
|
||||
if ($this->inventorySource->count() == 1) {
|
||||
if ($this->inventorySourceRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.settings.inventory_sources.last-delete-error'));
|
||||
} else {
|
||||
try {
|
||||
Event::fire('inventory.inventory_source.delete.before', $id);
|
||||
|
||||
$this->inventorySource->delete($id);
|
||||
$this->inventorySourceRepository->delete($id);
|
||||
|
||||
Event::fire('inventory.inventory_source.delete.after', $id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\Product\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Product\Http\Requests\ProductForm;
|
||||
use Webkul\Category\Repositories\CategoryRepository;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
namespace Webkul\Product\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository;
|
||||
|
||||
/**
|
||||
* Review controller
|
||||
|
|
@ -16,7 +13,6 @@ use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
|||
*/
|
||||
class ReviewController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Contains route related configuration
|
||||
*
|
||||
|
|
@ -24,32 +20,24 @@ class ReviewController extends Controller
|
|||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* ProductRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* ProductReviewRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $productReview;
|
||||
protected $productReviewRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $product
|
||||
* @param \Webkul\Product\Repositories\ProductReviewRepository $productReview
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Product $product, ProductReview $productReview)
|
||||
public function __construct(
|
||||
ProductReviewRepository $productReviewRepository
|
||||
)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
$this->productReview = $productReview;
|
||||
$this->productReviewRepository = $productReviewRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -72,23 +60,22 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$review = $this->productReview->findOrFail($id);
|
||||
$review = $this->productReviewRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'],compact('review'));
|
||||
return view($this->_config['view'], compact('review'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
Event::fire('customer.review.update.before', $id);
|
||||
|
||||
$this->productReview->update(request()->all(), $id);
|
||||
$this->productReviewRepository->update(request()->all(), $id);
|
||||
|
||||
Event::fire('customer.review.update.after', $id);
|
||||
|
||||
|
|
@ -105,12 +92,12 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$productReview = $this->productReview->findOrFail($id);
|
||||
$productReview = $this->productReviewRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::fire('customer.review.delete.before', $id);
|
||||
|
||||
$this->productReview->delete($id);
|
||||
$this->productReviewRepository->delete($id);
|
||||
|
||||
Event::fire('customer.review.delete.after', $id);
|
||||
|
||||
|
|
@ -129,7 +116,8 @@ class ReviewController extends Controller
|
|||
*
|
||||
* @return response
|
||||
*/
|
||||
public function massDestroy() {
|
||||
public function massDestroy()
|
||||
{
|
||||
$suppressFlash = false;
|
||||
|
||||
if (request()->isMethod('post')) {
|
||||
|
|
@ -141,7 +129,7 @@ class ReviewController extends Controller
|
|||
try {
|
||||
Event::fire('customer.review.delete.before', $value);
|
||||
|
||||
$this->productReview->delete($value);
|
||||
$this->productReviewRepository->delete($value);
|
||||
|
||||
Event::fire('customer.review.delete.after', $value);
|
||||
} catch(\Exception $e) {
|
||||
|
|
@ -170,7 +158,8 @@ class ReviewController extends Controller
|
|||
*
|
||||
* @return response
|
||||
*/
|
||||
public function massUpdate() {
|
||||
public function massUpdate()
|
||||
{
|
||||
$suppressFlash = false;
|
||||
|
||||
if (request()->isMethod('post')) {
|
||||
|
|
@ -179,7 +168,7 @@ class ReviewController extends Controller
|
|||
$indexes = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($indexes as $key => $value) {
|
||||
$review = $this->productReview->findOneByField('id', $value);
|
||||
$review = $this->productReviewRepository->findOneByField('id', $value);
|
||||
|
||||
try {
|
||||
if ($data['massaction-type'] == 'update') {
|
||||
|
|
|
|||
|
|
@ -20,17 +20,20 @@ class ProductAttributeValueRepository extends Repository
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attribute;
|
||||
protected $attributeRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AttributeRepository $attribute, App $app)
|
||||
public function __construct(
|
||||
AttributeRepository $attributeRepository,
|
||||
App $app
|
||||
)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
$this->attributeRepository = $attributeRepository;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
|
@ -52,9 +55,9 @@ class ProductAttributeValueRepository extends Repository
|
|||
public function create(array $data)
|
||||
{
|
||||
if (isset($data['attribute_id'])) {
|
||||
$attribute = $this->attribute->find($data['attribute_id']);
|
||||
$attribute = $this->attributeRepository->find($data['attribute_id']);
|
||||
} else {
|
||||
$attribute = $this->attribute->findOneByField('code', $data['attribute_code']);
|
||||
$attribute = $this->attributeRepository->findOneByField('code', $data['attribute_code']);
|
||||
}
|
||||
|
||||
if (! $attribute)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
|
||||
/**
|
||||
* Product Repository
|
||||
|
|
@ -14,23 +12,6 @@ use Webkul\Product\Repositories\ProductRepository as Product;
|
|||
*/
|
||||
class ProductFlatRepository extends Repository
|
||||
{
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* Price Object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $price;
|
||||
|
||||
public function __construct(
|
||||
Product $product,
|
||||
App $app
|
||||
) {
|
||||
$this->product = $product;
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
public function model()
|
||||
{
|
||||
return 'Webkul\Product\Contracts\ProductFlat';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace Webkul\Product\Repositories;
|
|||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
/**
|
||||
* Product Review Reposotory
|
||||
|
|
@ -14,28 +13,6 @@ use Webkul\Product\Repositories\ProductRepository;
|
|||
*/
|
||||
class ProductReviewRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* ProductImageRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
ProductRepository $product,
|
||||
App $app)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace Webkul\Product\Repositories;
|
|||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
/**
|
||||
* Search Reposotory
|
||||
|
|
@ -15,17 +15,26 @@ use Webkul\Product\Repositories\ProductRepository as Product;
|
|||
class SearchRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
* ProductRepository object
|
||||
*
|
||||
* @return mixed
|
||||
* @return Object
|
||||
*/
|
||||
protected $product;
|
||||
protected $productRepository;
|
||||
|
||||
|
||||
public function __construct(App $app, Product $product) {
|
||||
/**
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
ProductRepository $productRepository,
|
||||
App $app
|
||||
)
|
||||
{
|
||||
parent::__construct($app);
|
||||
|
||||
$this->product = $product;
|
||||
$this->productRepository = $productRepository;
|
||||
}
|
||||
|
||||
function model()
|
||||
|
|
@ -42,13 +51,13 @@ class SearchRepository extends Repository
|
|||
$searchTerm = explode("?", $query);
|
||||
$serachQuery = '';
|
||||
|
||||
foreach($searchTerm as $term){
|
||||
foreach ($searchTerm as $term) {
|
||||
if (strpos($term, 'term') !== false) {
|
||||
$serachQuery = last(explode("=", $term));
|
||||
}
|
||||
}
|
||||
|
||||
$products = $this->product->searchProductByAttribute($serachQuery);
|
||||
$products = $this->productRepository->searchProductByAttribute($serachQuery);
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,16 @@ abstract class AbstractType
|
|||
*/
|
||||
abstract public function isStockable();
|
||||
|
||||
/**
|
||||
* Return true if item can be moved to cart from wishlist
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canBeMovedFromWishlistToCart()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve product attributes
|
||||
*
|
||||
|
|
|
|||
|
|
@ -57,6 +57,16 @@ class Simple extends AbstractType
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if item can be moved to cart from wishlist
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canBeMovedFromWishlistToCart()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -52,4 +52,14 @@ class Virtual extends AbstractType
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if item can be moved to cart from wishlist
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canBeMovedFromWishlistToCart()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,9 +7,9 @@ use Illuminate\Support\Facades\Event;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Sales\Contracts\Shipment;
|
||||
use Webkul\Sales\Repositories\OrderRepository as Order;
|
||||
use Webkul\Sales\Repositories\OrderItemRepository as OrderItem;
|
||||
use Webkul\Sales\Repositories\ShipmentItemRepository as ShipmentItem;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
use Webkul\Sales\Repositories\OrderItemRepository;
|
||||
use Webkul\Sales\Repositories\ShipmentItemRepository;
|
||||
|
||||
/**
|
||||
* Shipment Reposotory
|
||||
|
|
@ -17,7 +17,6 @@ use Webkul\Sales\Repositories\ShipmentItemRepository as ShipmentItem;
|
|||
* @author Jitendra Singh <jitendra@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
|
||||
class ShipmentRepository extends Repository
|
||||
{
|
||||
/**
|
||||
|
|
@ -25,42 +24,42 @@ class ShipmentRepository extends Repository
|
|||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $order;
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* OrderItemRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $orderItem;
|
||||
protected $orderItemRepository;
|
||||
|
||||
/**
|
||||
* ShipmentItemRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $shipmentItem;
|
||||
protected $shipmentItemRepository;
|
||||
|
||||
/**
|
||||
* Create a new repository instance.
|
||||
*
|
||||
* @param Webkul\Sales\Repositories\OrderRepository $order
|
||||
* @param Webkul\Sales\Repositories\OrderItemRepository $orderItem
|
||||
* @param Webkul\Sales\Repositories\ShipmentItemRepository $orderItem
|
||||
* @param Webkul\Sales\Repositories\OrderRepository $orderRepository
|
||||
* @param Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository
|
||||
* @param Webkul\Sales\Repositories\ShipmentItemRepository $orderItemRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
Order $order,
|
||||
OrderItem $orderItem,
|
||||
ShipmentItem $shipmentItem,
|
||||
OrderRepository $orderRepository,
|
||||
OrderItemRepository $orderItemRepository,
|
||||
ShipmentItemRepository $shipmentItemRepository,
|
||||
App $app
|
||||
)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->orderRepository = $orderRepository;
|
||||
|
||||
$this->orderItem = $orderItem;
|
||||
$this->orderItemRepository = $orderItemRepository;
|
||||
|
||||
$this->shipmentItem = $shipmentItem;
|
||||
$this->shipmentItemRepository = $shipmentItemRepository;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
|
@ -87,7 +86,7 @@ class ShipmentRepository extends Repository
|
|||
try {
|
||||
Event::fire('sales.shipment.save.before', $data);
|
||||
|
||||
$order = $this->order->find($data['order_id']);
|
||||
$order = $this->orderRepository->find($data['order_id']);
|
||||
|
||||
$shipment = $this->model->create([
|
||||
'order_id' => $order->id,
|
||||
|
|
@ -105,14 +104,14 @@ class ShipmentRepository extends Repository
|
|||
foreach ($data['shipment']['items'] as $itemId => $inventorySource) {
|
||||
$qty = $inventorySource[$data['shipment']['source']];
|
||||
|
||||
$orderItem = $this->orderItem->find($itemId);
|
||||
$orderItem = $this->orderItemRepository->find($itemId);
|
||||
|
||||
if ($qty > $orderItem->qty_to_ship)
|
||||
$qty = $orderItem->qty_to_ship;
|
||||
|
||||
$totalQty += $qty;
|
||||
|
||||
$shipmentItem = $this->shipmentItem->create([
|
||||
$shipmentItem = $this->shipmentItemRepository->create([
|
||||
'shipment_id' => $shipment->id,
|
||||
'order_item_id' => $orderItem->id,
|
||||
'name' => $orderItem->name,
|
||||
|
|
@ -134,7 +133,7 @@ class ShipmentRepository extends Repository
|
|||
? $orderItem->child->product
|
||||
: $orderItem->product;
|
||||
|
||||
$this->shipmentItem->updateProductInventory([
|
||||
$this->shipmentItemRepository->updateProductInventory([
|
||||
'shipment' => $shipment,
|
||||
'shipmentItem' => $shipmentItem,
|
||||
'product' => $product,
|
||||
|
|
@ -142,14 +141,14 @@ class ShipmentRepository extends Repository
|
|||
'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0
|
||||
]);
|
||||
|
||||
$this->orderItem->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id);
|
||||
$this->orderItemRepository->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id);
|
||||
}
|
||||
|
||||
$shipment->update([
|
||||
'total_qty' => $totalQty
|
||||
]);
|
||||
|
||||
$this->order->updateOrderStatus($order);
|
||||
$this->orderRepository->updateOrderStatus($order);
|
||||
|
||||
Event::fire('sales.shipment.save.after', $shipment);
|
||||
} catch (\Exception $e) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\Shop\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Checkout\Repositories\CartItemRepository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Customer\Repositories\WishlistRepository;
|
||||
|
|
@ -66,7 +64,6 @@ class CartController extends Controller
|
|||
WishlistRepository $wishlistRepository
|
||||
)
|
||||
{
|
||||
|
||||
$this->middleware('customer')->only(['moveToWishlist']);
|
||||
|
||||
$this->cartItemRepository = $cartItemRepository;
|
||||
|
|
|
|||
|
|
@ -14,9 +14,20 @@ use Webkul\Core\Repositories\SliderRepository;
|
|||
class HomeController extends Controller
|
||||
{
|
||||
protected $_config;
|
||||
protected $sliderRepository;
|
||||
protected $current_channel;
|
||||
|
||||
/**
|
||||
* SliderRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $sliderRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\SliderRepository $sliderRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(SliderRepository $sliderRepository)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
|
@ -30,6 +41,7 @@ use Webkul\Core\Repositories\SliderRepository;
|
|||
public function index()
|
||||
{
|
||||
$currentChannel = core()->getCurrentChannel();
|
||||
|
||||
$sliderData = $this->sliderRepository->findByField('channel_id', $currentChannel->id)->toArray();
|
||||
|
||||
return view($this->_config['view'], compact('sliderData'));
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@
|
|||
|
||||
namespace Webkul\Shop\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Sales\Repositories\OrderRepository;
|
||||
use Webkul\Sales\Repositories\InvoiceRepository;
|
||||
use Auth;
|
||||
use PDF;
|
||||
|
||||
/**
|
||||
|
|
@ -28,36 +25,36 @@ class OrderController extends Controller
|
|||
/**
|
||||
* OrderrRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $order;
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* InvoiceRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $invoice;
|
||||
protected $invoiceRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Order\Repositories\OrderRepository $order
|
||||
* @param \Webkul\Order\Repositories\InvoiceRepository $invoice
|
||||
* @param \Webkul\Order\Repositories\OrderRepository $orderRepository
|
||||
* @param \Webkul\Order\Repositories\InvoiceRepository $invoiceRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
OrderRepository $order,
|
||||
InvoiceRepository $invoice
|
||||
OrderRepository $orderRepository,
|
||||
InvoiceRepository $invoiceRepository
|
||||
)
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->order = $order;
|
||||
$this->orderRepository = $orderRepository;
|
||||
|
||||
$this->invoice = $invoice;
|
||||
$this->invoiceRepository = $invoiceRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,7 +75,7 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$order = $this->order->findOneWhere([
|
||||
$order = $this->orderRepository->findOneWhere([
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
'id' => $id
|
||||
]);
|
||||
|
|
@ -97,7 +94,7 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function print($id)
|
||||
{
|
||||
$invoice = $this->invoice->findOrFail($id);
|
||||
$invoice = $this->invoiceRepository->findOrFail($id);
|
||||
|
||||
$pdf = PDF::loadView('shop::customers.account.orders.pdf', compact('invoice'))->setPaper('a4');
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Shop\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository;
|
||||
|
||||
/**
|
||||
* Review controller
|
||||
|
|
@ -15,7 +13,6 @@ use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
|||
*/
|
||||
class ReviewController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Contains route related configuration
|
||||
*
|
||||
|
|
@ -26,29 +23,32 @@ class ReviewController extends Controller
|
|||
/**
|
||||
* ProductRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $product;
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* ProductReviewRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $productReview;
|
||||
protected $productReviewRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $product
|
||||
* @param \Webkul\Product\Repositories\ProductReviewRepository $productReview
|
||||
* @param \Webkul\Product\Repositories\ProductRepository $productRepository
|
||||
* @param \Webkul\Product\Repositories\ProductReviewRepository $productReviewRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Product $product, ProductReview $productReview)
|
||||
public function __construct(
|
||||
ProductRepository $productRepository,
|
||||
ProductReviewRepository $productReviewRepository
|
||||
)
|
||||
{
|
||||
$this->product = $product;
|
||||
$this->productRepository = $productRepository;
|
||||
|
||||
$this->productReview = $productReview;
|
||||
$this->productReviewRepository = $productReviewRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function create($slug)
|
||||
{
|
||||
$product = $this->product->findBySlugOrFail($slug);
|
||||
$product = $this->productRepository->findBySlugOrFail($slug);
|
||||
|
||||
$guest_review = core()->getConfigData('catalog.products.review.guest_review');
|
||||
|
||||
|
|
@ -71,10 +71,10 @@ class ReviewController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request , $id)
|
||||
public function store($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'comment' => 'required',
|
||||
|
|
@ -92,7 +92,7 @@ class ReviewController extends Controller
|
|||
$data['status'] = 'pending';
|
||||
$data['product_id'] = $id;
|
||||
|
||||
$this->productReview->create($data);
|
||||
$this->productReviewRepository->create($data);
|
||||
|
||||
session()->flash('success', trans('shop::app.response.submit-success', ['name' => 'Product Review']));
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function show($slug)
|
||||
{
|
||||
$product = $this->product->findBySlugOrFail($slug);
|
||||
$product = $this->productRepository->findBySlugOrFail($slug);
|
||||
|
||||
return view($this->_config['view'],compact('product'));
|
||||
}
|
||||
|
|
@ -115,11 +115,12 @@ class ReviewController extends Controller
|
|||
/**
|
||||
* Customer delete a reviews from their account
|
||||
*
|
||||
* @param integer $id
|
||||
* @return response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$review = $this->productReview->findOneWhere([
|
||||
$review = $this->productReviewRepository->findOneWhere([
|
||||
'id' => $id,
|
||||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
]);
|
||||
|
|
@ -127,7 +128,7 @@ class ReviewController extends Controller
|
|||
if (! $review)
|
||||
abort(404);
|
||||
|
||||
$this->productReview->delete($id);
|
||||
$this->productReviewRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('shop::app.response.delete-success', ['name' => 'Product Review']));
|
||||
|
||||
|
|
@ -139,12 +140,13 @@ class ReviewController extends Controller
|
|||
*
|
||||
* @return Mixed Response & Boolean
|
||||
*/
|
||||
public function deleteAll() {
|
||||
public function deleteAll()
|
||||
{
|
||||
$reviews = auth()->guard('customer')->user()->all_reviews;
|
||||
|
||||
if ($reviews->count() > 0) {
|
||||
foreach ($reviews as $review) {
|
||||
$this->productReview->delete($review->id);
|
||||
$this->productReviewRepository->delete($review->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,7 @@
|
|||
|
||||
namespace Webkul\Shop\Http\Controllers;
|
||||
|
||||
use Webkul\Shop\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
use Webkul\Product\Repositories\SearchRepository as Search;
|
||||
use Webkul\Product\Repositories\SearchRepository;
|
||||
|
||||
/**
|
||||
* Search controller
|
||||
|
|
@ -14,18 +10,33 @@ use Webkul\Product\Repositories\SearchRepository as Search;
|
|||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
|
||||
class SearchController extends controller
|
||||
class SearchController extends Controller
|
||||
{
|
||||
/**
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
protected $search;
|
||||
/**
|
||||
* SearchRepository object
|
||||
*
|
||||
* @var Object
|
||||
*/
|
||||
protected $searchRepository;
|
||||
|
||||
public function __construct(Search $search)
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Product\Repositories\SearchRepository $searchRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(SearchRepository $searchRepository)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->search = $search;
|
||||
$this->searchRepository = $searchRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -33,15 +44,8 @@ use Webkul\Product\Repositories\SearchRepository as Search;
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$results = null;
|
||||
|
||||
$results = $this->search->search(request()->all());
|
||||
|
||||
if ($results->count()) {
|
||||
return view($this->_config['view'])->with('results', $results);
|
||||
} else {
|
||||
return view($this->_config['view'])->with('results', null);
|
||||
}
|
||||
$results = $this->searchRepository->search(request()->all());
|
||||
|
||||
return view($this->_config['view'])->with('results', $results->count() ? $results : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,9 @@
|
|||
|
||||
namespace Webkul\Shop\Http\Controllers;
|
||||
|
||||
use Webkul\Shop\Http\Controllers\Controller;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Webkul\Shop\Mail\SubscriptionEmail;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
use Webkul\Core\Repositories\SubscribersListRepository as Subscription;
|
||||
use Webkul\Core\Repositories\SubscribersListRepository;
|
||||
|
||||
/**
|
||||
* Subscription controller
|
||||
|
|
@ -20,34 +15,28 @@ use Webkul\Core\Repositories\SubscribersListRepository as Subscription;
|
|||
class SubscriptionController extends Controller
|
||||
{
|
||||
/**
|
||||
* User object
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $user;
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* Customer Repository object
|
||||
* SubscribersListRepository
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* Subscription List Repository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $subscription;
|
||||
protected $subscriptionRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\SubscribersListRepository $subscriptionRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Customer $customer, Subscription $subscription)
|
||||
public function __construct(SubscribersListRepository $subscriptionRepository)
|
||||
{
|
||||
$this->subscription = $subscription;
|
||||
$this->subscriptionRepository = $subscriptionRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -65,14 +54,10 @@ class SubscriptionController extends Controller
|
|||
|
||||
$unique = 0;
|
||||
|
||||
$alreadySubscribed = $this->subscription->findWhere(['email' => $email]);
|
||||
$alreadySubscribed = $this->subscriptionRepository->findWhere(['email' => $email]);
|
||||
|
||||
$unique = function () use ($alreadySubscribed) {
|
||||
if ($alreadySubscribed->count() > 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return $alreadySubscribed->count() > 0 ? 0 : 1;
|
||||
};
|
||||
|
||||
if ($unique()) {
|
||||
|
|
@ -96,14 +81,14 @@ class SubscriptionController extends Controller
|
|||
$result = false;
|
||||
|
||||
if ($mailSent) {
|
||||
$result = $this->subscription->create([
|
||||
$result = $this->subscriptionRepository->create([
|
||||
'email' => $email,
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'is_subscribed' => 1,
|
||||
'token' => $token
|
||||
]);
|
||||
|
||||
if (!$result) {
|
||||
if (! $result) {
|
||||
session()->flash('error', trans('shop::app.subscription.not-subscribed'));
|
||||
|
||||
return redirect()->back();
|
||||
|
|
@ -123,14 +108,15 @@ class SubscriptionController extends Controller
|
|||
*/
|
||||
public function unsubscribe($token)
|
||||
{
|
||||
$subscriber = $this->subscription->findOneByField('token', $token);
|
||||
$subscriber = $this->subscriptionRepository->findOneByField('token', $token);
|
||||
|
||||
if (isset($subscriber))
|
||||
if (isset($subscriber)) {
|
||||
if ($subscriber->count() > 0 && $subscriber->is_subscribed == 1 && $subscriber->update(['is_subscribed' => 0])) {
|
||||
session()->flash('info', trans('shop::app.subscription.unsubscribed'));
|
||||
} else {
|
||||
session()->flash('info', trans('shop::app.subscription.already-unsub'));
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('shop.home.index');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -363,6 +363,7 @@ return [
|
|||
'add' => 'Item successfully added to wishlist',
|
||||
'remove' => 'Item successfully removed from wishlist',
|
||||
'moved' => 'Item successfully moved To cart',
|
||||
'option-missing' => 'Product options are missing, so item can not be moved to the wishlist.',
|
||||
'move-error' => 'Item cannot be moved to wishlist, Please try again later',
|
||||
'success' => 'Item successfully added to wishlist',
|
||||
'failure' => 'Item cannot be added to wishlist, Please try again later',
|
||||
|
|
|
|||
|
|
@ -2,13 +2,9 @@
|
|||
|
||||
namespace Webkul\Tax\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Channel as Channel;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository as TaxCategory;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxMapRepository as TaxMap;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository;
|
||||
|
||||
/**
|
||||
* Tax controller
|
||||
|
|
@ -28,43 +24,32 @@ class TaxCategoryController extends Controller
|
|||
/**
|
||||
* TaxCategoryRepository
|
||||
*
|
||||
* @var mixed
|
||||
* @var Object
|
||||
*/
|
||||
protected $taxCategory;
|
||||
protected $taxCategoryRepository;
|
||||
|
||||
/**
|
||||
* TaxRateRepository
|
||||
*
|
||||
* @var mixed
|
||||
* @var Object
|
||||
*/
|
||||
protected $taxRate;
|
||||
|
||||
/**
|
||||
* TaxMapRepository
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $taxMap;
|
||||
protected $taxRateRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategory
|
||||
* @param \Webkul\Tax\Repositories\TaxRateRepository $taxRate
|
||||
* @param \Webkul\Tax\Repositories\TaxMapRepository $taxMap
|
||||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategoryRepository
|
||||
* @param \Webkul\Tax\Repositories\TaxRateRepository $taxRateRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
TaxCategory $taxCategory,
|
||||
TaxRate $taxRate,
|
||||
TaxMap $taxMap
|
||||
TaxCategoryRepository $taxCategoryRepository,
|
||||
TaxRateRepository $taxRateRepository
|
||||
)
|
||||
{
|
||||
$this->taxCategory = $taxCategory;
|
||||
$this->taxCategoryRepository = $taxCategoryRepository;
|
||||
|
||||
$this->taxRate = $taxRate;
|
||||
|
||||
$this->taxMap = $taxMap;
|
||||
$this->taxRateRepository = $taxRateRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -77,7 +62,7 @@ class TaxCategoryController extends Controller
|
|||
*/
|
||||
public function show()
|
||||
{
|
||||
return view($this->_config['view'])->with('taxRates', $this->taxRate->all());
|
||||
return view($this->_config['view'])->with('taxRates', $this->taxRateRepository->all());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -100,10 +85,10 @@ class TaxCategoryController extends Controller
|
|||
|
||||
Event::fire('tax.tax_category.create.before');
|
||||
|
||||
$taxCategory = $this->taxCategory->create($data);
|
||||
$taxCategory = $this->taxCategoryRepository->create($data);
|
||||
|
||||
//attach the categories in the tax map table
|
||||
$this->taxCategory->attachOrDetach($taxCategory, $data['taxrates']);
|
||||
$this->taxCategoryRepository->attachOrDetach($taxCategory, $data['taxrates']);
|
||||
|
||||
Event::fire('tax.tax_category.create.after', $taxCategory);
|
||||
|
||||
|
|
@ -120,7 +105,7 @@ class TaxCategoryController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$taxCategory = $this->taxCategory->findOrFail($id);
|
||||
$taxCategory = $this->taxCategoryRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('taxCategory'));
|
||||
}
|
||||
|
|
@ -145,7 +130,7 @@ class TaxCategoryController extends Controller
|
|||
|
||||
Event::fire('tax.tax_category.update.before', $id);
|
||||
|
||||
$taxCategory = $this->taxCategory->update($data, $id);
|
||||
$taxCategory = $this->taxCategoryRepository->update($data, $id);
|
||||
|
||||
Event::fire('tax.tax_category.update.after', $taxCategory);
|
||||
|
||||
|
|
@ -158,7 +143,7 @@ class TaxCategoryController extends Controller
|
|||
$taxRates = $data['taxrates'];
|
||||
|
||||
//attach the categories in the tax map table
|
||||
$this->taxCategory->attachOrDetach($taxCategory, $taxRates);
|
||||
$this->taxCategoryRepository->attachOrDetach($taxCategory, $taxRates);
|
||||
|
||||
session()->flash('success', trans('admin::app.settings.tax-categories.update-success'));
|
||||
|
||||
|
|
@ -173,12 +158,12 @@ class TaxCategoryController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$taxCategory = $this->taxCategory->findOrFail($id);
|
||||
$taxCategory = $this->taxCategoryRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::fire('tax.tax_category.delete.before', $id);
|
||||
|
||||
$this->taxCategory->delete($id);
|
||||
$this->taxCategoryRepository->delete($id);
|
||||
|
||||
Event::fire('tax.tax_category.delete.after', $id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,6 @@
|
|||
|
||||
namespace Webkul\Tax\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Core\Repositories\ChannelRepository as Channel;
|
||||
use Webkul\Tax\Repositories\TaxCategoryRepository as TaxCategory;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxMapRepository as TaxMap;
|
||||
|
||||
|
||||
/**
|
||||
* Tax controller
|
||||
*
|
||||
|
|
@ -25,55 +17,15 @@ class TaxController extends Controller
|
|||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* ChannelRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $channel;
|
||||
|
||||
/**
|
||||
* Tax Category Repository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $taxCategory;
|
||||
|
||||
/**
|
||||
* Tax Rate Repository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $taxRate;
|
||||
|
||||
/**
|
||||
* Tax Map Repository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $taxMap;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Core\Repositories\ChannelRepository $channel
|
||||
* @param \Webkul\Tax\Repositories\TaxCategoryRepository $taxCategory
|
||||
* @param \Webkul\Tax\Repositories\TaxRateRepository $taxRate
|
||||
* @param \Webkul\Tax\Repositories\TaxMapRepository $taxMap
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Channel $channel, TaxCategory $taxCategory, TaxRate $taxRate, TaxMap $taxMap)
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->channel = $channel;
|
||||
|
||||
$this->taxCategory = $taxCategory;
|
||||
|
||||
$this->taxRate = $taxRate;
|
||||
|
||||
$this->taxMap = $taxMap;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\Tax\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository as TaxRate;
|
||||
use Webkul\Tax\Repositories\TaxRateRepository;
|
||||
use Webkul\Admin\Imports\DataGridImport;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Excel;
|
||||
|
|
@ -27,21 +25,21 @@ class TaxRateController extends Controller
|
|||
protected $_config;
|
||||
|
||||
/**
|
||||
* Tax Rate Repository object
|
||||
* TaxRateRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $taxRate;
|
||||
protected $taxRateRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\Tax\Repositories\TaxRateRepository $taxRate
|
||||
* @param \Webkul\Tax\Repositories\TaxRateRepository $taxRateRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(TaxRate $taxRate)
|
||||
public function __construct(TaxRateRepository $taxRateRepository)
|
||||
{
|
||||
$this->taxRate = $taxRate;
|
||||
$this->taxRateRepository = $taxRateRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -96,7 +94,7 @@ class TaxRateController extends Controller
|
|||
|
||||
Event::fire('tax.tax_rate.create.before');
|
||||
|
||||
$taxRate = $this->taxRate->create($data);
|
||||
$taxRate = $this->taxRateRepository->create($data);
|
||||
|
||||
Event::fire('tax.tax_rate.create.after', $taxRate);
|
||||
|
||||
|
|
@ -114,7 +112,7 @@ class TaxRateController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$taxRate = $this->taxRate->findOrFail($id);
|
||||
$taxRate = $this->taxRateRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'])->with('taxRate', $taxRate);
|
||||
}
|
||||
|
|
@ -139,7 +137,7 @@ class TaxRateController extends Controller
|
|||
|
||||
Event::fire('tax.tax_rate.update.before', $id);
|
||||
|
||||
$taxRate = $this->taxRate->update(request()->input(), $id);
|
||||
$taxRate = $this->taxRateRepository->update(request()->input(), $id);
|
||||
|
||||
Event::fire('tax.tax_rate.update.after', $taxRate);
|
||||
|
||||
|
|
@ -156,12 +154,12 @@ class TaxRateController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$taxRate = $this->taxRate->findOrFail($id);
|
||||
$taxRate = $this->taxRateRepository->findOrFail($id);
|
||||
|
||||
try {
|
||||
Event::fire('tax.tax_rate.delete.before', $id);
|
||||
|
||||
$this->taxRate->delete($id);
|
||||
$this->taxRateRepository->delete($id);
|
||||
|
||||
Event::fire('tax.tax_rate.delete.after', $id);
|
||||
|
||||
|
|
@ -184,7 +182,7 @@ class TaxRateController extends Controller
|
|||
|
||||
$valid_extension = ['xlsx', 'csv', 'xls'];
|
||||
|
||||
if (!in_array(request()->file('file')->getClientOriginalExtension(), $valid_extension)) {
|
||||
if (! in_array(request()->file('file')->getClientOriginalExtension(), $valid_extension)) {
|
||||
session()->flash('error', trans('admin::app.export.upload-error'));
|
||||
} else {
|
||||
try {
|
||||
|
|
@ -226,6 +224,7 @@ class TaxRateController extends Controller
|
|||
foreach ($filtered as $position => $identifier) {
|
||||
$message[] = trans('admin::app.export.duplicate-error', ['identifier' => $identifier, 'position' => $position]);
|
||||
}
|
||||
|
||||
$finalMsg = implode(" ", $message);
|
||||
|
||||
session()->flash('error', $finalMsg);
|
||||
|
|
@ -260,7 +259,7 @@ class TaxRateController extends Controller
|
|||
|
||||
session()->flash('error', $finalMsg);
|
||||
} else {
|
||||
$taxRate = $this->taxRate->get()->toArray();
|
||||
$taxRate = $this->taxRateRepository->get()->toArray();
|
||||
|
||||
foreach ($taxRate as $rate) {
|
||||
$rateIdentifier[$rate['id']] = $rate['identifier'];
|
||||
|
|
@ -276,12 +275,12 @@ class TaxRateController extends Controller
|
|||
if (isset($rateIdentifier)) {
|
||||
$id = array_search($uploadData['identifier'], $rateIdentifier);
|
||||
if ($id) {
|
||||
$this->taxRate->update($uploadData, $id);
|
||||
$this->taxRateRepository->update($uploadData, $id);
|
||||
} else {
|
||||
$this->taxRate->create($uploadData);
|
||||
$this->taxRateRepository->create($uploadData);
|
||||
}
|
||||
} else {
|
||||
$this->taxRate->create($uploadData);
|
||||
$this->taxRateRepository->create($uploadData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ class TaxCategoryRepository extends Repository
|
|||
return 'Webkul\Tax\Contracts\TaxCategory';
|
||||
}
|
||||
|
||||
public function attachOrDetach($taxCategory, $data) {
|
||||
public function attachOrDetach($taxCategory, $data)
|
||||
{
|
||||
$taxRates = $taxCategory->tax_rates;
|
||||
|
||||
$this->model->findOrFail($taxCategory->id)->tax_rates()->sync($data);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\User\Http\Controllers\Controller;
|
||||
use Hash;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
|
|
@ -15,7 +13,6 @@ use Illuminate\Support\Facades\Password;
|
|||
*/
|
||||
class ForgetPasswordController extends Controller
|
||||
{
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
|
@ -18,7 +16,6 @@ use Illuminate\Support\Str;
|
|||
*/
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
|
|
@ -43,14 +40,13 @@ class ResetPasswordController extends Controller
|
|||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $token
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function create(Request $request, $token = null)
|
||||
public function create($token = null)
|
||||
{
|
||||
return view($this->_config['view'])->with(
|
||||
['token' => $token, 'email' => $request->email]
|
||||
['token' => $token, 'email' => request('email')]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -113,5 +109,4 @@ class ResetPasswordController extends Controller
|
|||
{
|
||||
return Password::broker('admins');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\User\Repositories\RoleRepository as Role;
|
||||
use Webkul\User\Repositories\RoleRepository;
|
||||
|
||||
/**
|
||||
* Admin user role controller
|
||||
|
|
@ -27,19 +25,19 @@ class RoleController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $role;
|
||||
protected $roleRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\User\Repositories\RoleRepository $role
|
||||
* @param \Webkul\User\Repositories\RoleRepository $roleRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Role $role)
|
||||
public function __construct(RoleRepository $roleRepository)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->role = $role;
|
||||
$this->roleRepository = $roleRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
}
|
||||
|
|
@ -67,10 +65,9 @@ class RoleController extends Controller
|
|||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'name' => 'required',
|
||||
|
|
@ -79,7 +76,7 @@ class RoleController extends Controller
|
|||
|
||||
Event::fire('user.role.create.before');
|
||||
|
||||
$role = $this->role->create(request()->all());
|
||||
$role = $this->roleRepository->create(request()->all());
|
||||
|
||||
Event::fire('user.role.create.after', $role);
|
||||
|
||||
|
|
@ -96,7 +93,7 @@ class RoleController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$role = $this->role->findOrFail($id);
|
||||
$role = $this->roleRepository->findOrFail($id);
|
||||
|
||||
return view($this->_config['view'], compact('role'));
|
||||
}
|
||||
|
|
@ -104,11 +101,10 @@ class RoleController extends Controller
|
|||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update($id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'name' => 'required',
|
||||
|
|
@ -117,7 +113,7 @@ class RoleController extends Controller
|
|||
|
||||
Event::fire('user.role.update.before', $id);
|
||||
|
||||
$role = $this->role->update(request()->all(), $id);
|
||||
$role = $this->roleRepository->update(request()->all(), $id);
|
||||
|
||||
Event::fire('user.role.update.after', $role);
|
||||
|
||||
|
|
@ -134,17 +130,17 @@ class RoleController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$role = $this->role->findOrFail($id);
|
||||
$role = $this->roleRepository->findOrFail($id);
|
||||
|
||||
if ($role->admins->count() >= 1) {
|
||||
session()->flash('error', trans('admin::app.response.being-used', ['name' => 'Role', 'source' => 'Admin User']));
|
||||
} else if($this->role->count() == 1) {
|
||||
} else if($this->roleRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Role']));
|
||||
} else {
|
||||
try {
|
||||
Event::fire('user.role.delete.before', $id);
|
||||
|
||||
$this->role->delete($id);
|
||||
$this->roleRepository->delete($id);
|
||||
|
||||
Event::fire('user.role.delete.after', $id);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace Webkul\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Webkul\User\Repositories\AdminRepository as Admin;
|
||||
use Webkul\User\Repositories\RoleRepository as Role;
|
||||
use Webkul\User\Repositories\AdminRepository;
|
||||
use Webkul\User\Repositories\RoleRepository;
|
||||
use Webkul\User\Http\Requests\UserForm;
|
||||
use Hash;
|
||||
|
||||
|
|
@ -28,29 +26,32 @@ class UserController extends Controller
|
|||
/**
|
||||
* AdminRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $admin;
|
||||
protected $adminRepository;
|
||||
|
||||
/**
|
||||
* RoleRepository object
|
||||
*
|
||||
* @var array
|
||||
* @var Object
|
||||
*/
|
||||
protected $role;
|
||||
protected $roleRepository;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param \Webkul\User\Repositories\AdminRepository $admin
|
||||
* @param \Webkul\User\Repositories\RoleRepository $role
|
||||
* @param \Webkul\User\Repositories\AdminRepository $adminRepository
|
||||
* @param \Webkul\User\Repositories\RoleRepository $roleRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Admin $admin, Role $role)
|
||||
public function __construct(
|
||||
AdminRepository $adminRepository,
|
||||
RoleRepository $roleRepository
|
||||
)
|
||||
{
|
||||
$this->admin = $admin;
|
||||
$this->adminRepository = $adminRepository;
|
||||
|
||||
$this->role = $role;
|
||||
$this->roleRepository = $roleRepository;
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
|
|
@ -74,7 +75,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
$roles = $this->role->all();
|
||||
$roles = $this->roleRepository->all();
|
||||
|
||||
return view($this->_config['view'], compact('roles'));
|
||||
}
|
||||
|
|
@ -94,7 +95,7 @@ class UserController extends Controller
|
|||
|
||||
Event::fire('user.admin.create.before');
|
||||
|
||||
$admin = $this->admin->create($data);
|
||||
$admin = $this->adminRepository->create($data);
|
||||
|
||||
Event::fire('user.admin.delete.after', $admin);
|
||||
|
||||
|
|
@ -111,9 +112,9 @@ class UserController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$user = $this->admin->findOrFail($id);
|
||||
$user = $this->adminRepository->findOrFail($id);
|
||||
|
||||
$roles = $this->role->all();
|
||||
$roles = $this->roleRepository->all();
|
||||
|
||||
return view($this->_config['view'], compact('user', 'roles'));
|
||||
}
|
||||
|
|
@ -142,7 +143,7 @@ class UserController extends Controller
|
|||
|
||||
Event::fire('user.admin.update.before', $id);
|
||||
|
||||
$admin = $this->admin->update($data, $id);
|
||||
$admin = $this->adminRepository->update($data, $id);
|
||||
|
||||
Event::fire('user.admin.update.after', $admin);
|
||||
|
||||
|
|
@ -159,9 +160,9 @@ class UserController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$user = $this->admin->findOrFail($id);
|
||||
$user = $this->adminRepository->findOrFail($id);
|
||||
|
||||
if ($this->admin->count() == 1) {
|
||||
if ($this->adminRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Admin']));
|
||||
} else {
|
||||
Event::fire('user.admin.delete.before', $id);
|
||||
|
|
@ -171,7 +172,7 @@ class UserController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
$this->admin->delete($id);
|
||||
$this->adminRepository->delete($id);
|
||||
|
||||
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Admin']));
|
||||
|
||||
|
|
@ -196,14 +197,14 @@ class UserController extends Controller
|
|||
$password = request()->input('password');
|
||||
|
||||
if (Hash::check($password, auth()->guard('admin')->user()->password)) {
|
||||
if ($this->admin->count() == 1) {
|
||||
if ($this->adminRepository->count() == 1) {
|
||||
session()->flash('error', trans('admin::app.users.users.delete-last'));
|
||||
} else {
|
||||
$id = auth()->guard('admin')->user()->id;
|
||||
|
||||
Event::fire('user.admin.delete.before', $id);
|
||||
|
||||
$this->admin->delete($id);
|
||||
$this->adminRepository->delete($id);
|
||||
|
||||
Event::fire('user.admin.delete.after', $id);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
Loading…
Reference in New Issue