¨4.0.1¨
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Themes\Storefront\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Ui\Facades\TabManager;
|
||||
use Themes\Storefront\Http\Requests\SaveStorefrontRequest;
|
||||
|
||||
@@ -10,7 +11,7 @@ class StorefrontController
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@@ -20,15 +21,16 @@ class StorefrontController
|
||||
return view('admin.storefront.edit', compact('settings', 'tabs'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function update(SaveStorefrontRequest $request)
|
||||
{
|
||||
setting($request->except('_token', '_method'));
|
||||
|
||||
return back()->withSuccess(trans('admin::messages.resource_saved', ['resource' => trans('setting::settings.settings')]));
|
||||
return back()->withSuccess(trans('admin::messages.resource_updated', ['resource' => trans('setting::settings.settings')]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace Themes\Storefront\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class FeaturedCategoryProductController extends ProductIndexController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param int $categoryNumber
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index($categoryNumber)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Themes\Storefront\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\FlashSale\Entities\FlashSale;
|
||||
|
||||
class FlashSaleProductController
|
||||
@@ -9,7 +10,7 @@ class FlashSaleProductController
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ class NewsletterPopup
|
||||
return response('')->withCookie($cookie);
|
||||
}
|
||||
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
$cookie = cookie()->forever('show_newsletter_popup', false);
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace Themes\Storefront\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ProductGridController extends ProductIndexController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param int $tabNumber
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index($tabNumber)
|
||||
{
|
||||
|
||||
@@ -11,18 +11,20 @@ class ProductIndexController
|
||||
{
|
||||
private $recentlyViewed;
|
||||
|
||||
|
||||
public function __construct(RecentlyViewed $recentlyViewed)
|
||||
{
|
||||
$this->recentlyViewed = $recentlyViewed;
|
||||
}
|
||||
|
||||
|
||||
protected function getProducts($settingPrefix)
|
||||
{
|
||||
$type = setting("{$settingPrefix}_product_type", 'custom_products');
|
||||
$limit = setting("{$settingPrefix}_products_limit");
|
||||
|
||||
if ($type === 'category_products') {
|
||||
return $this->categoryProducts($settingPrefix,$limit);
|
||||
return $this->categoryProducts($settingPrefix, $limit);
|
||||
}
|
||||
|
||||
if ($type === 'recently_viewed_products') {
|
||||
@@ -37,7 +39,8 @@ class ProductIndexController
|
||||
->clean();
|
||||
}
|
||||
|
||||
private function categoryProducts($settingPrefix,$limit)
|
||||
|
||||
private function categoryProducts($settingPrefix, $limit)
|
||||
{
|
||||
return Category::findOrNew(setting("{$settingPrefix}_category_id"))
|
||||
->products()
|
||||
@@ -46,33 +49,36 @@ class ProductIndexController
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
private function recentlyViewedProducts($limit)
|
||||
{
|
||||
return collect($this->recentlyViewed->products())
|
||||
->reverse()
|
||||
->when(! is_null($limit), function (Collection $products) use ($limit) {
|
||||
->when(!is_null($limit), function (Collection $products) use ($limit) {
|
||||
return $products->take($limit);
|
||||
})
|
||||
->values();
|
||||
}
|
||||
|
||||
|
||||
private function latestProductsCallback($limit)
|
||||
{
|
||||
return function ($query) use ($limit) {
|
||||
$query->latest()
|
||||
->when(! is_null($limit), function ($q) use ($limit) {
|
||||
->when(!is_null($limit), function ($q) use ($limit) {
|
||||
$q->limit($limit);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private function customProductsCallback($settingPrefix)
|
||||
{
|
||||
return function ($query) use ($settingPrefix) {
|
||||
$productIds = setting("{$settingPrefix}_products", []);
|
||||
|
||||
$query->whereIn('id', $productIds)
|
||||
->when(! empty($productIds), function ($q) use ($productIds) {
|
||||
->when(!empty($productIds), function ($q) use ($productIds) {
|
||||
$productIdsString = collect($productIds)->filter()->implode(',');
|
||||
|
||||
$q->orderByRaw("FIELD(id, {$productIdsString})");
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Themes\Storefront\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class TabProductController extends ProductIndexController
|
||||
{
|
||||
/**
|
||||
@@ -9,7 +11,8 @@ class TabProductController extends ProductIndexController
|
||||
*
|
||||
* @param int $sectionNumber
|
||||
* @param int $tabNumber
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index($sectionNumber, $tabNumber)
|
||||
{
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace Themes\Storefront\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class VerticalProductController extends ProductIndexController
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param int $columnNumber
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index($columnNumber)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user