Skip to content

Commit

Permalink
fixes on brand search
Browse files Browse the repository at this point in the history
  • Loading branch information
Filippo Matteo Riggio committed Jul 8, 2020
1 parent 529079a commit f96db60
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 128 deletions.
4 changes: 2 additions & 2 deletions src/app/Http/Controllers/Api/Cart/ReadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Kaleidoscope\Factotum\Cart;
use Kaleidoscope\Factotum\CartProduct;
use Kaleidoscope\Factotum\Library\Utility;
use Kaleidoscope\Factotum\Order;
use Kaleidoscope\Factotum\Traits\CartUtils;

Expand All @@ -31,7 +32,7 @@ public function getListPaginated( Request $request )
$direction = 'DESC';
}

$query = Cart::query();
$query = Cart::withTrashed();
$query->selectRaw('carts.*, first_name, last_name, company_name');
$query->join('users', 'users.id', '=', 'carts.customer_id');
$query->join('profiles', 'profiles.user_id', '=', 'users.id');
Expand Down Expand Up @@ -70,7 +71,6 @@ public function getListPaginated( Request $request )
$cart->totals = $this->_getCartTotals( $cart );
}
}

return response()->json( [ 'result' => 'ok', 'carts' => $carts, 'total' => Cart::count() ]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@

class ReadController extends Controller
{
protected $_productsPerPage = 48;

public function getProductsByBrand(Request $request, $brandCode)
{
$itemsPerPage = $request->input('items_per_page', 12);
$itemsPerPage = $request->input('items_per_page', $this->_productsPerPage );
$brandFilter = $request->input('brand_filter');
$brandsFilter = $request->input('brands');
$brand = Brand::where( 'code', $brandCode )->first();
$brandsFiltered = null;

if ( $brandsFilter ) {
$brandsFilter = explode(',', $brandsFilter);

$brandsFiltered = Brand::whereIn('id', $brandsFilter)->get();
}

if ( $brand ) {
Expand Down Expand Up @@ -49,6 +53,7 @@ public function getProductsByBrand(Request $request, $brandCode)
->with([
'itemsPerPage' => $products->perPage(),
'brandFilter' => $brandFilter,
'brandsFiltered' => $brandsFiltered,
'brand' => $brand,
'brandsFilter' => $brandsFilter,
'products' => $products,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function setOrderTransaction( SetOrderTransaction $request )

if ( $order ) {
$order->setTransactionId( $transactionId );
$cart = $this->_getCart();

$result = [
'result' => 'ok',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

class ReadController extends Controller
{
protected $_productsPerPage = 48;

public function getProductsByCategory(Request $request, $productCategorySlug)
{
$itemsPerPage = $request->input('items_per_page', 12);
$itemsPerPage = $request->input('items_per_page', $this->_productsPerPage );
$brandFilter = $request->input('brand_filter');
$brandsFilter = $request->input('brands');
$productCategory = ProductCategory::where('name', $productCategorySlug)->first();
Expand Down
1 change: 1 addition & 0 deletions src/app/Http/Requests/SearchProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function rules()

if ( isset($data['product_category_id']) && $data['product_category_id'] != '' ) {
$rules['product_category_id'] = 'required|exists:product_categories,id';
unset($rules['term']);
}

return $rules;
Expand Down
2 changes: 2 additions & 0 deletions src/app/Traits/CartUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ protected function _createOrderFromCart( Cart $cart )
request()->session()->remove('delivery_address');
request()->session()->remove('invoice_address');
request()->session()->remove('shipping');

$cart->delete();
}

return $order;
Expand Down
93 changes: 0 additions & 93 deletions src/gulpfile.js

This file was deleted.

21 changes: 0 additions & 21 deletions src/package.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<select name="brand_filter" id="brand_filter">
<option value="">Brand</option>
@foreach( $brands as $br )
<option value="{{ $br->id }}" @if( $brandFilter == $br->id ) selected @endif>{{ $br->name }}</option>
<option value="{{ $br->id }}" @if( !isset($brandsFiltered) && $brandFilter == $br->id ) selected @endif>{{ $br->name }}</option>
@endforeach
</select>
</div>
Expand Down
31 changes: 22 additions & 9 deletions src/resources/views/ecommerce/product/products_by_brand.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,33 @@
</div>
<div class="col col-xs-12 col-md-9">

<div class="product-category-cover">
@if ( !$brandsFiltered )
<div class="product-category-cover">

<div class="row clearfix">
<div class="col col-xs-12">
@if( isset($brand->logo) )
<img src="{{ $brand->logo }}" alt="{{ $brand->name }}" width="200" />
@endif
<div class="row clearfix">
<div class="col col-xs-12">
@if( isset($brand->logo) )
<img src="{{ $brand->logo }}" alt="{{ $brand->name }}" width="200" />
@endif
</div>
</div>
</div>

</div>
</div>
@endif


@include('factotum::ecommerce.product.partials.product-category-filters', [ 'title' => $brand->name ])
@if ( !$brandsFiltered )
@include('factotum::ecommerce.product.partials.product-category-filters', [ 'title' => $brand->name ])
@else
@php
$title = [];
foreach ( $brandsFiltered as $b ) {
$title[] = $b->name;
}
$title = 'Ricerca per : ' . join(', ', $title);
@endphp
@include('factotum::ecommerce.product.partials.product-category-filters', [ 'title' => $title ])
@endif


@if ( $products->count() > 0 )
Expand Down

0 comments on commit f96db60

Please sign in to comment.