Repository pattern changes

This commit is contained in:
jitendra 2018-08-22 15:14:35 +05:30
parent 86b7971b61
commit bc087010ee
30 changed files with 221 additions and 262 deletions

View File

@ -16,6 +16,7 @@
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"nwidart/laravel-modules": "^3.2",
"prettus/l5-repository": "^2.6",
"propaganistas/laravel-intl": "^2.0"
},
"require-dev": {

105
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "8acd4eec85be1351459a67cfd14d039b",
"content-hash": "ee788a0a8a86526cd58b0b4853a45c06",
"packages": [
{
"name": "commerceguys/intl",
@ -1394,6 +1394,109 @@
],
"time": "2018-07-02T15:55:56+00:00"
},
{
"name": "prettus/l5-repository",
"version": "2.6.32",
"source": {
"type": "git",
"url": "https://github.com/andersao/l5-repository.git",
"reference": "f6ebfffee80a38e1d2dcf479e70b1a9ead397c24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/andersao/l5-repository/zipball/f6ebfffee80a38e1d2dcf479e70b1a9ead397c24",
"reference": "f6ebfffee80a38e1d2dcf479e70b1a9ead397c24",
"shasum": ""
},
"require": {
"illuminate/config": "~5.0",
"illuminate/console": "~5.0",
"illuminate/database": "~5.0",
"illuminate/filesystem": "~5.0",
"illuminate/http": "~5.0",
"illuminate/pagination": "~5.0",
"illuminate/support": "~5.0",
"prettus/laravel-validation": "1.1.*"
},
"suggest": {
"league/fractal": "Required to use the Fractal Presenter (0.12.*).",
"prettus/laravel-validation": "Required to provide easy validation with the repository (1.1.*)",
"robclancy/presenter": "Required to use the Presenter Model (1.3.*)"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Prettus\\Repository\\Providers\\RepositoryServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Prettus\\Repository\\": "src/Prettus/Repository/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anderson Andrade",
"email": "contato@andersonandra.de",
"role": "Developer"
}
],
"description": "Laravel 5 - Repositories to the database layer",
"keywords": [
"cache",
"eloquent",
"laravel",
"model",
"repository"
],
"time": "2018-01-27T15:53:20+00:00"
},
{
"name": "prettus/laravel-validation",
"version": "1.1.5",
"source": {
"type": "git",
"url": "https://github.com/andersao/laravel-validator.git",
"reference": "d9eb401fb3518a890b117e83bd25a4109fcdb704"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/andersao/laravel-validator/zipball/d9eb401fb3518a890b117e83bd25a4109fcdb704",
"reference": "d9eb401fb3518a890b117e83bd25a4109fcdb704",
"shasum": ""
},
"require": {
"illuminate/support": "~5.4",
"illuminate/validation": "~5.4",
"php": ">=5.4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Prettus\\Validator\\": "src/Prettus/Validator/"
}
},
"notification-url": "https://packagist.org/downloads/",
"authors": [
{
"name": "Anderson Andrade",
"email": "contato@andersonandra.de"
}
],
"description": "Laravel Validation Service",
"keywords": [
"laravel",
"service",
"validation"
],
"time": "2017-08-28T23:28:32+00:00"
},
{
"name": "propaganistas/laravel-intl",
"version": "2.0.3",

View File

@ -172,6 +172,7 @@ return [
//Laravel Intervention
Intervention\Image\ImageServiceProvider::class,
Prettus\Repository\Providers\RepositoryServiceProvider::class,
//Webkul packages
Webkul\User\Providers\UserServiceProvider::class,

View File

@ -67,7 +67,7 @@
<div class="control-group" :class="[errors.has('default_locale') ? 'has-error' : '']">
<label for="default_locale" class="required">{{ __('admin::app.settings.channels.default-locale') }}</label>
<?php $selectedOption = old('default_locale') ?: $channel->default_locale ?>
<?php $selectedOption = old('default_locale') ?: $channel->default_locale_id ?>
<select v-validate="'required'" class="control" id="default_locale" name="default_locale">
@foreach(core()->getAllLocales() as $locale)
<option value="{{ $locale->id }}" {{ $selectedOption == $locale->id ? 'selected' : '' }}>
@ -82,7 +82,7 @@
<label for="currencies" class="required">{{ __('admin::app.settings.channels.currencies') }}</label>
<?php $selectedOptionIds = old('currencies') ?: $channel->currencies->pluck('id')->toArray() ?>
<select v-validate="'required'" class="control" id="currencies" name="currencies[]" multiple>
@foreach(core()->geAllCurrencies() as $currency)
@foreach(core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ in_array($currency->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $currency->name }}
</option>
@ -93,9 +93,9 @@
<div class="control-group" :class="[errors.has('base_currency') ? 'has-error' : '']">
<label for="base_currency" class="required">{{ __('admin::app.settings.channels.base-currency') }}</label>
<?php $selectedOption = old('base_currency') ?: $channel->base_currency ?>
<?php $selectedOption = old('base_currency') ?: $channel->base_currency_id ?>
<select v-validate="'required'" class="control" id="base_currency" name="base_currency">
@foreach(core()->geAllCurrencies() as $currency)
@foreach(core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ $selectedOption == $currency->id ? 'selected' : '' }}>
{{ $currency->name }}
</option>

View File

@ -90,7 +90,7 @@ class AttributeController extends Controller
*/
public function edit($id)
{
$attribute = $this->attribute->findOrFail($id);
$attribute = $this->attribute->find($id);
return view($this->_config['view'], compact('attribute'));
}

View File

@ -61,7 +61,7 @@ class AttributeFamilyController extends Controller
*/
public function create(Attribute $attribute)
{
$attributeFamily = $this->attributeFamily->findBy('code', 'default', ['*'], ['attribute_groups.custom_attributes']);
$attributeFamily = $this->attributeFamily->with(['attribute_groups.custom_attributes'])->findOneByField('code', 'default');
$custom_attributes = $attribute->all(['id', 'code', 'admin_name', 'type']);
@ -96,7 +96,7 @@ class AttributeFamilyController extends Controller
*/
public function edit(Attribute $attribute, $id)
{
$attributeFamily = $this->attributeFamily->findOrFail($id, ['*'], ['attribute_groups.custom_attributes']);
$attributeFamily = $this->attributeFamily->find($id, ['*'], ['attribute_groups.custom_attributes']);
$custom_attributes = $attribute->all(['id', 'code', 'admin_name', 'type']);

View File

@ -74,7 +74,7 @@ class AttributeFamilyRepository extends Repository
if(isset($attribute['id'])) {
$attributeModel = $this->attribute->find($attribute['id']);
} else {
$attributeModel = $this->attribute->findBy('code', $attribute['code']);
$attributeModel = $this->attribute->findOneByField('code', $attribute['code']);
}
$attributeGroup->custom_attributes()->save($attributeModel, ['position' => $key + 1]);
@ -92,7 +92,7 @@ class AttributeFamilyRepository extends Repository
*/
public function update(array $data, $id, $attribute = "id")
{
$family = $this->findOrFail($id);
$family = $this->find($id);
$family->update($data);
@ -114,7 +114,7 @@ class AttributeFamilyRepository extends Repository
$previousAttributeGroupIds->forget($index);
}
$attributeGroup = $this->attributeGroup->findOrFail($attributeGroupId);
$attributeGroup = $this->attributeGroup->find($attributeGroupId);
$attributeGroup->update($attributeGroupInputs);
$attributeIds = $attributeGroup->custom_attributes()->get()->pluck('id');

View File

@ -75,7 +75,7 @@ class AttributeRepository extends Repository
{
$data = $this->validateUserInput($data);
$attribute = $this->findOrFail($id);
$attribute = $this->find($id);
$attribute->update($data);

View File

@ -92,7 +92,7 @@ class CategoryController extends Controller
{
$categories = $this->category->getCategoryTree($id);
$category = $this->category->findOrFail($id);
$category = $this->category->find($id);
return view($this->_config['view'], compact('category', 'categories'));
}

View File

@ -1,29 +0,0 @@
<?php
namespace Webkul\Core\Contracts;
/**
* Reposotory Interface
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
interface RepositoryInterface {
public function all($columns = ['*']);
public function paginate($perPage = 15, $columns = ['*']);
public function create(array $data);
public function update(array $data, $id);
public function delete($id);
public function find($id, $columns = ['*']);
public function findOrFail($id, $columns = ['*']);
public function findBy($field, $value, $columns = ['*']);
}

View File

@ -2,9 +2,7 @@
namespace Webkul\Core\Eloquent;
use Webkul\Core\Contracts\RepositoryInterface;
use Webkul\Core\Exceptions\RepositoryException;
use Prettus\Repository\Eloquent\BaseRepository;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Container\Container as App;
@ -14,158 +12,38 @@ use Illuminate\Container\Container as App;
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
abstract class Repository implements RepositoryInterface {
abstract class Repository extends BaseRepository {
/**
* @var App
*/
private $app;
/**
* @var \Illuminate\Database\Eloquent\Model
*/
protected $model;
/**
* @param App $app
* @throws \Webkul\Core\Exceptions\RepositoryException
*/
public function __construct(App $app)
{
$this->app = $app;
$this->makeModel();
}
/**
* Specify Model class name
* Find data by field and value
*
* @param $field
* @param $value
* @param array $columns
*
* @return mixed
*/
public abstract function model();
public function findOneByField($field, $value = null, $columns = ['*'])
{
$model = parent::findByField($field, $value, $columns = ['*']);
return $model->first();
}
/**
* Find data by field and value
*
* @param $field
* @param $value
* @param array $columns
*
* @return mixed
*/
public function all($columns = ['*'], $with = [])
public function findOneWhere(array $where, $columns = ['*'])
{
return $this->resetScope()->model->with($with)->get($columns);
}
/**
* @param int $perPage
* @param array $columns
* @return mixed
*/
public function paginate($perPage = 1, $columns = ['*'])
{
return $this->resetScope()->model->paginate($perPage, $columns);
}
/**
* @param array $data
* @return mixed
*/
public function create(array $data)
{
return $this->resetScope()->model->create($data);
}
/**
* @param array $data
* @param $id
* @param string $attribute
* @return mixed
*/
public function update(array $data, $id, $attribute = "id")
{
return $this->resetScope()->model->where($attribute, '=', $id)->first()->update($data);
}
/**
* @param $id
* @return mixed
*/
public function delete($id)
{
return $this->resetScope()->find($id)->delete();
}
/**
* @param $id
* @param array $columns->with($with)
* @return mixed
*/
public function find($id, $columns = ['*'], $with = [])
{
return $this->resetScope()->model->with($with)->find($id, $columns);
}
/**
* @param $id
* @param array $columns
* @return mixed
*/
public function findOrFail($id, $columns = ['*'], $with = [])
{
return $this->resetScope()->model->with($with)->findOrFail($id, $columns);
}
/**
* @param $attribute
* @param $value
* @param array $columns
* @return mixed
*/
public function findBy($attribute, $value, $columns = ['*'], $with = [])
{
return $this->resetScope()->model->with($with)->where($attribute, '=', $value)->first($columns);
}
/**
* @param $conditions
* @param array $columns
* @return mixed
*/
public function findWhere($conditions, $columns = ['*'], $with = [])
{
$model = $this->resetScope()->model;
foreach ($conditions as $column => $value) {
if(is_array($value)) {
list($column, $condition, $val) = $value;
$this->model = $this->model->where($column, $condition, $val);
} else {
$model->where($column, $value);
}
}
return $model->with($with)->get($columns);
}
/**
* @return \Illuminate\Database\Eloquent\Builder
* @throws RepositoryException
*/
public function makeModel()
{
$model = $this->app->make($this->model());
if (!$model instanceof Model)
throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model");
return $this->model = $model->newQuery();
}
/**
* @return $this
*/
public function resetScope() {
$this->makeModel();
return $this;
$model = parent::findWhere($where, $columns);
return $model->first();
}
/**

View File

@ -1,14 +0,0 @@
<?php
namespace Webkul\Core\Exceptions;
/**
* Reposotory Exception
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class RepositoryException extends \Exception
{
}

View File

@ -94,7 +94,7 @@ class ChannelController extends Controller
*/
public function edit($id)
{
$channel = $this->channel->findOrFail($id, ['*'], ['locales', 'currencies']);
$channel = $this->channel->with(['locales', 'currencies'])->find($id);
return view($this->_config['view'], compact('channel'));
}

View File

@ -110,7 +110,7 @@ class ExchangeRateController extends Controller
{
$currencies = $this->currency->all();
$exchangeRate = $this->exchangeRate->findOrFail($id);
$exchangeRate = $this->exchangeRate->find($id);
return view($this->_config['view'], compact('currencies', 'exchangeRate'));
}

View File

@ -31,7 +31,7 @@ class Locale
public function handle($request, Closure $next)
{
if($locale = $request->get('locale')) {
if($this->locale->findBy('code', $locale)) {
if($this->locale->findOneByField('code', $locale)) {
// app()->setLocale($locale);
}
}

View File

@ -45,7 +45,7 @@ class ChannelRepository extends Repository
*/
public function update(array $data, $id, $attribute = "id")
{
$channel = $this->findOrFail($id);
$channel = $this->find($id);
$channel->update($data);

View File

@ -87,7 +87,7 @@ class InventorySourceController extends Controller
*/
public function edit($id)
{
$inventorySource = $this->inventorySource->findOrFail($id);
$inventorySource = $this->inventorySource->find($id);
return view($this->_config['view'], compact('inventorySource'));
}

View File

@ -99,7 +99,7 @@ class ProductController extends Controller
$families = $this->attributeFamily->all();
if($familyId = request()->get('family')) {
$configurableFamily = $this->attributeFamily->findOrFail($familyId);
$configurableFamily = $this->attributeFamily->find($familyId);
}
return view($this->_config['view'], compact('families', 'configurableFamily'));
@ -143,7 +143,7 @@ class ProductController extends Controller
*/
public function edit($id)
{
$product = $this->product->findOrFail($id, ['*'], ['variants']);
$product = $this->product->with(['variants'])->find($id);
$categories = $this->category->getCategoryTree();

View File

@ -2,6 +2,8 @@
namespace Webkul\Product\Product;
use Webkul\Product\Models\ProductAttributeValue;
abstract class AbstractProduct
{
/**
@ -33,4 +35,30 @@ abstract class AbstractProduct
return $qb;
}
/**
* Adds attributes to select
*
* @param QB $qb
* @return QB
*/
public function addSelectAttributes($qb)
{
foreach ($this->attributeToSelect as $code) {
$attribute = $this->attribute->findOneByField('code', $code);
$productValueAlias = 'pav_' . $attribute->code;
$qb->leftJoin('product_attribute_values as ' . $productValueAlias, function($leftJoin) use($attribute, $productValueAlias) {
$leftJoin->on('products.id', $productValueAlias . '.product_id');
$leftJoin = $this->applyChannelLocaleFilter($attribute, $leftJoin, $productValueAlias)->where($productValueAlias . '.attribute_id', $attribute->id);
});
$qb->addSelect($productValueAlias . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type] . ' as ' . $code);
}
return $qb;
}
}

View File

@ -5,7 +5,6 @@ namespace Webkul\Product\Product;
use Illuminate\Support\Facades\DB;
use Webkul\Product\Repositories\ProductRepository as Product;
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
use Webkul\Product\Models\ProductAttributeValue;
class Collection extends AbstractProduct
{
@ -28,7 +27,7 @@ class Collection extends AbstractProduct
*
* @var array
*/
protected $attributesToSelect = [
protected $attributeToSelect = [
'name',
'description',
'short_description',
@ -58,42 +57,33 @@ class Collection extends AbstractProduct
*/
public function addAttributesToSelect($attributes)
{
$this->attributesToSelect = $attributes;
$this->attributeToSelect = array_unique(
array_merge($this->attributeToSelect, $attributes)
);
return $this;
}
/**
* @param integer $categoryId
* @return Collection
*/
public function getProductCollection($categoryId = null, $attributeToSelect = '*')
public function getCollection($categoryId = null)
{
$qb = $this->product->getModel()
->select('products.*')
->join('product_categories', 'products.id', '=', 'product_categories.product_id')
->where('product_categories.category_id', $categoryId);
foreach ($this->attributesToSelect as $code) {
$attribute = $this->attribute->findBy('code', $code);
$productValueAlias = 'pav_' . $attribute->code;
$qb->leftJoin('product_attribute_values as ' . $productValueAlias, function($leftJoin) use($attribute, $productValueAlias) {
$leftJoin->on('products.id', $productValueAlias . '.product_id');
$leftJoin = $this->applyChannelLocaleFilter($attribute, $leftJoin, $productValueAlias)->where($productValueAlias . '.attribute_id', $attribute->id);
});
$qb->addSelect($productValueAlias . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type] . ' as ' . $code);
}
$this->addSelectAttributes($qb);
foreach (request()->input() as $code => $value) {
$filterAlias = 'filter_' . $code;
// foreach (request()->input() as $code => $value) {
// $filterAlias = 'filter_' . $code;
$qb->leftJoin('product_attribute_values as ' . $filterAlias, 'products.id', '=', $filterAlias . '.product_id');
// $qb->leftJoin('product_attribute_values as ' . $filterAlias, 'products.id', '=', $filterAlias . '.product_id');
$qb->where($filterAlias . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type], $value);
}
// $qb->where($filterAlias . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type], $value);
// }
// if(0) {
// $qb->orderBy('id', 'desc');

View File

@ -56,7 +56,7 @@ class Price extends AbstractProduct
static $attribute;
if(!$attribute)
$attribute = $this->attribute->findBy('code', 'price');
$attribute = $this->attribute->findOneByField('code', 'price');
$qb = ProductAttributeValue::join('products', 'product_attribute_values.product_id', '=', 'products.id')
->join('attributes', 'product_attribute_values.attribute_id', '=', 'attributes.id')
@ -64,7 +64,7 @@ class Price extends AbstractProduct
->where('attributes.code', 'price')
->addSelect('product_attribute_values.*');
$qb = $this->applyChannelLocaleFilter($attribute, $qb);
$this->applyChannelLocaleFilter($attribute, $qb);
return $qb->min('product_attribute_values.' . ProductAttributeValue::$attributeTypeFields['price']);
}

View File

@ -54,7 +54,7 @@ class ProductAttributeValueRepository extends Repository
if(isset($data['attribute_id'])) {
$attribute = $this->attribute->find($data['attribute_id']);
} else {
$attribute = $this->attribute->findBy('code', $data['attribute_code']);
$attribute = $this->attribute->findOneByField('code', $data['attribute_code']);
}
if(!$attribute)

View File

@ -37,10 +37,10 @@ class ProductInventoryRepository extends Repository
if(is_null($qty))
continue;
$productInventory = $this->findWhere([
$productInventory = $this->findOneWhere([
'product_id' => $product->id,
'inventory_source_id' => $inventorySourceId,
])->first();
]);
if($productInventory) {
if(is_numeric($index = $inventorySourceIds->search($inventorySourceId))) {

View File

@ -103,7 +103,7 @@ class ProductRepository extends Repository
{
$product = $this->model->create($data);
$nameAttribute = $this->attribute->findBy('code', 'status');
$nameAttribute = $this->attribute->findOneByField('code', 'status');
$this->attributeValue->create([
'product_id' => $product->id,
'attribute_id' => $nameAttribute->id,
@ -115,7 +115,7 @@ class ProductRepository extends Repository
$super_attributes = [];
foreach ($data['super_attributes'] as $attributeCode => $attributeOptions) {
$attribute = $this->attribute->findBy('code', $attributeCode);
$attribute = $this->attribute->findOneByField('code', $attributeCode);
$super_attributes[$attribute->id] = $attributeOptions;
@ -138,7 +138,7 @@ class ProductRepository extends Repository
*/
public function update(array $data, $id, $attribute = "id")
{
$product = $this->findOrFail($id);
$product = $this->find($id);
if($product->parent_id && $this->checkVariantOptionAvailabiliy($data, $product)) {
$data['parent_id'] = NULL;
@ -155,12 +155,12 @@ class ProductRepository extends Repository
if(!isset($data[$attribute->code]) || !$data[$attribute->code])
continue;
$attributeValue = $this->attributeValue->findWhere([
$attributeValue = $this->attributeValue->findOneWhere([
'product_id' => $product->id,
'attribute_id' => $attribute->id,
'channel' => $attribute->value_per_channel ? $data['channel'] : null,
'locale' => $attribute->value_per_locale ? $data['locale'] : null
])->first();
]);
if(!$attributeValue) {
$this->attributeValue->create([
@ -228,7 +228,7 @@ class ProductRepository extends Repository
]);
foreach (['sku', 'name', 'price', 'weight', 'status'] as $attributeCode) {
$attribute = $this->attribute->findBy('code', $attributeCode);
$attribute = $this->attribute->findOneByField('code', $attributeCode);
if($attribute->value_per_channel) {
if($attribute->value_per_locale) {
@ -293,19 +293,19 @@ class ProductRepository extends Repository
*/
public function updateVariant(array $data, $id)
{
$variant = $this->findOrFail($id);
$variant = $this->find($id);
$variant->update(['sku' => $data['sku']]);
foreach (['sku', 'name', 'price', 'weight', 'status'] as $attributeCode) {
$attribute = $this->attribute->findBy('code', $attributeCode);
$attribute = $this->attribute->findOneByField('code', $attributeCode);
$attributeValue = $this->attributeValue->findWhere([
$attributeValue = $this->attributeValue->findOneWhere([
'product_id' => $id,
'attribute_id' => $attribute->id,
'channel' => $attribute->value_per_channel ? $data['channel'] : null,
'locale' => $attribute->value_per_locale ? $data['locale'] : null
])->first();
]);
if(!$attributeValue) {
$this->attributeValue->create([

View File

@ -31,7 +31,7 @@ use Webkul\Channel\Channel as Channel;
$current_channel = core()->getCurrentChannel();
$all_sliders = $this->sliders->findWhere(['channel_id'=>$current_channel['id']]);
$all_sliders = $this->sliders->findOneWhere(['channel_id'=>$current_channel['id']]);
return view($this->_config['view'])->with('data',$all_sliders);
}

View File

@ -41,18 +41,19 @@
<script type="text/javascript">
window.flashMessages = [];
@if($success = session('success'))
window.flashMessages = [{'type': 'alert-success', 'message': "{{ $success }}" }];
@elseif($warning = session('warning'))
window.flashMessages = [{'type': 'alert-warning', 'message': "{{ $warning }}" }];
@elseif($error = session('error'))
window.flashMessages = [{'type': 'alert-error', 'message': "{{ $error }}" }];
@endif
@if($success = session('success'))
window.flashMessages = [{'type': 'alert-success', 'message': "{{ $success }}" }];
@elseif($warning = session('warning'))
window.flashMessages = [{'type': 'alert-warning', 'message': "{{ $warning }}" }];
@elseif($error = session('error'))
window.flashMessages = [{'type': 'alert-error', 'message': "{{ $error }}" }];
@endif
window.serverErrors = [];
@if (count($errors))
window.serverErrors = @json($errors->getMessages());
@endif
window.serverErrors = [];
@if (count($errors))
window.serverErrors = @json($errors->getMessages());
@endif
</script>
<script type="text/javascript" src="{{ bagisto_asset('js/shop.js') }}"></script>

View File

@ -10,7 +10,7 @@
@inject ('productHelper', 'Webkul\Product\Product\Collection')
<?php $products = $productHelper->getProductCollection($category->id); ?>
<?php $products = $productHelper->getCollection($category->id); ?>
@foreach ($products as $product)

View File

@ -573,7 +573,7 @@ class ProductGrid
$locale = app()->getLocale();
foreach (['name', 'description', 'short_description', 'price'] as $code) {
$attribute = $this->attributes->findBy('code', $code);
$attribute = $this->attributes->findOneByField('code', $code);
$productValueAlias = 'pav_' . $attribute->code;
@ -628,7 +628,7 @@ class ProductGrid
$locale = $this->locale;
foreach ($this->attributeColumns as $code) {
$attribute = $this->attributes->findBy('code', $code);
$attribute = $this->attributes->findOneByField('code', $code);
$productValueAlias = 'pav_' . $attribute->code;

View File

@ -89,7 +89,7 @@ class RoleController extends Controller
*/
public function edit($id)
{
$role = $this->role->findOrFail($id);
$role = $this->role->find($id);
return view($this->_config['view'], compact('role'));
}

View File

@ -100,7 +100,7 @@ class UserController extends Controller
*/
public function edit($id)
{
$user = $this->admin->findOrFail($id);
$user = $this->admin->find($id);
$roles = $this->role->all();