Add variations, slider, fix cart ...
This commit is contained in:
50
app/Console/Commands/untranslateShelves.php
Normal file
50
app/Console/Commands/untranslateShelves.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use App\Models\Shop\Category;
|
||||||
|
|
||||||
|
class untranslateShelves extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'untranslateShelves';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Migrations of shelves';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$categories = Category::all();
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
$trans = json_decode($category->name, true);
|
||||||
|
$name = $trans['fr'];
|
||||||
|
$trans = $category->description ? json_decode($category->description, true) : false;
|
||||||
|
$description = $trans ? $trans['fr'] : '';
|
||||||
|
$category->update(['name' => $name, 'description' => $description]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ class CategoriesDataTable extends DataTable
|
|||||||
|
|
||||||
public function query(Category $model)
|
public function query(Category $model)
|
||||||
{
|
{
|
||||||
$model = $model::with(['tags.articles'])->withCount(['articles', 'tags']);
|
$model = $model::notRoot()->with(['tags.articles'])->withCount(['articles', 'tags']);
|
||||||
return $this->buildQuery($model);
|
return $this->buildQuery($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ class OffersDataTable extends DataTable
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('status_id')->title('')->width(40),
|
Column::make('status_id')->title('')->width(40),
|
||||||
Column::make('article.article_nature.name')->title('Nature'),
|
Column::make('article.article_nature.name')->title('Nature')->defaultContent(''),
|
||||||
Column::make('thumb')->title('')->width(40)->searchable(false),
|
Column::make('thumb')->title('')->width(40)->searchable(false)->order(false),
|
||||||
Column::make('article.name')->title('Article'),
|
Column::make('article.name')->title('Article')->defaultContent(''),
|
||||||
Column::make('variation.name')->title('Déclinaison'),
|
Column::make('variation.name')->title('Déclinaison')->defaultContent(''),
|
||||||
Column::make('tariff.name')->title('Tarif'),
|
Column::make('tariff.name')->title('Tarif')->defaultContent(''),
|
||||||
Column::make('stock_current')->title('Appro im')->searchable(false),
|
Column::make('stock_current')->title('Appro im')->searchable(false),
|
||||||
Column::make('stock_delayed')->title('Appro délai')->searchable(false),
|
Column::make('stock_delayed')->title('Appro délai')->searchable(false),
|
||||||
Column::make('stock_ondemand')->title('Dmde')->searchable(false),
|
Column::make('stock_ondemand')->title('Dmde')->searchable(false),
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ class ArticleController extends Controller
|
|||||||
{
|
{
|
||||||
$data = self::init();
|
$data = self::init();
|
||||||
$data['article'] = Articles::getArticleToSell($id);
|
$data['article'] = Articles::getArticleToSell($id);
|
||||||
|
// dump($data);
|
||||||
|
// exit;
|
||||||
return view('Shop.Articles.show', $data);
|
return view('Shop.Articles.show', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
70
app/Http/Controllers/Shop/BasketController.php
Normal file
70
app/Http/Controllers/Shop/BasketController.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Shop;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use App\Repositories\Core\User\ShopCart;
|
||||||
|
use App\Repositories\Shop\Offers;
|
||||||
|
|
||||||
|
class BasketController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getPrice(Request $request)
|
||||||
|
{
|
||||||
|
$offer_id = $request->input('offer_id');
|
||||||
|
$quantity = $request->input('quantity');
|
||||||
|
$price = Offers::getPrice($offer_id, $quantity)->price_taxed;
|
||||||
|
return $quantity * $price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addBasket(Request $request)
|
||||||
|
{
|
||||||
|
$offer_id = $request->input('offer_id');
|
||||||
|
$quantity = $request->input('quantity');
|
||||||
|
|
||||||
|
if (ShopCart::has($offer_id)) {
|
||||||
|
$ret = ShopCart::remove($offer_id);
|
||||||
|
}
|
||||||
|
$data = Offers::getBasketData($offer_id, $quantity);
|
||||||
|
$ret = ShopCart::add($data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function basket()
|
||||||
|
{
|
||||||
|
$data['basket'] = Offers::getBasket();
|
||||||
|
dump($data['basket']->toArray());
|
||||||
|
exit;
|
||||||
|
return view('Shop.Baskets.basket', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBasket()
|
||||||
|
{
|
||||||
|
$data = ShopCart::getContent();
|
||||||
|
return response()->json(['data' => $data, 'code' => '200']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function countBasket()
|
||||||
|
{
|
||||||
|
return ShopCart::count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function order(Request $request)
|
||||||
|
{
|
||||||
|
ShopCart::clear();
|
||||||
|
$data = $request->all();
|
||||||
|
unset($data['_token']);
|
||||||
|
$data['user_id'] = Users::getId();
|
||||||
|
Orders::newOrder($data);
|
||||||
|
return response()->json(['code' => '200']);
|
||||||
|
|
||||||
|
// return redirect()->route('ThirdParty.select');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clearBasket()
|
||||||
|
{
|
||||||
|
return ShopCart::clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,9 @@ class HomeController extends Controller
|
|||||||
$input = $request->input();
|
$input = $request->input();
|
||||||
$data = self::init();
|
$data = self::init();
|
||||||
$data['display_by_rows'] = $input['by_rows'] ?? false;
|
$data['display_by_rows'] = $input['by_rows'] ?? false;
|
||||||
$data['articles'] = Articles::getArticlesToSell();
|
$data['shelves'] = Articles::getArticlesByHomepage();
|
||||||
|
// dump($data['shelves']);
|
||||||
|
// exit;
|
||||||
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
||||||
return view('Shop.home', $data);
|
return view('Shop.home', $data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,12 +24,13 @@ class Category extends parentCategory
|
|||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
protected $table = 'categories';
|
protected $table = 'categories';
|
||||||
public $translatable = ['name', 'description'];
|
public $translatable = [];
|
||||||
protected $cascadeDeleteMorph = ['Articles'];
|
protected $cascadeDeleteMorph = ['Articles'];
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
'visible',
|
||||||
|
'homepage',
|
||||||
'slug',
|
'slug',
|
||||||
'name',
|
'name',
|
||||||
'visible',
|
|
||||||
'description',
|
'description',
|
||||||
NestedSet::LFT,
|
NestedSet::LFT,
|
||||||
NestedSet::RGT,
|
NestedSet::RGT,
|
||||||
@@ -61,4 +62,14 @@ class Category extends parentCategory
|
|||||||
{
|
{
|
||||||
return $query->where('visible', 1);
|
return $query->where('visible', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeHomepage($query)
|
||||||
|
{
|
||||||
|
return $query->where('homepage', 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeNotRoot($query)
|
||||||
|
{
|
||||||
|
return $query->where('id', '<>', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,4 +150,35 @@ class Offer extends Model
|
|||||||
$query->active()->bySaleChannel($sale_channel_id);
|
$query->active()->bySaleChannel($sale_channel_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeWithPriceListsBySaleChannel($query, $sale_channel_id)
|
||||||
|
{
|
||||||
|
return $query->with([
|
||||||
|
'price_lists' => function($query) use ($sale_channel_id) {
|
||||||
|
$query->bySaleChannel($sale_channel_id);
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeWithPriceListValuesBySaleChannel($query, $sale_channel_id)
|
||||||
|
{
|
||||||
|
return $query->with([
|
||||||
|
'price_lists' => function($query) use ($sale_channel_id) {
|
||||||
|
$query->bySaleChannel($sale_channel_id);
|
||||||
|
},
|
||||||
|
'price_lists.price_list_values',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeWithPriceBySaleChannelByQuantity($query, $sale_channel_id, $quantity = 1)
|
||||||
|
{
|
||||||
|
return $query->with([
|
||||||
|
'price_lists' => function($query) use ($sale_channel_id) {
|
||||||
|
$query->bySaleChannel($sale_channel_id);
|
||||||
|
},
|
||||||
|
'price_lists.price_list_values' => function($query) use ($quantity) {
|
||||||
|
$query->byQuantity($quantity);
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ class Categories
|
|||||||
{
|
{
|
||||||
$categories = self::getCategoryTreeVisibles()->toArray();
|
$categories = self::getCategoryTreeVisibles()->toArray();
|
||||||
return $categories ? self::getChildren($categories[0]['children'], $withFolder) : [];
|
return $categories ? self::getChildren($categories[0]['children'], $withFolder) : [];
|
||||||
return $categories ? self::getChildren($categories[0]['children'], $withFolder) : [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTree($withFolder = false)
|
public static function getTree($withFolder = false)
|
||||||
@@ -111,7 +110,7 @@ class Categories
|
|||||||
|
|
||||||
public static function getModel()
|
public static function getModel()
|
||||||
{
|
{
|
||||||
// return Category::class;
|
return app(Category::class);
|
||||||
return app('rinvex.categories.category');
|
// return app('rinvex.categories.category');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Repositories\Core\User;
|
namespace App\Repositories\Core\User;
|
||||||
|
|
||||||
use App\Repositories\Core\Auth\Users;
|
use App\Repositories\Core\Auth\Users;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use \Cart;
|
use \Cart;
|
||||||
|
|
||||||
class ShopCart
|
class ShopCart
|
||||||
@@ -19,9 +20,8 @@ class ShopCart
|
|||||||
|
|
||||||
public static function clear()
|
public static function clear()
|
||||||
{
|
{
|
||||||
Cart::session(1)->clear();
|
Cart::clear();
|
||||||
return Cart::clear();
|
return Cart::session(Auth::id())->clear();
|
||||||
// return self::get()->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function has($id)
|
public static function has($id)
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ class ShopCartStorage
|
|||||||
|
|
||||||
public function get($key)
|
public function get($key)
|
||||||
{
|
{
|
||||||
if ($this->has($key)) {
|
if (!$this->has($key)) {
|
||||||
return new CartCollection(CartStorage::find($key)->cart_data);
|
|
||||||
} else {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
return new CartCollection(CartStorage::find($key)->cart_data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function put($key, $value)
|
public function put($key, $value)
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class Articles
|
|||||||
$article_ids = self::getSiblingsIds($id);
|
$article_ids = self::getSiblingsIds($id);
|
||||||
$offers = Offers::getOffersByArticles($article_ids, $sale_channel_id);
|
$offers = Offers::getOffersByArticles($article_ids, $sale_channel_id);
|
||||||
foreach ($offers as $offer) {
|
foreach ($offers as $offer) {
|
||||||
$data[strtolower($offer->article_nature->name)] = [
|
$data[strtolower($offer->article_nature->name)][] = [
|
||||||
|
'id' => $offer->id,
|
||||||
'name' => $offer->variation->name,
|
'name' => $offer->variation->name,
|
||||||
'prices' => $offer->tariff->price_lists->first()->price_list_values->toArray(),
|
'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)
|
public static function getArticleToSell($id, $sale_channel_id = false)
|
||||||
{
|
{
|
||||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
|
||||||
$article = self::get($id);
|
$article = self::get($id);
|
||||||
$data = $article->toArray();
|
$data = $article->toArray();
|
||||||
$parents = self::getInheritedByProduct($article->product_id, $article->product_type);
|
$parents = self::getInheritedByProduct($article->product_id, $article->product_type);
|
||||||
@@ -126,6 +126,19 @@ class Articles
|
|||||||
return $data;
|
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)
|
public static function getArticlesToSell($category_id = false, $tags = false)
|
||||||
{
|
{
|
||||||
$articles = self::getArticlesWithOffers($category_id, $tags);
|
$articles = self::getArticlesWithOffers($category_id, $tags);
|
||||||
@@ -135,6 +148,7 @@ class Articles
|
|||||||
if (count($price_lists)) {
|
if (count($price_lists)) {
|
||||||
if (!is_array($data[$article->name] ?? false)) {
|
if (!is_array($data[$article->name] ?? false)) {
|
||||||
$data[$article->name] = [
|
$data[$article->name] = [
|
||||||
|
'id' => $article->id,
|
||||||
'description' => (!empty($article->description)) ? $article->description : $article->product->description,
|
'description' => (!empty($article->description)) ? $article->description : $article->product->description,
|
||||||
'image' => self::getFullImageByArticle($article),
|
'image' => self::getFullImageByArticle($article),
|
||||||
'product_type' => $article->product_type,
|
'product_type' => $article->product_type,
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ use App\Repositories\Core\Categories as CategoryTrees;
|
|||||||
|
|
||||||
class Categories
|
class Categories
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static function getByHomepage()
|
||||||
|
{
|
||||||
|
return Category::homepage()->orderBy('name', 'asc')->get();
|
||||||
|
}
|
||||||
|
|
||||||
public static function getAll()
|
public static function getAll()
|
||||||
{
|
{
|
||||||
return Category::orderBy('name', 'asc')->get();
|
return Category::orderBy('name', 'asc')->get();
|
||||||
|
|||||||
@@ -3,9 +3,40 @@
|
|||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
use App\Models\Shop\Offer;
|
use App\Models\Shop\Offer;
|
||||||
|
use App\Repositories\Core\User\ShopCart;
|
||||||
|
|
||||||
class Offers
|
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)
|
public static function getOffersByArticles($articles_ids, $sale_channel_id = false)
|
||||||
{
|
{
|
||||||
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
$sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID();
|
||||||
@@ -13,7 +44,7 @@ class Offers
|
|||||||
->with([
|
->with([
|
||||||
'article_nature',
|
'article_nature',
|
||||||
'variation',
|
'variation',
|
||||||
'tariff.price_lists' => function($query) use ($sale_channel_id) {
|
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
|
||||||
$query->bySaleChannel($sale_channel_id);
|
$query->bySaleChannel($sale_channel_id);
|
||||||
},
|
},
|
||||||
'tariff.price_lists.price_list_values',
|
'tariff.price_lists.price_list_values',
|
||||||
@@ -30,7 +61,7 @@ class Offers
|
|||||||
->with([
|
->with([
|
||||||
'article_nature',
|
'article_nature',
|
||||||
'variation',
|
'variation',
|
||||||
'tariff.price_lists' => function($query) use ($sale_channel_id) {
|
'tariff.price_lists' => function ($query) use ($sale_channel_id) {
|
||||||
$query->bySaleChannel($sale_channel_id);
|
$query->bySaleChannel($sale_channel_id);
|
||||||
},
|
},
|
||||||
'tariff.price_lists.price_list_values',
|
'tariff.price_lists.price_list_values',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-6">
|
<div class="col-5">
|
||||||
{{ Form::label('name', 'Nom') }}
|
{{ Form::label('name', 'Nom') }}
|
||||||
@include('components.form.input', ['name' => 'name', 'value' => $category['name'] ?? null, 'required' => true])
|
@include('components.form.input', ['name' => 'name', 'value' => $category['name'] ?? null, 'required' => true])
|
||||||
</div>
|
</div>
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
'class' => 'select2',
|
'class' => 'select2',
|
||||||
])
|
])
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-1 text-center">
|
||||||
|
{{ Form::label('homepage', 'Accueil') }}<br/>
|
||||||
|
@include('components.form.toggle', ['name' => 'homepage', 'value' => $category['homepage'] ?? null])
|
||||||
|
</div>
|
||||||
<div class="col-1 text-right">
|
<div class="col-1 text-right">
|
||||||
{{ Form::label('visible', 'Visible') }}<br/>
|
{{ Form::label('visible', 'Visible') }}<br/>
|
||||||
@include('components.form.toggle', ['name' => 'visible', 'value' => $category['visible'] ?? null])
|
@include('components.form.toggle', ['name' => 'visible', 'value' => $category['visible'] ?? null])
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
@if ($article['offers']['semences'] ?? false)
|
||||||
|
@include('Shop.Articles.partials.addBasket', [
|
||||||
|
'data' => $article['offers']['semences'],
|
||||||
|
'title' => 'Semence',
|
||||||
|
'model' => 'semences',
|
||||||
|
])
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($article['offers']['plants'] ?? false)
|
||||||
|
@include('Shop.Articles.partials.addBasket', [
|
||||||
|
'data' => $article['offers']['plants'],
|
||||||
|
'title' => 'Plant',
|
||||||
|
'model' => 'plants',
|
||||||
|
])
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($article['offers']['legumes'] ?? false)
|
||||||
|
@include('Shop.Articles.partials.addBasket', [
|
||||||
|
'data' => $article['offers']['legumes'],
|
||||||
|
'title' => 'Légume',
|
||||||
|
'model' => 'legumes',
|
||||||
|
])
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
$('.basket').click(function() {
|
||||||
|
var type = $(this).data('type');
|
||||||
|
var offer_id = $('#' + type + '-offer_id').find('option:selected').val();
|
||||||
|
var quantity = $('#' + type + '-quantity').val();
|
||||||
|
var data = {
|
||||||
|
'offer_id': offer_id,
|
||||||
|
'quantity': quantity,
|
||||||
|
};
|
||||||
|
$.post('{{ route("Shop.Basket.addBasket") }}', data, function() {
|
||||||
|
console.log('ici');
|
||||||
|
});
|
||||||
|
console.log(type);
|
||||||
|
console.log(offer_id);
|
||||||
|
console.log(quantity);
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
function setPrice(model) {
|
||||||
|
var offer_id = $('#' + model + '-offer_id').find('option:selected').val();
|
||||||
|
var quantity = $('#' + model + '-quantity').val();
|
||||||
|
var data = {
|
||||||
|
'offer_id': offer_id,
|
||||||
|
'quantity': quantity,
|
||||||
|
};
|
||||||
|
$.post('{{ route("Shop.Basket.getPrice") }}', data, function(data) {
|
||||||
|
$('#' + model + '-price').html(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
51
resources/views/Shop/Articles/partials/addBasket.blade.php
Normal file
51
resources/views/Shop/Articles/partials/addBasket.blade.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
@component('components.card', [
|
||||||
|
'id_card' => $model . '-basket',
|
||||||
|
'title' => $title,
|
||||||
|
'class' => 'mb-3',
|
||||||
|
])
|
||||||
|
|
||||||
|
@include('components.form.select', [
|
||||||
|
'name' => 'offer_id',
|
||||||
|
'id_name' => $model . '-offer_id',
|
||||||
|
'list' => collect($data)->pluck('name', 'id')->toArray(),
|
||||||
|
'class' => 'select2 mb-2',
|
||||||
|
])
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
@include('components.form.inputs.number', [
|
||||||
|
'name' => 'quantity',
|
||||||
|
'id_name' => $model . '-quantity',
|
||||||
|
'value' => 1,
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
<div class="col-8 text-right">
|
||||||
|
<span id="{{ $model }}-price" style="font-size:2em; font-weight: 600;">
|
||||||
|
{{ $data[0]['prices'][0]['price_taxed'] }}
|
||||||
|
</span>
|
||||||
|
€ TTC
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
@include('components.form.button', [
|
||||||
|
'metadata' => 'data-type=' . $model,
|
||||||
|
'class' => 'btn-success basket w-100 ' . $model,
|
||||||
|
'txt' => 'Ajouter au panier',
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
$('#{{ $model }}-quantity').change(function() {
|
||||||
|
setPrice('{{ $model }}');
|
||||||
|
});
|
||||||
|
$('#{{ $model }}-offer_id').change(function() {
|
||||||
|
setPrice('{{ $model }}');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -4,56 +4,19 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-1">
|
<div class="col-12">
|
||||||
|
<h1>{{ $article['name'] }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-5">
|
||||||
{!! $article['image_big'] !!}
|
{!! $article['image_big'] !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<h1>{{ $article['name'] }}</h1>
|
|
||||||
{!! $article['description'] !!}
|
{!! $article['description'] !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
@if ($article['offers']['semences'] ?? false)
|
@include('Shop.Articles.partials.ArticleAddBasket')
|
||||||
@component('components.card', [
|
|
||||||
'title' => 'Semence',
|
|
||||||
'class' => 'mb-3',
|
|
||||||
])
|
|
||||||
{{ $article['offers']['semences']['name'] }}<br>
|
|
||||||
{{ $article['offers']['semences']['prices'][0]['price_taxed'] }}<br>
|
|
||||||
@include('components.form.button', [
|
|
||||||
'class' => 'btn-success basket semences',
|
|
||||||
'txt' => 'Ajouter au panier',
|
|
||||||
])
|
|
||||||
@endcomponent
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($article['offers']['plants'] ?? false)
|
|
||||||
@component('components.card', [
|
|
||||||
'title' => 'Plant',
|
|
||||||
'class' => 'mb-3',
|
|
||||||
])
|
|
||||||
{{ $article['offers']['plants']['name'] }}<br>
|
|
||||||
{{ $article['offers']['plants']['prices'][0]['price_taxed'] }}<br>
|
|
||||||
@include('components.form.button', [
|
|
||||||
'class' => 'btn-success basket plants',
|
|
||||||
'txt' => 'Ajouter au panier',
|
|
||||||
])
|
|
||||||
@endcomponent
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($article['offers']['legumes'] ?? false)
|
|
||||||
@component('components.card', [
|
|
||||||
'title' => 'Légume',
|
|
||||||
'class' => 'mb-3',
|
|
||||||
])
|
|
||||||
@include('components.form.button', [
|
|
||||||
'class' => 'btn-success basket legumes',
|
|
||||||
'txt' => 'Ajouter au panier',
|
|
||||||
])
|
|
||||||
@endcomponent
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<div class="mb-3 bg-light">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-6">
|
||||||
|
<h1 style="font-size: 2em;">{{ $shelve['name'] }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 text-right">
|
||||||
|
<a href="">Découvrir la sélection</a>
|
||||||
|
<a href="">Tout voir</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row shelve_slider_{{ $shelve['id'] }}">
|
||||||
|
@foreach ($shelve['articles'] as $name => $article)
|
||||||
|
<div class="text-center pr-2 pl-2">
|
||||||
|
<a href="{{ route('Shop.Articles.show', ['id' => $article['id']]) }}">
|
||||||
|
<img data-lazy="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" class="d-block w-100" alt="{{ $name }}"/>
|
||||||
|
{{ $name }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
$('.shelve_slider_{{ $shelve['id'] }}').slick({
|
||||||
|
lazyLoad: 'ondemand',
|
||||||
|
slidesToShow: 6,
|
||||||
|
slidesToScroll: 1
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<div id="carousel_shelve_{{ $shelve['id'] ?? false }}" class="carousel slide" data-ride="carousel">
|
||||||
|
<div class="carousel-inner">
|
||||||
|
@foreach ($shelve['articles'] as $article)
|
||||||
|
<div class="carousel-item active">
|
||||||
|
<img class="d-block w-100" src="..." alt="First slide">
|
||||||
|
{{ $article['name'] }}
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
|
||||||
|
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
|
||||||
|
<span class="sr-only">Previous</span>
|
||||||
|
</a>
|
||||||
|
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
|
||||||
|
<span class="carousel-control-next-icon" aria-hidden="true"></span>
|
||||||
|
<span class="sr-only">Next</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
@include('Shop.Tags.partials.filter')
|
@include('Shop.Tags.partials.filter')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@if ($display_by_rows ?? false)
|
@foreach ($shelves as $shelve)
|
||||||
@include('Shop.layout.partials.category_articles_rows')
|
@include('Shop.Homepage.partials.sliderByShelve')
|
||||||
@else
|
@endforeach
|
||||||
@include('Shop.layout.partials.category_articles')
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@include('load.slick')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<div class="card {{ $class ?? 'mb-0' }} {{ isset($tabs) ? ($outline ?? config('boilerplate.theme.card.outline', false)) ? 'card-outline-tabs' : 'card-tabs' : ''}} {{ ($outline ?? config('boilerplate.theme.card.outline', false)) ? 'card-outline' : '' }} card-{{ $color ?? config('boilerplate.theme.card.default_color', 'info') }}">
|
<div @isset($id_card) id="{{ $id_card }}" @endisset class="card {{ $class ?? 'mb-0' }} {{ isset($tabs) ? ($outline ?? config('boilerplate.theme.card.outline', false)) ? 'card-outline-tabs' : 'card-tabs' : ''}} {{ ($outline ?? config('boilerplate.theme.card.outline', false)) ? 'card-outline' : '' }} card-{{ $color ?? config('boilerplate.theme.card.default_color', 'info') }}">
|
||||||
@if($title ?? $header ?? false)
|
@if($title ?? $header ?? false)
|
||||||
<div class="card-header {{ isset($tabs) ? ($outline ?? config('boilerplate.theme.card.outline', false)) ? 'p-0' : 'p-0 pt-1' : '' }} border-bottom-0">
|
<div class="card-header {{ isset($tabs) ? ($outline ?? config('boilerplate.theme.card.outline', false)) ? 'p-0' : 'p-0 pt-1' : '' }} border-bottom-0">
|
||||||
@isset($header)
|
@isset($header)
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<button type="{{ $type ?? 'button' }}" class="btn {{ $class ?? ''}}" @if (isset($id)) id="{{ $id }}"@endif>
|
<button type="{{ $type ?? 'button' }}" class="btn {{ $class ?? ''}}"
|
||||||
|
@if (isset($id)) id="{{ $id }}"@endif
|
||||||
|
@if (isset($data_id)) data-id="{{ $data_id }}"@endif
|
||||||
|
{{ $metadata ?? null }}
|
||||||
|
>
|
||||||
@if ($icon ?? false)<i class="fa fa-fw {{ $icon ?? '' }}"></i>@endif
|
@if ($icon ?? false)<i class="fa fa-fw {{ $icon ?? '' }}"></i>@endif
|
||||||
{{ $txt ?? '' }}
|
{{ $txt ?? '' }}
|
||||||
</button>
|
</button>
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
@if(!defined('LOAD_SLICKJS'))
|
@if(!defined('LOAD_SLICKJS'))
|
||||||
@push('css')
|
@push('css')
|
||||||
<link rel="stylesheet" type="text/css" href="{{ asset('/assets/plugins/slick/slick.css') }}"/>
|
<link rel="stylesheet" type="text/css" href="{{ asset('/assets/plugins/slick/slick.css') }}"/>
|
||||||
<link rel="stylesheet" type="text/css" href="{{ asset('/assets/plugins/slick/slick-theme.css') }}"/>
|
<link rel="stylesheet" type="text/css" href="{{ asset('/assets/plugins/slick/slick-theme.css') }}"/>
|
||||||
@endpush
|
@endpush
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript" src="{{ asset('/assets/plugins/slick/slick.min.js') }}"></script>
|
<script type="text/javascript" src="{{ asset('/assets/plugins/slick/slick.min.js') }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
@php(define('LOAD_SLICKJS', true))
|
@php(define('LOAD_SLICKJS', true))
|
||||||
@endif
|
@endif
|
||||||
12
routes/Shop/Baskets.php
Normal file
12
routes/Shop/Baskets.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Route::prefix('Basket')->name('Basket.')->group(function () {
|
||||||
|
Route::post('getPrice', 'BasketController@getPrice')->name('getPrice');
|
||||||
|
Route::post('addBasket', 'BasketController@addBasket')->name('addBasket');
|
||||||
|
Route::get('getBasket', 'BasketController@getBasket')->name('getBasket');
|
||||||
|
Route::get('countBasket', 'BasketController@countBasket')->name('countBasket');
|
||||||
|
Route::get('clearBasket', 'BasketController@clearBasket')->name('clearBasket');
|
||||||
|
Route::get('basket', 'BasketController@basket')->name('basket');
|
||||||
|
Route::post('order', 'BasketController@order')->name('order');
|
||||||
|
});
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
Route::prefix('Categories')->name('Categories.')->group(function () {
|
Route::prefix('Categories')->name('Categories.')->group(function () {
|
||||||
Route::get('', 'CategoryController@index')->name('index');
|
Route::get('', 'CategoryController@index')->name('index');
|
||||||
Route::get('show/{id}', 'CategoryController@show')->name('show');
|
Route::get('show/{id}', 'CategoryController@show')->name('show');
|
||||||
Route::get('getTree', 'CategoryController@getTree')->name('getTree');
|
Route::get('getTree', 'CategoryController@getTree')->name('getTree');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
Route::prefix('Shop')->namespace('Shop')->name('Shop.')->group(function () {
|
Route::prefix('Shop')->namespace('Shop')->name('Shop.')->group(function () {
|
||||||
include( __DIR__ . '/Articles.php');
|
include( __DIR__ . '/Articles.php');
|
||||||
|
include( __DIR__ . '/Baskets.php');
|
||||||
include( __DIR__ . '/Categories.php');
|
include( __DIR__ . '/Categories.php');
|
||||||
include( __DIR__ . '/Customers.php');
|
include( __DIR__ . '/Customers.php');
|
||||||
include( __DIR__ . '/Invoices.php');
|
include( __DIR__ . '/Invoices.php');
|
||||||
include( __DIR__ . '/Offers.php');
|
include( __DIR__ . '/Offers.php');
|
||||||
include( __DIR__ . '/Orders.php');
|
include( __DIR__ . '/Orders.php');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user