commit
503f0e0a5a
|
|
@ -7,7 +7,7 @@
|
|||
@section('content')
|
||||
<div class="content">
|
||||
<?php $locale = request()->get('locale') ?: app()->getLocale(); ?>
|
||||
<?php $channel = request()->get('channel') ?: core()->getCurrentChannelCode(); ?>
|
||||
<?php $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); ?>
|
||||
|
||||
<form method="POST" action="" @submit.prevent="onSubmit" enctype="multipart/form-data">
|
||||
|
||||
|
|
|
|||
|
|
@ -237,10 +237,10 @@ class Cart {
|
|||
{
|
||||
$cart = null;
|
||||
|
||||
if(session()->has('cart')) {
|
||||
$cart = $this->cart->find(session()->get('cart')->id);
|
||||
} else if(auth()->guard('customer')->check()) {
|
||||
if(auth()->guard('customer')->check()) {
|
||||
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
|
||||
} elseif(session()->has('cart')) {
|
||||
$cart = $this->cart->find(session()->get('cart')->id);
|
||||
}
|
||||
|
||||
return $cart && $cart->is_active ? $cart : null;
|
||||
|
|
@ -460,9 +460,7 @@ class Cart {
|
|||
*/
|
||||
public function removeItem($itemId)
|
||||
{
|
||||
if(session()->has('cart')) {
|
||||
$cart = $this->getCart();
|
||||
|
||||
if($cart = $this->getCart()) {
|
||||
$items = $cart->items;
|
||||
|
||||
foreach($items as $item) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class CreateCartItemsTable extends Migration
|
|||
$table->json('additional')->nullable();
|
||||
|
||||
$table->integer('product_id')->unsigned();
|
||||
$table->foreign('product_id')->references('id')->on('products');
|
||||
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
|
||||
$table->integer('cart_id')->unsigned();
|
||||
$table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade');
|
||||
$table->integer('tax_category_id')->unsigned()->nullable();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class CreateCartAddress extends Migration
|
|||
$table->integer('cart_id')->nullable()->unsigned();
|
||||
$table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade');
|
||||
$table->integer('customer_id')->nullable()->unsigned();
|
||||
$table->foreign('customer_id')->references('id')->on('customers');
|
||||
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class CreateCartPayment extends Migration
|
|||
$table->string('method');
|
||||
$table->string('method_title')->nullable();
|
||||
$table->integer('cart_id')->nullable()->unsigned();
|
||||
$table->foreign('cart_id')->references('id')->on('cart');
|
||||
$table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class CreateCartShippingRatesTable extends Migration
|
|||
$table->double('price')->default(0)->nullable();
|
||||
$table->double('base_price')->default(0)->nullable();
|
||||
$table->integer('cart_address_id')->nullable()->unsigned();
|
||||
$table->foreign('cart_address_id')->references('id')->on('cart_address');
|
||||
$table->foreign('cart_address_id')->references('id')->on('cart_address')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,34 @@ class Core
|
|||
return ($channel = $this->getCurrentChannel()) ? $channelCode = $channel->code : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns default channel models
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDefaultChannel() {
|
||||
static $channel;
|
||||
|
||||
if($channel)
|
||||
return $channel;
|
||||
|
||||
return $channel = ChannelModel::first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns default channel code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultChannelCode() {
|
||||
static $channelCode;
|
||||
|
||||
if($channelCode)
|
||||
return $channelCode;
|
||||
|
||||
return ($channel = $this->getDefaultChannel()) ? $channelCode = $channel->code : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all locales
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,14 +24,6 @@ class TaxCategoryController extends Controller
|
|||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* Contains the current
|
||||
* channel.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currentChannelId;
|
||||
|
||||
/**
|
||||
* Tax Rule Repository object
|
||||
*
|
||||
|
|
@ -49,8 +41,6 @@ class TaxCategoryController extends Controller
|
|||
{
|
||||
$this->middleware('admin');
|
||||
|
||||
$this->currentChannelId = core()->getCurrentChannel()->id;
|
||||
|
||||
$this->taxRule = $taxRule;
|
||||
|
||||
$this->taxRate = $taxRate;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ class WishlistController extends Controller
|
|||
* Displays the listing resources if the customer having items in wishlist.
|
||||
*/
|
||||
public function index() {
|
||||
$wishlists = $this->wishlist->findWhere(['channel_id' => core()->getCurrentChannel()->id,'customer_id' => auth()->guard('customer')->user()->id]);
|
||||
$wishlists = $this->wishlist->findWhere([
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'customer_id' => auth()->guard('customer')->user()->id]
|
||||
);
|
||||
|
||||
$wishlistItems = array();
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ class Product extends Model
|
|||
$attributeModel = $this->attribute_family->custom_attributes()->where('attributes.code', $key)->first();
|
||||
|
||||
if($attributeModel) {
|
||||
$channel = request()->get('channel') ?: core()->getCurrentChannelCode();
|
||||
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
|
||||
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ class Product extends Model
|
|||
$hiddenAttributes = $this->getHidden();
|
||||
|
||||
if(isset($this->id)) {
|
||||
$channel = request()->get('channel') ?: core()->getCurrentChannelCode();
|
||||
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
|
||||
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,21 +37,10 @@ class Review extends AbstractProduct
|
|||
return $product->reviews()->where('status', 'approved')->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formated created at date
|
||||
*
|
||||
* @param ProductReview $review
|
||||
* @return integer
|
||||
*/
|
||||
public function formatDate($reviewCreatedAt)
|
||||
{
|
||||
return core()->formatDate($reviewCreatedAt, 'd, M Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total rating of the product
|
||||
*
|
||||
* @param Product $product
|
||||
* @param Product $product
|
||||
* @return integer
|
||||
*/
|
||||
public function getTotalRating($product)
|
||||
|
|
|
|||
|
|
@ -423,4 +423,28 @@ class ProductRepository extends Repository
|
|||
get_class($this->model), $slug
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return newly added product
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getNewProducts()
|
||||
{
|
||||
$this->pushCriteria(app(AttributeToSelectCriteria::class)->addAttribueToSelect([
|
||||
'name',
|
||||
'description',
|
||||
'short_description',
|
||||
'price',
|
||||
'special_price',
|
||||
'special_price_from',
|
||||
'special_price_to'
|
||||
]));
|
||||
|
||||
$params = request()->input();
|
||||
|
||||
return $this->scopeQuery(function($query){
|
||||
return $query->distinct()->addSelect('products.*')->orderBy('id', 'desc');
|
||||
})->paginate(4, ['products.id']);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Shop\Http\ViewComposers\Categories;
|
||||
namespace Webkul\Shop\Http\ViewComposers;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
use Webkul\Category\Repositories\CategoryRepository as Category;
|
||||
|
||||
|
||||
|
|
@ -14,7 +13,6 @@ use Webkul\Category\Repositories\CategoryRepository as Category;
|
|||
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
|
||||
class CategoryComposer
|
||||
{
|
||||
/**
|
||||
|
|
@ -36,13 +34,20 @@ class CategoryComposer
|
|||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
$collected_cat = array();
|
||||
$categories = $this->category->getCategoryTree();
|
||||
foreach ($categories as $category) {
|
||||
array_push($collected_cat, collect($category));
|
||||
$categories = [];
|
||||
|
||||
foreach ($this->category->getCategoryTree() as $category) {
|
||||
array_push($categories, collect($category));
|
||||
}
|
||||
$view->with('categories', $collected_cat);
|
||||
|
||||
$view->with('categories', $categories);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Shop\Http\ViewComposers;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Support\Collection;
|
||||
use Webkul\Product\Repositories\ProductRepository as Product;
|
||||
|
||||
/**
|
||||
* New Products page
|
||||
*
|
||||
* @author Jitendra Singh <jitendra@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class NewProductListComposer
|
||||
{
|
||||
/**
|
||||
* ProductRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Product $product)
|
||||
{
|
||||
$this->product = $product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param View $view
|
||||
* @return void
|
||||
*/
|
||||
public function compose(View $view)
|
||||
{
|
||||
// dd($mytime = \Carbon\Carbon::now());
|
||||
$products = $this->product->getNewProducts();
|
||||
|
||||
$view->with('products', $products);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,17 +17,14 @@ class ComposerServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
//using the class based composers...
|
||||
View::composer(['shop::layouts.header.index', 'shop::layouts.footer.footer'], 'Webkul\Shop\Http\ViewComposers\Categories\CategoryComposer');
|
||||
}
|
||||
View::composer(
|
||||
['shop::layouts.header.index', 'shop::layouts.footer.footer'],
|
||||
'Webkul\Shop\Http\ViewComposers\CategoryComposer'
|
||||
);
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
View::composer(
|
||||
['shop::home.new-products'],
|
||||
'Webkul\Shop\Http\ViewComposers\NewProductListComposer'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<section class="featured-products">
|
||||
|
||||
<div class="featured-heading">
|
||||
New Products<br/>
|
||||
<span class="featured-seperator" style="color:lightgrey;">_____</span>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@
|
|||
{{ __('shop::app.products.by', ['name' => $review->customer->name]) }}
|
||||
</span>
|
||||
<span class="when">
|
||||
{{ $reviewHelper->formatDate($review->created_at) }}
|
||||
{{ core()->formatDate($review->created_at) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
</span>
|
||||
|
||||
<span class="when">
|
||||
{{ $reviewHelper->formatDate($review->created_at) }}
|
||||
{{ core()->formatDate($review->created_at) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class ProductGrid
|
|||
|
||||
public function __construct(AttributeRepository $attributes) {
|
||||
|
||||
$this->channel = request()->get('channel') ?: core()->getCurrentChannelCode();
|
||||
$this->channel = request()->get('channel') ?: core()->getDefaultChannelCode();
|
||||
$this->locale = request()->get('locale') ?: app()->getLocale();
|
||||
$this->attributes = $attributes;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue