Add variations, slider, fix cart ...
This commit is contained in:
@@ -20,7 +20,6 @@ class Categories
|
||||
{
|
||||
$categories = self::getCategoryTreeVisibles()->toArray();
|
||||
return $categories ? self::getChildren($categories[0]['children'], $withFolder) : [];
|
||||
return $categories ? self::getChildren($categories[0]['children'], $withFolder) : [];
|
||||
}
|
||||
|
||||
public static function getTree($withFolder = false)
|
||||
@@ -111,7 +110,7 @@ class Categories
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
// return Category::class;
|
||||
return app('rinvex.categories.category');
|
||||
return app(Category::class);
|
||||
// return app('rinvex.categories.category');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Repositories\Core\User;
|
||||
|
||||
use App\Repositories\Core\Auth\Users;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use \Cart;
|
||||
|
||||
class ShopCart
|
||||
@@ -19,9 +20,8 @@ class ShopCart
|
||||
|
||||
public static function clear()
|
||||
{
|
||||
Cart::session(1)->clear();
|
||||
return Cart::clear();
|
||||
// return self::get()->clear();
|
||||
Cart::clear();
|
||||
return Cart::session(Auth::id())->clear();
|
||||
}
|
||||
|
||||
public static function has($id)
|
||||
|
||||
@@ -16,11 +16,11 @@ class ShopCartStorage
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||
} else {
|
||||
if (!$this->has($key)) {
|
||||
return [];
|
||||
}
|
||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||
|
||||
}
|
||||
|
||||
public function put($key, $value)
|
||||
|
||||
@@ -32,7 +32,8 @@ class Articles
|
||||
$article_ids = self::getSiblingsIds($id);
|
||||
$offers = Offers::getOffersByArticles($article_ids, $sale_channel_id);
|
||||
foreach ($offers as $offer) {
|
||||
$data[strtolower($offer->article_nature->name)] = [
|
||||
$data[strtolower($offer->article_nature->name)][] = [
|
||||
'id' => $offer->id,
|
||||
'name' => $offer->variation->name,
|
||||
'prices' => $offer->tariff->price_lists->first()->price_list_values->toArray(),
|
||||
];
|
||||
@@ -77,7 +78,6 @@ class Articles
|
||||
|
||||
public static function getArticleToSell($id, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
$article = self::get($id);
|
||||
$data = $article->toArray();
|
||||
$parents = self::getInheritedByProduct($article->product_id, $article->product_type);
|
||||
@@ -126,6 +126,19 @@ class Articles
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getArticlesByHomepage()
|
||||
{
|
||||
$shelves = Categories::getByHomepage();
|
||||
foreach ($shelves as $shelve) {
|
||||
$data[] = [
|
||||
'id' => $shelve->id,
|
||||
'name' => $shelve->name,
|
||||
'articles' => self::getArticlesToSell($shelve->id),
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getArticlesToSell($category_id = false, $tags = false)
|
||||
{
|
||||
$articles = self::getArticlesWithOffers($category_id, $tags);
|
||||
@@ -135,6 +148,7 @@ class Articles
|
||||
if (count($price_lists)) {
|
||||
if (!is_array($data[$article->name] ?? false)) {
|
||||
$data[$article->name] = [
|
||||
'id' => $article->id,
|
||||
'description' => (!empty($article->description)) ? $article->description : $article->product->description,
|
||||
'image' => self::getFullImageByArticle($article),
|
||||
'product_type' => $article->product_type,
|
||||
|
||||
@@ -8,6 +8,12 @@ use App\Repositories\Core\Categories as CategoryTrees;
|
||||
|
||||
class Categories
|
||||
{
|
||||
|
||||
public static function getByHomepage()
|
||||
{
|
||||
return Category::homepage()->orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return Category::orderBy('name', 'asc')->get();
|
||||
|
||||
@@ -3,9 +3,40 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Offer;
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
|
||||
class Offers
|
||||
{
|
||||
|
||||
public static function getPrice($id, $quantity = 1, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
$offer = Offer::withPriceBySaleChannelByQuantity($sale_channel_id, $quantity)->find($id);
|
||||
return $offer->price_lists->first()->price_list_values->first();
|
||||
}
|
||||
|
||||
public static function getBasket()
|
||||
{
|
||||
$basket = ShopCart::getContent();
|
||||
$offers = Offer::with(['variation', 'article.article_nature'])->whereIn('id', ShopCart::keys())->get();
|
||||
dump($basket->toArray());
|
||||
dump($offers->toArray());
|
||||
exit;
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getBasketData($id, $quantity = 1)
|
||||
{
|
||||
$offer = Offer::with(['article'])->findOrFail($id);
|
||||
return [
|
||||
'id' => $id,
|
||||
'name' => $offer->article->name,
|
||||
'price' => self::getPrice($id, $quantity)->price_taxed,
|
||||
'quantity' => $quantity,
|
||||
'attributes' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public static function getOffersByArticles($articles_ids, $sale_channel_id = false)
|
||||
{
|
||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||
@@ -13,7 +44,7 @@ class Offers
|
||||
->with([
|
||||
'article_nature',
|
||||
'variation',
|
||||
'tariff.price_lists' => function($query) use ($sale_channel_id) {
|
||||
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
'tariff.price_lists.price_list_values',
|
||||
@@ -30,7 +61,7 @@ class Offers
|
||||
->with([
|
||||
'article_nature',
|
||||
'variation',
|
||||
'tariff.price_lists' => function($query) use ($sale_channel_id) {
|
||||
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
|
||||
$query->bySaleChannel($sale_channel_id);
|
||||
},
|
||||
'tariff.price_lists.price_list_values',
|
||||
|
||||
Reference in New Issue
Block a user