Search and Bug fixes
This commit is contained in:
parent
2514d748b5
commit
e2c036ced0
|
|
@ -61,7 +61,7 @@
|
|||
<script>
|
||||
function loadTinyMCE() {
|
||||
tinymce.init({
|
||||
selector: 'textarea',
|
||||
selector: 'textarea#tiny',
|
||||
height: 300,
|
||||
width: 535,
|
||||
plugins: 'image imagetools media wordcount save fullscreen',
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<div class="control-group" :class="[errors.has('content') ? 'has-error' : '']">
|
||||
<label for="content">{{ __('admin::app.settings.sliders.content') }}</label>
|
||||
|
||||
<textarea class="control" id="add_content" name="content" rows="5"></textarea>
|
||||
<textarea id="tiny" class="control" id="add_content" name="content" rows="5"></textarea>
|
||||
|
||||
<span class="control-error" v-if="errors.has('content')">@{{ errors.first('content') }}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
<label for="content">{{ __('admin::app.settings.sliders.content') }}</label>
|
||||
|
||||
<div class="panel-body">
|
||||
<textarea class="control" id="add_content" name="content" v-validate="'required'" rows="5">{{ $slider->content ? : old('content') }}</textarea>
|
||||
<textarea id="tiny" class="control" id="add_content" name="content" v-validate="'required'" rows="5">{{ $slider->content ? : old('content') }}</textarea>
|
||||
</div>
|
||||
|
||||
<span class="control-error" v-if="errors.has('content')">@{{ errors.first('content') }}</span>
|
||||
|
|
|
|||
|
|
@ -1149,6 +1149,7 @@ class Cart {
|
|||
* @return mixed
|
||||
*/
|
||||
public function moveConfigurableFromWishlistToCart($configurableproductId, $productId) {
|
||||
// dd('moving configurable');
|
||||
$product = $this->product->find($configurableproductId);
|
||||
|
||||
$canAdd = $this->product->find($productId)->haveSufficientQuantity(1);
|
||||
|
|
@ -1196,7 +1197,7 @@ class Cart {
|
|||
'weight' => $weight = ($product->type == 'configurable' ? $child->weight : $product->weight),
|
||||
'total_weight' => $weight,
|
||||
'base_total_weight' => $weight,
|
||||
'additional' => json_encode($additional)
|
||||
'additional' => $additional
|
||||
];
|
||||
|
||||
return ['parent' => $parentData, 'child' => $childData];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Search extends Model
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Repositories;
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
|
||||
// use Webkul\Product\Contracts\Criteria\searchByAttributeCriteria;
|
||||
|
||||
/**
|
||||
* Search Reposotory
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class SearchRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
|
||||
public function __construct(App $app, Product $product) {
|
||||
parent::__construct($app);
|
||||
|
||||
$this->product = $product;
|
||||
}
|
||||
|
||||
function model()
|
||||
{
|
||||
return 'Webkul\Product\Models\Product';
|
||||
}
|
||||
|
||||
public function searchAttributes(){
|
||||
// $this->pushCriteria(app(searchByAttributeCriteria::class));
|
||||
}
|
||||
|
||||
public function search($data) {
|
||||
$term = $data['term'];
|
||||
|
||||
$products = $this->product->searchProductByAttribute($term);
|
||||
|
||||
dd($products);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Contracts\Criteria;
|
||||
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
use Webkul\Product\Helpers\AbstractProduct;
|
||||
|
||||
/**
|
||||
* Class MyCriteria.
|
||||
*
|
||||
* @package namespace App\Criteria;
|
||||
*/
|
||||
class SearchByAttributeCriteria extends AbstractProduct implements CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attribute
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(AttributeRepository $attribute)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply criteria in query repository
|
||||
*
|
||||
* @param string $model
|
||||
* @param RepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply($model, RepositoryInterface $repository)
|
||||
{
|
||||
return $model = $model->leftJoin('product_attribute_values as pav', 'products.id', '=', 'pav.product_id')->where('attribute_id', '=', 75)->where('products.parent_id', '=', null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Contracts\Criteria;
|
||||
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
use Webkul\Product\Helpers\AbstractProduct;
|
||||
|
||||
/**
|
||||
* Class MyCriteria.
|
||||
*
|
||||
* @package namespace App\Criteria;
|
||||
*/
|
||||
class SearchByCategoryCriteria extends AbstractProduct implements CriteriaInterface
|
||||
{
|
||||
/**
|
||||
* Apply criteria in query repository
|
||||
*
|
||||
* @param string $model
|
||||
* @param RepositoryInterface $repository
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function apply($model, RepositoryInterface $repository)
|
||||
{
|
||||
|
||||
//->leftJoin('category_translations', 'categories.id', '=', 'category_translations.id')->addSelect('category_translations.name')
|
||||
|
||||
$model = $model->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id')->leftJoin('categories', 'product_categories.category_id', '=', 'categories.id')->leftJoin('category_translations', 'categories.id', '=', 'category_translations.id');
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Product\Contracts\Criteria;
|
||||
|
||||
use Prettus\Repository\Contracts\CriteriaInterface;
|
||||
use Prettus\Repository\Contracts\RepositoryInterface;
|
||||
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
|
||||
use Webkul\Product\Helpers\AbstractProduct;
|
||||
|
||||
/**
|
||||
* Class MyCriteria.
|
||||
*
|
||||
* @package namespace App\Criteria;
|
||||
*/
|
||||
class SearchBySuperAttributeCriteria extends AbstractProduct implements CriteriaInterface
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ class ReviewController extends Controller
|
|||
return view($this->_config['view'],compact('review'));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
|
|
@ -92,7 +92,7 @@ class ReviewController extends Controller
|
|||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Delete the review of the current product
|
||||
*
|
||||
* @return response
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ use Webkul\Product\Contracts\Criteria\FilterByAttributesCriteria;
|
|||
use Webkul\Product\Contracts\Criteria\FilterByCategoryCriteria;
|
||||
use Webkul\Product\Contracts\Criteria\NewProductsCriteria;
|
||||
use Webkul\Product\Contracts\Criteria\FeaturedProductsCriteria;
|
||||
use Webkul\Product\Contracts\Criteria\SearchByAttributeCriteria;
|
||||
use Webkul\Product\Contracts\Criteria\SearchByCategoryCriteria;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
|
|
@ -471,4 +473,31 @@ class ProductRepository extends Repository
|
|||
return $query->distinct()->addSelect('products.*')->orderBy('id', 'desc');
|
||||
})->paginate(4, ['products.id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Product by Attribute
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchProductByAttribute($term) {
|
||||
// $findIn = $this->breakTheTerm($term);
|
||||
|
||||
$this->pushCriteria(app(SearchByAttributeCriteria::class));
|
||||
// $this->pushCriteria(app(SearchByCategoryCriteria::class));
|
||||
|
||||
return $this->scopeQuery(function($query) use($term) {
|
||||
return $query->distinct()->addSelect('products.*')->where('pav.text_value', 'like', '%'.$term.'%');
|
||||
// ->where('category_translations.name', 'like', '%'.'clothes'.'%');
|
||||
})->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* break the search term into explode by using space and tell which exploded item is attribute
|
||||
* , category, super attribute or combination of them.
|
||||
*/
|
||||
public function breakTheTerm($term) {
|
||||
$explodedTerm = (explode(" ", $term));
|
||||
|
||||
dd($term);
|
||||
}
|
||||
}
|
||||
|
|
@ -46,8 +46,6 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function __construct(Product $product, ProductReview $productReview)
|
||||
{
|
||||
$this->middleware('admin')->only(['update', 'destroy']);
|
||||
|
||||
$this->middleware('customer')->only(['create', 'store', 'destroy']);
|
||||
|
||||
$this->product = $product;
|
||||
|
|
@ -57,16 +55,6 @@ class ReviewController extends Controller
|
|||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
|
|
@ -122,35 +110,6 @@ class ReviewController extends Controller
|
|||
return view($this->_config['view'],compact('product'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$review = $this->productReview->find($id);
|
||||
|
||||
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)
|
||||
{
|
||||
$this->productReview->update(request()->all(), $id);
|
||||
|
||||
session()->flash('success', 'Review updated successfully.');
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the review of the current product
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ use Webkul\Shop\Http\Controllers\Controller;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
use Webkul\Core\Repositories\SearchRepository as Search;
|
||||
|
||||
/**
|
||||
* Search controller
|
||||
*
|
||||
|
|
@ -16,20 +18,29 @@ use Illuminate\Http\Response;
|
|||
class SearchController extends controller
|
||||
{
|
||||
protected $_config;
|
||||
protected $sliders;
|
||||
protected $current_channel;
|
||||
|
||||
public function __construct(Sliders $s)
|
||||
protected $search;
|
||||
|
||||
public function __construct(Search $search)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->sliders = $s;
|
||||
$this->search = $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index to handle the view loaded with the search results
|
||||
*/
|
||||
public function index($data) {
|
||||
return redirect()->back();
|
||||
public function index() {
|
||||
$results = null;
|
||||
|
||||
$results = $this->search->search(request()->all());
|
||||
|
||||
if($results) {
|
||||
return view($this->_config['view'])->with('results', $results);
|
||||
} else {
|
||||
return view($this->_config['view'])->with('results', null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function
|
|||
'view' => 'shop::products.index'
|
||||
]);
|
||||
|
||||
//Store front search
|
||||
Route::get('/search', 'Webkul\Shop\Http\Controllers\SearchController@index')->defaults('_config', [
|
||||
'view' => 'shop::search.search'
|
||||
])->name('shop.search.index');
|
||||
|
||||
//checkout and cart
|
||||
//Cart Items(listing)
|
||||
Route::get('checkout/cart', 'Webkul\Shop\Http\Controllers\CartController@index')->defaults('_config', [
|
||||
|
|
|
|||
|
|
@ -727,6 +727,11 @@ section.slider-block {
|
|||
height: 24px;
|
||||
width: 24px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
outline: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ return [
|
|||
'locale' => 'Locale',
|
||||
],
|
||||
|
||||
'search' => [
|
||||
'no-results' => 'No Results Found.',
|
||||
'page-title' => 'Bagisto - Search'
|
||||
],
|
||||
|
||||
'reviews' => [
|
||||
'title' => 'Title',
|
||||
'add-review-page-title' => 'Add Review',
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
</div>
|
||||
|
||||
<input class="btn btn-primary btn-lg" type="submit" value="{{ __('shop::app.customer.login-form.button_title') }}">
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,11 +15,13 @@
|
|||
|
||||
<ul class="search-container">
|
||||
<li class="search-group">
|
||||
<input type="search" class="search-field" placeholder="Search for products">
|
||||
<form role="search" action="{{ route('shop.search.index') }}" method="GET" @submit.prevent="onSubmit" style="display: inherit;">
|
||||
<input type="search" name="term" class="search-field" placeholder="products, categories" v-validate="'required'">
|
||||
|
||||
<div class="search-icon-wrapper">
|
||||
<span class="icon icon-search"></span>
|
||||
</div>
|
||||
<div class="search-icon-wrapper">
|
||||
<button class="icon icon-search" class="background: none;"></button>
|
||||
</div>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('shop::app.search.page-title') }}
|
||||
@endsection
|
||||
|
||||
@section('content-wrapper')
|
||||
@if(!$results)
|
||||
{{ __('shop::app.search.no-results') }}
|
||||
@endif
|
||||
@endsection
|
||||
Loading…
Reference in New Issue