Improved admin package code standard
This commit is contained in:
parent
b4c68c7f0b
commit
99d506db94
|
|
@ -5,7 +5,6 @@ namespace Webkul\Admin\Exceptions;
|
|||
use Exception;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Database\Eloquent\PDOException;
|
||||
use Illuminate\Database\Eloquent\ErrorException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
|
|
|||
|
|
@ -12,16 +12,14 @@ use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|||
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
|
||||
class DataGridExport implements FromView, ShouldAutoSize
|
||||
{
|
||||
|
||||
/**
|
||||
* DataGrid instance
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $gridData = array();
|
||||
protected $gridData = [];
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
|
|
@ -40,7 +38,7 @@ class DataGridExport implements FromView, ShouldAutoSize
|
|||
*/
|
||||
public function view(): View
|
||||
{
|
||||
$columns = array();
|
||||
$columns = [];
|
||||
|
||||
foreach($this->gridData as $key => $gridData) {
|
||||
$columns = array_keys((array) $gridData);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ class ConfigurationController extends Controller
|
|||
$this->_config = request('_config');
|
||||
|
||||
$this->prepareConfigTree();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ class AddressController extends Controller
|
|||
$address = $this->customerAddress->find($id);
|
||||
|
||||
if ($address) {
|
||||
|
||||
$this->customerAddress->update($data, $id);
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.addresses.success-update'));
|
||||
|
|
|
|||
|
|
@ -225,9 +225,7 @@ class CustomerController extends Controller
|
|||
|
||||
$customer = $this->customerRepository->find(request()->input('_customer'));
|
||||
|
||||
$noteTaken = $customer->update([
|
||||
'notes' => request()->input('notes'),
|
||||
]);
|
||||
$noteTaken = $customer->update(['notes' => request()->input('notes')]);
|
||||
|
||||
if ($noteTaken) {
|
||||
session()->flash('success', 'Note taken');
|
||||
|
|
@ -251,9 +249,7 @@ class CustomerController extends Controller
|
|||
foreach ($customerIds as $customerId) {
|
||||
$customer = $this->customerRepository->find($customerId);
|
||||
|
||||
$customer->update([
|
||||
'status' => $updateOption,
|
||||
]);
|
||||
$customer->update(['status' => $updateOption]);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.customers.mass-update-success'));
|
||||
|
|
@ -271,9 +267,7 @@ class CustomerController extends Controller
|
|||
$customerIds = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$this->customerRepository->deleteWhere([
|
||||
'id' => $customerId,
|
||||
]);
|
||||
$this->customerRepository->deleteWhere(['id' => $customerId]);
|
||||
}
|
||||
|
||||
session()->flash('success', trans('admin::app.customers.customers.mass-destroy-success'));
|
||||
|
|
|
|||
|
|
@ -116,8 +116,9 @@ class DashboardController extends Controller
|
|||
*/
|
||||
public function getPercentageChange($previous, $current)
|
||||
{
|
||||
if (! $previous)
|
||||
if (! $previous) {
|
||||
return $current ? 100 : 0;
|
||||
}
|
||||
|
||||
return ($current - $previous) / $previous * 100;
|
||||
}
|
||||
|
|
@ -264,8 +265,9 @@ class DashboardController extends Controller
|
|||
? Carbon::createFromTimeString(request()->get('end') . " 23:59:59")
|
||||
: Carbon::now();
|
||||
|
||||
if ($this->endDate > Carbon::now())
|
||||
if ($this->endDate > Carbon::now()) {
|
||||
$this->endDate = Carbon::now();
|
||||
}
|
||||
|
||||
$this->lastStartDate = clone $this->startDate;
|
||||
$this->lastEndDate = clone $this->startDate;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class ExportController extends Controller
|
|||
$format = $criteria['format'];
|
||||
|
||||
$gridName = explode('\\', $criteria['gridName']);
|
||||
|
||||
$path = '\Webkul\Admin\DataGrids'.'\\'.last($gridName);
|
||||
|
||||
$proceed = false;
|
||||
|
|
@ -53,6 +54,7 @@ class ExportController extends Controller
|
|||
}
|
||||
|
||||
$gridInstance = new $path;
|
||||
|
||||
$records = $gridInstance->export();
|
||||
|
||||
if (count($records) == 0) {
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ class InvoiceController extends Controller
|
|||
$data = request()->all();
|
||||
|
||||
$haveProductToInvoice = false;
|
||||
|
||||
foreach ($data['invoice']['items'] as $itemId => $qty) {
|
||||
if ($qty) {
|
||||
$haveProductToInvoice = true;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ class OrderController extends Controller
|
|||
$this->_config = request('_config');
|
||||
|
||||
$this->orderRepository = $orderRepository;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -148,8 +148,9 @@ class RefundController extends Controller
|
|||
{
|
||||
$data = $this->refundRepository->getOrderItemsRefundSummary(request()->all(), $orderId);
|
||||
|
||||
if (! $data)
|
||||
if (! $data) {
|
||||
return response('');
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,8 +143,9 @@ class ShipmentController extends Controller
|
|||
*/
|
||||
public function isInventoryValidate(&$data)
|
||||
{
|
||||
if (! isset($data['shipment']['items']))
|
||||
if (! isset($data['shipment']['items'])) {
|
||||
return ;
|
||||
}
|
||||
|
||||
$valid = false;
|
||||
|
||||
|
|
@ -154,13 +155,15 @@ class ShipmentController extends Controller
|
|||
if ($qty = $inventorySource[$inventorySourceId]) {
|
||||
$orderItem = $this->orderItemRepository->find($itemId);
|
||||
|
||||
if ($orderItem->qty_to_ship < $qty)
|
||||
if ($orderItem->qty_to_ship < $qty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($orderItem->getTypeInstance()->isComposite()) {
|
||||
foreach ($orderItem->children as $child) {
|
||||
if (! $child->qty_ordered)
|
||||
if (! $child->qty_ordered) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$finalQty = ($child->qty_ordered / $orderItem->qty_ordered) * $qty;
|
||||
|
||||
|
|
@ -168,17 +171,19 @@ class ShipmentController extends Controller
|
|||
->where('inventory_source_id', $inventorySourceId)
|
||||
->sum('qty');
|
||||
|
||||
if ($child->qty_to_ship < $finalQty || $availableQty < $finalQty)
|
||||
if ($child->qty_to_ship < $finalQty || $availableQty < $finalQty) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$availableQty = $orderItem->product->inventories()
|
||||
->where('inventory_source_id', $inventorySourceId)
|
||||
->sum('qty');
|
||||
|
||||
if ($orderItem->qty_to_ship < $qty || $availableQty < $qty)
|
||||
if ($orderItem->qty_to_ship < $qty || $availableQty < $qty) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$valid = true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -26,13 +26,6 @@ class ConfigurationForm extends FormRequest
|
|||
{
|
||||
$this->rules = [];
|
||||
|
||||
// if (request()->has('sales.orderSettings.order_number')) {
|
||||
// $this->rules = [
|
||||
// 'sales.orderSettings.order_number.order_number_prefix' => 'required|regex:/^[a-zA-Z0-9$%^&*@]+$/u',
|
||||
// 'sales.orderSettings.order_number.order_number_suffix' => 'required|regex:/^[a-zA-Z0-9$%^&*@]+$/u',
|
||||
// ];
|
||||
// }
|
||||
|
||||
if (request()->has('general.design.admin_logo.logo_image') && ! request()->input('general.design.admin_logo.logo_image.delete')) {
|
||||
$this->rules = [
|
||||
'general.design.admin_logo.logo_image' => 'required|mimes:jpeg,bmp,png,jpg'
|
||||
|
|
@ -50,8 +43,6 @@ class ConfigurationForm extends FormRequest
|
|||
public function messages()
|
||||
{
|
||||
return [
|
||||
// 'sales.orderSettings.order_number.order_number_prefix.regex' => 'Invalid format. Can not use #.',
|
||||
// 'sales.orderSettings.order_number.order_number_suffix.regex' => 'Invalid format. Can not use #.',
|
||||
'general.design.admin_logo.logo_image.mimes' => 'Invalid file format. Use only jpeg, bmp, png, jpg.'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ class CancelOrderNotification extends Mailable
|
|||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/*
|
||||
/**
|
||||
* @var Order
|
||||
* */
|
||||
*
|
||||
*/
|
||||
public $order;
|
||||
|
||||
public function __construct($order)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ class NewAdminNotification extends Mailable
|
|||
*/
|
||||
public $order;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class NewInventorySourceNotification extends Mailable
|
|||
public function build()
|
||||
{
|
||||
$order = $this->shipment->order;
|
||||
|
||||
$inventory = $this->shipment->inventory_source;
|
||||
|
||||
return $this->to($inventory->contact_email, $inventory->name)
|
||||
|
|
|
|||
|
|
@ -139,8 +139,9 @@ class AdminServiceProvider extends ServiceProvider
|
|||
{
|
||||
static $tree;
|
||||
|
||||
if ($tree)
|
||||
if ($tree) {
|
||||
return $tree;
|
||||
}
|
||||
|
||||
$tree = Tree::create();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue