first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Themes\Storefront\Http\Controllers\Admin;
use Modules\Admin\Ui\Facades\TabManager;
use Themes\Storefront\Http\Requests\SaveStorefrontRequest;
class StorefrontController
{
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function edit()
{
$settings = setting()->all();
$tabs = TabManager::get('storefront');
return view('admin.storefront.edit', compact('settings', 'tabs'));
}
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function update(SaveStorefrontRequest $request)
{
setting($request->except('_token', '_method'));
return back()->withSuccess(trans('admin::messages.resource_saved', ['resource' => trans('setting::settings.settings')]));
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Themes\Storefront\Http\Controllers;
class CookieBarController
{
public function destroy()
{
$cookie = cookie()->forever('show_cookie_bar', false);
return response('')->withCookie($cookie);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Themes\Storefront\Http\Controllers;
class FeaturedCategoryProductController extends ProductIndexController
{
/**
* Display a listing of the resource.
*
* @param int $categoryNumber
* @return \Illuminate\Http\Response
*/
public function index($categoryNumber)
{
return $this->getProducts("storefront_featured_categories_section_category_{$categoryNumber}");
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Themes\Storefront\Http\Controllers;
use Modules\FlashSale\Entities\FlashSale;
class FlashSaleProductController
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return FlashSale::active()->products->map->clean();
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Themes\Storefront\Http\Controllers;
class NewsletterPopup
{
public function store()
{
$cookie = cookie()->forever('show_newsletter_popup', true);
return response('')->withCookie($cookie);
}
public function destroy()
{
$cookie = cookie()->forever('show_newsletter_popup', false);
return response('')->withCookie($cookie);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Themes\Storefront\Http\Controllers;
class ProductGridController extends ProductIndexController
{
/**
* Display a listing of the resource.
*
* @param int $tabNumber
* @return \Illuminate\Http\Response
*/
public function index($tabNumber)
{
return $this->getProducts("storefront_product_grid_section_tab_{$tabNumber}");
}
}

View File

@@ -0,0 +1,82 @@
<?php
namespace Themes\Storefront\Http\Controllers;
use Illuminate\Support\Collection;
use Modules\Product\RecentlyViewed;
use Modules\Product\Entities\Product;
use Modules\Category\Entities\Category;
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);
}
if ($type === 'recently_viewed_products') {
return $this->recentlyViewedProducts($limit);
}
return Product::forCard()
->when($type === 'latest_products', $this->latestProductsCallback($limit))
->when($type === 'custom_products', $this->customProductsCallback($settingPrefix))
->get()
->map
->clean();
}
private function categoryProducts($settingPrefix,$limit)
{
return Category::findOrNew(setting("{$settingPrefix}_category_id"))
->products()
->forCard()
->take($limit)
->get();
}
private function recentlyViewedProducts($limit)
{
return collect($this->recentlyViewed->products())
->reverse()
->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) {
$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) {
$productIdsString = collect($productIds)->filter()->implode(',');
$q->orderByRaw("FIELD(id, {$productIdsString})");
});
};
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Themes\Storefront\Http\Controllers;
class TabProductController extends ProductIndexController
{
/**
* Display a listing of the resource.
*
* @param int $sectionNumber
* @param int $tabNumber
* @return \Illuminate\Http\Response
*/
public function index($sectionNumber, $tabNumber)
{
return $this->getProducts("storefront_product_tabs_{$sectionNumber}_section_tab_{$tabNumber}");
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Themes\Storefront\Http\Controllers;
class VerticalProductController extends ProductIndexController
{
/**
* Display a listing of the resource.
*
* @param int $columnNumber
* @return \Illuminate\Http\Response
*/
public function index($columnNumber)
{
return $this->getProducts("storefront_vertical_products_{$columnNumber}");
}
}