refactoring on Articles, minor fixes
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Datatables\Admin\Shop\ArticlesDataTable;
|
|||||||
use App\Http\Requests\Admin\Shop\StoreArticlePost;
|
use App\Http\Requests\Admin\Shop\StoreArticlePost;
|
||||||
use App\Repositories\Shop\ArticleNatures;
|
use App\Repositories\Shop\ArticleNatures;
|
||||||
use App\Repositories\Shop\Articles;
|
use App\Repositories\Shop\Articles;
|
||||||
|
use App\Repositories\Shop\ArticleInherited;
|
||||||
use App\Repositories\Shop\Categories;
|
use App\Repositories\Shop\Categories;
|
||||||
use App\Repositories\Shop\Tags;
|
use App\Repositories\Shop\Tags;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -71,7 +72,7 @@ class ArticleController extends Controller
|
|||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'article' => [
|
'article' => [
|
||||||
'inherited' => Articles::getInheritedByProduct($productId, base64_decode($model)),
|
'inherited' => ArticleInherited::getInheritedByProduct($productId, base64_decode($model)),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ class ArticleController extends Controller
|
|||||||
|
|
||||||
public function getProductTags($productId, $model)
|
public function getProductTags($productId, $model)
|
||||||
{
|
{
|
||||||
$data = Articles::getInheritedByProduct($productId, base64_decode($model));
|
$data = ArticleInherited::getInheritedByProduct($productId, base64_decode($model));
|
||||||
|
|
||||||
return view('Admin.Shop.Articles.partials.product.tags', $data);
|
return view('Admin.Shop.Articles.partials.product.tags', $data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ContentController extends Controller
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'homepage' => Contents::get($id),
|
'content' => Contents::get($id),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('Admin.Shop.Contents.edit', $data);
|
return view('Admin.Shop.Contents.edit', $data);
|
||||||
|
|||||||
@@ -10,19 +10,17 @@ class CustomerAddressController extends Controller
|
|||||||
{
|
{
|
||||||
public function index(CustomerAddressesDataTable $dataTable)
|
public function index(CustomerAddressesDataTable $dataTable)
|
||||||
{
|
{
|
||||||
$data = [];
|
return $dataTable->render('Admin.Shop.Customers.list');
|
||||||
|
|
||||||
return $dataTable->render('Admin.Shop.Customers.list', $data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
return view('Admin.Shop.CustomerAddresses.create', $data);
|
return view('Admin.Shop.CustomerAddresses.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store(Request $request)
|
public function store(Request $request)
|
||||||
{
|
{
|
||||||
$ret = CustomerAddresses::storeFull($request->all());
|
$ret = CustomerAddresses::store($request->all());
|
||||||
|
|
||||||
return redirect()->route('Admin.Shop.CustomerAddresses.index');
|
return redirect()->route('Admin.Shop.CustomerAddresses.index');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Shop;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Repositories\Shop\Articles;
|
use App\Repositories\Shop\Articles;
|
||||||
|
use App\Repositories\Shop\ArticleSiblings;
|
||||||
|
|
||||||
class ArticleController extends Controller
|
class ArticleController extends Controller
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,7 @@ class ArticleController extends Controller
|
|||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'article' => Articles::getArticleToSell($id),
|
'article' => Articles::getArticleToSell($id),
|
||||||
'offers2' => Articles::getSiblings($id)->toArray(),
|
'offers2' => ArticleSiblings::getSiblings($id)->toArray(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('Shop.Articles.show', $data);
|
return view('Shop.Articles.show', $data);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Shop;
|
namespace App\Http\Controllers\Shop;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Repositories\Core\PDF;
|
use App\Repositories\Shop\InvoicePDF;
|
||||||
use App\Repositories\Shop\Invoices;
|
use App\Repositories\Shop\Invoices;
|
||||||
|
|
||||||
class InvoiceController extends Controller
|
class InvoiceController extends Controller
|
||||||
@@ -24,11 +24,6 @@ class InvoiceController extends Controller
|
|||||||
{
|
{
|
||||||
\Debugbar::disable();
|
\Debugbar::disable();
|
||||||
|
|
||||||
$data = [
|
return InvoicePDF::getByUUID($uuid);
|
||||||
'invoice' => Invoices::getByUUID($uuid),
|
|
||||||
];
|
|
||||||
$filename = 'invoice-'.$uuid.'.pdf';
|
|
||||||
|
|
||||||
return PDF::view('Shop.Invoices.pdf', $data, $filename);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ class Tax extends Model
|
|||||||
|
|
||||||
public function price()
|
public function price()
|
||||||
{
|
{
|
||||||
return $this->hasMany(ArticlePrice::class, 'id', 'tax_id');
|
return $this->hasMany(PriceListValue::class, 'id', 'tax_id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
62
app/Repositories/Shop/ArticleCategories.php
Normal file
62
app/Repositories/Shop/ArticleCategories.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
use App\Models\Shop\Merchandise;
|
||||||
|
use App\Repositories\Botanic\Species;
|
||||||
|
use App\Repositories\Botanic\Varieties;
|
||||||
|
use App\Repositories\Core\Comments;
|
||||||
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
|
use App\Traits\Repository\Imageable;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleCategories
|
||||||
|
{
|
||||||
|
public static function getProductTypeByCategory($category_id)
|
||||||
|
{
|
||||||
|
$models = self::getProductTypesModelsByCategory($category_id);
|
||||||
|
|
||||||
|
return ($models[0] ?? false) === Merchandise::class ? 'merchandise' : 'botanic';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getProductTypesModelsByCategory($category_id)
|
||||||
|
{
|
||||||
|
return Article::byCategory($category_id)->select('product_type')->distinct()->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function countProductTypesByCategory($category_id)
|
||||||
|
{
|
||||||
|
return Article::byCategory($category_id)->select('product_type')->distinct()->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getByCategory($category_id)
|
||||||
|
{
|
||||||
|
return Article::byCategory($category_id)->with(['prices', 'product', 'image'])->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCategoriesByArticle($article)
|
||||||
|
{
|
||||||
|
return $article->categories->pluck('id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCategoriesNameByArticle($article)
|
||||||
|
{
|
||||||
|
return $article->categories->pluck('name', 'id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeCategories($article, $categories)
|
||||||
|
{
|
||||||
|
if (! $categories) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$categories = collect($categories)->transform(
|
||||||
|
function ($item, $key) {
|
||||||
|
return (int) $item;
|
||||||
|
}
|
||||||
|
)->toArray();
|
||||||
|
|
||||||
|
return $article->syncCategories($categories, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
110
app/Repositories/Shop/ArticleImages.php
Normal file
110
app/Repositories/Shop/ArticleImages.php
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
use App\Models\Shop\Merchandise;
|
||||||
|
use App\Repositories\Botanic\Species;
|
||||||
|
use App\Repositories\Botanic\Varieties;
|
||||||
|
use App\Repositories\Core\Comments;
|
||||||
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
|
use App\Traits\Repository\Imageable;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleImages
|
||||||
|
{
|
||||||
|
use Basic, Imageable;
|
||||||
|
|
||||||
|
public static function getFullImagesByArticleId($id)
|
||||||
|
{
|
||||||
|
$article = self::get($id);
|
||||||
|
|
||||||
|
return $article ? self::getFullImagesByArticle($article) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function countFullImagesByArticleId($id)
|
||||||
|
{
|
||||||
|
$article = self::get($id);
|
||||||
|
|
||||||
|
return $article ? self::countFullImagesByArticle($article) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function countFullImagesByArticle($article)
|
||||||
|
{
|
||||||
|
return count(self::getFullImagesByArticle($article));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFullImagesByArticle($article)
|
||||||
|
{
|
||||||
|
$images = count($article->images) ? $article->images : collect([]);
|
||||||
|
switch ($article->product_type) {
|
||||||
|
case 'App\Models\Botanic\Variety':
|
||||||
|
$variety = $article->product ?? false;
|
||||||
|
$specie = $variety->specie ?? false;
|
||||||
|
if ($variety) {
|
||||||
|
$images = count($variety->images ?? []) ? $images->merge($variety->images) : $images;
|
||||||
|
}
|
||||||
|
if ($specie) {
|
||||||
|
$images = count($specie->images ?? []) ? $images->merge($specie->images) : $images;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'App\Models\Botanic\Specie':
|
||||||
|
$specie = $article->product ?? false;
|
||||||
|
$images = count($specie->images ?? []) ? $specie->images : $images;
|
||||||
|
break;
|
||||||
|
case 'App\Models\Shop\Merchandise':
|
||||||
|
$merchandise = $article->product ?? false;
|
||||||
|
$images = count($merchandise->images ?? []) ? $merchandise->images : $images;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return $images;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFullImageById($id)
|
||||||
|
{
|
||||||
|
return self::getFullImageByArticle(self::get($id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFullImageByArticle($article)
|
||||||
|
{
|
||||||
|
$image = $article->image;
|
||||||
|
if ($image) {
|
||||||
|
return $image;
|
||||||
|
}
|
||||||
|
switch ($article->product_type) {
|
||||||
|
case 'App\Models\Botanic\Variety':
|
||||||
|
$image = $article->product->image ?? ($article->product->specie->image ?? false);
|
||||||
|
break;
|
||||||
|
case 'App\Models\Botanic\Specie':
|
||||||
|
$image = $article->product->image ?? false;
|
||||||
|
break;
|
||||||
|
case 'App\Models\Shop\Merchandise':
|
||||||
|
$image = $article->product->image ?? false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return $image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInheritedImagesByProduct($product_id, $product_type)
|
||||||
|
{
|
||||||
|
switch ($product_type) {
|
||||||
|
case 'App\Models\Botanic\Variety':
|
||||||
|
$images = Varieties::getImages($product_id);
|
||||||
|
break;
|
||||||
|
case 'App\Models\Botanic\Specie':
|
||||||
|
$images = Species::getImages($product_id);
|
||||||
|
break;
|
||||||
|
case 'App\Models\Shop\Merchandise':
|
||||||
|
$images = Merchandises::getImages($product_id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return $images ?? false ? ['images' => $images] : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
65
app/Repositories/Shop/ArticleInherited.php
Normal file
65
app/Repositories/Shop/ArticleInherited.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
use App\Repositories\Botanic\Species;
|
||||||
|
use App\Repositories\Botanic\Varieties;
|
||||||
|
|
||||||
|
class ArticleInherited
|
||||||
|
{
|
||||||
|
public static function getInherited($id)
|
||||||
|
{
|
||||||
|
$article = Article::with('product.tags.tag_group')->findOrFail($id);
|
||||||
|
|
||||||
|
return self::getInheritedByProduct($article->product_id, $article->product_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getInheritedByProduct($product_id, $product_type)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
switch ($product_type) {
|
||||||
|
case 'App\Models\Botanic\Variety':
|
||||||
|
$product = Varieties::get($product_id);
|
||||||
|
if (! $product) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$data[] = [
|
||||||
|
'name' => 'Espèces',
|
||||||
|
'description' => Species::getDescription($product->specie_id),
|
||||||
|
'tags' => Species::getTags($product->specie_id),
|
||||||
|
];
|
||||||
|
$data[] = [
|
||||||
|
'name' => 'Variétés',
|
||||||
|
'description' => $product->description,
|
||||||
|
'tags' => $product->tags->toArray(),
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
case 'App\Models\Botanic\Specie':
|
||||||
|
$product = Species::get($product_id);
|
||||||
|
if (! $product) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$data[] = [
|
||||||
|
'name' => 'Espèces',
|
||||||
|
'description' => $product->description,
|
||||||
|
'tags' => $product->tags->toArray(),
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
case 'App\Models\Shop\Merchandise':
|
||||||
|
$product = Merchandises::get($product_id);
|
||||||
|
if (! $product) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$data[] = [
|
||||||
|
'name' => 'Marchandise',
|
||||||
|
'description' => $product->description,
|
||||||
|
'tags' => $product->tags->toArray(),
|
||||||
|
];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data ?? false;
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/Repositories/Shop/ArticleSiblings.php
Normal file
43
app/Repositories/Shop/ArticleSiblings.php
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
use App\Models\Shop\Merchandise;
|
||||||
|
use App\Repositories\Botanic\Species;
|
||||||
|
use App\Repositories\Botanic\Varieties;
|
||||||
|
use App\Repositories\Core\Comments;
|
||||||
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
|
use App\Traits\Repository\Imageable;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleSiblings
|
||||||
|
{
|
||||||
|
public static function getSiblingsIDs($id)
|
||||||
|
{
|
||||||
|
return self::getSiblings($id)->pluck('id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSiblingsDescriptions($id)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$siblings = self::getSiblings($id);
|
||||||
|
foreach ($siblings as $sibling) {
|
||||||
|
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
|
||||||
|
$data[strtolower($sibling->article_nature->name)] = $sibling->description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSiblings($id)
|
||||||
|
{
|
||||||
|
return Article::with([
|
||||||
|
'siblings' => function ($query) use ($id) {
|
||||||
|
$query->where('id', '!=', $id);
|
||||||
|
},
|
||||||
|
])->find($id)->siblings;
|
||||||
|
}
|
||||||
|
}
|
||||||
67
app/Repositories/Shop/ArticleTags.php
Normal file
67
app/Repositories/Shop/ArticleTags.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
use App\Models\Shop\Merchandise;
|
||||||
|
use App\Repositories\Botanic\Species;
|
||||||
|
use App\Repositories\Botanic\Varieties;
|
||||||
|
use App\Repositories\Core\Comments;
|
||||||
|
use App\Repositories\Core\Tag;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
|
use App\Traits\Repository\Imageable;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ArticleTags
|
||||||
|
{
|
||||||
|
public static function getTagsByArticle($article)
|
||||||
|
{
|
||||||
|
return $article->tags->pluck('id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTagsNameByArticle($article)
|
||||||
|
{
|
||||||
|
return $article->tags->pluck('name', 'id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTagsSlugByArticle($article)
|
||||||
|
{
|
||||||
|
return $article->tags->pluck('slug', 'id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFullTagsSlugByArticle($article)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
switch ($article->product_type) {
|
||||||
|
case 'App\Models\Botanic\Variety':
|
||||||
|
$data += $article->product->tags->toArray();
|
||||||
|
if ($article->product->specie ?? false) {
|
||||||
|
$data += $article->product->specie->tags->toArray();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'App\Models\Botanic\Specie':
|
||||||
|
$data += $article->product->tags->toArray();
|
||||||
|
break;
|
||||||
|
case 'App\Models\Shop\Merchandise':
|
||||||
|
$data += $article->product->tags->toArray();
|
||||||
|
$data += $article->product->producer->tags->toArray();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
$data += $article->tags->toArray();
|
||||||
|
|
||||||
|
foreach ($data as $tag) {
|
||||||
|
if (! isset($tags[$tag['group']][$tag['name']])) {
|
||||||
|
$tags[$tag['group']][] = $tag['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tags ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function storeTags($article, $tags)
|
||||||
|
{
|
||||||
|
return Tag::storeTags($article, $tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getOffersGroupedByNature($id, $saleChannelId = false)
|
public static function getOffersGroupedByNature($id, $saleChannelId = false)
|
||||||
{
|
{
|
||||||
$articleIds = self::getSiblingsIds($id);
|
$articleIds = ArticleSiblings::getSiblingsIds($id);
|
||||||
$articleIds[] = $id;
|
$articleIds[] = $id;
|
||||||
$offers = Offers::getOffersByArticles($articleIds, $saleChannelId);
|
$offers = Offers::getOffersByArticles($articleIds, $saleChannelId);
|
||||||
foreach ($offers as $offer) {
|
foreach ($offers as $offer) {
|
||||||
@@ -43,33 +43,6 @@ class Articles
|
|||||||
return $data ?? false;
|
return $data ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSiblingsIDs($id)
|
|
||||||
{
|
|
||||||
return self::getSiblings($id)->pluck('id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getSiblingsDescriptions($id)
|
|
||||||
{
|
|
||||||
$data = [];
|
|
||||||
$siblings = self::getSiblings($id);
|
|
||||||
foreach ($siblings as $sibling) {
|
|
||||||
if ($sibling->description && ($sibling->article_nature->name ?? false)) {
|
|
||||||
$data[strtolower($sibling->article_nature->name)] = $sibling->description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getSiblings($id)
|
|
||||||
{
|
|
||||||
return Article::with([
|
|
||||||
'siblings' => function ($query) use ($id) {
|
|
||||||
$query->where('id', '!=', $id);
|
|
||||||
},
|
|
||||||
])->find($id)->siblings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getOffersById($id)
|
public static function getOffersById($id)
|
||||||
{
|
{
|
||||||
return Offers::getOffersByArticle($id);
|
return Offers::getOffersByArticle($id);
|
||||||
@@ -105,13 +78,13 @@ class Articles
|
|||||||
$article = self::get($id);
|
$article = self::get($id);
|
||||||
$data = $article->toArray();
|
$data = $article->toArray();
|
||||||
$data['description'] = self::getFullDescriptionByArticle($article);
|
$data['description'] = self::getFullDescriptionByArticle($article);
|
||||||
$images = self::getFullImagesByArticle($article);
|
$images = ArticleImages::getFullImagesByArticle($article);
|
||||||
$data['image'] = self::getPreviewSrc($images[0] ?? false);
|
$data['image'] = self::getPreviewSrc($images[0] ?? false);
|
||||||
$data['images'] = count($images) ? $images : false;
|
$data['images'] = count($images) ? $images : false;
|
||||||
$data['image_big'] = self::getImageSrc($images[0] ?? false);
|
$data['image_big'] = self::getImageSrc($images[0] ?? false);
|
||||||
$data['inherited'] = self::getInherited($id);
|
$data['inherited'] = ArticleInherited::getInherited($id);
|
||||||
$data['categories'] = self::getCategoriesNameByArticle($article);
|
$data['categories'] = ArticleCategories::getCategoriesNameByArticle($article);
|
||||||
$data['tags'] = self::getFullTagsSlugByArticle($article);
|
$data['tags'] = ArticleTags::getFullTagsSlugByArticle($article);
|
||||||
$data['comments'] = Comments::getByModel($article);
|
$data['comments'] = Comments::getByModel($article);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@@ -140,7 +113,7 @@ class Articles
|
|||||||
if ($article->description) {
|
if ($article->description) {
|
||||||
$data[strtolower($article->article_nature->name ?? '')] = $article->description;
|
$data[strtolower($article->article_nature->name ?? '')] = $article->description;
|
||||||
}
|
}
|
||||||
$siblings = self::getSiblingsDescriptions($article->id);
|
$siblings = ArticleSiblings::getSiblingsDescriptions($article->id);
|
||||||
if ($siblings) {
|
if ($siblings) {
|
||||||
array_push($data, $siblings);
|
array_push($data, $siblings);
|
||||||
}
|
}
|
||||||
@@ -195,7 +168,7 @@ class Articles
|
|||||||
'id' => $article->id,
|
'id' => $article->id,
|
||||||
'article_nature_id' => $article->article_nature_id,
|
'article_nature_id' => $article->article_nature_id,
|
||||||
'description' => $article->description ? $article->description : $article->product->description,
|
'description' => $article->description ? $article->description : $article->product->description,
|
||||||
'image' => self::getFullImageByArticle($article),
|
'image' => ArticleImages::getFullImageByArticle($article),
|
||||||
'product_type' => $article->product_type,
|
'product_type' => $article->product_type,
|
||||||
'product_id' => $article->product_id,
|
'product_id' => $article->product_id,
|
||||||
'product_name' => $article->product->name,
|
'product_name' => $article->product->name,
|
||||||
@@ -315,87 +288,14 @@ class Articles
|
|||||||
{
|
{
|
||||||
$article = self::get($id);
|
$article = self::get($id);
|
||||||
$data = $article->toArray();
|
$data = $article->toArray();
|
||||||
$data['inherited'] = self::getInherited($id);
|
$data['inherited'] = ArticleInherited::getInherited($id);
|
||||||
$data['categories'] = self::getCategoriesByArticle($article);
|
$data['categories'] = ArticleCategories::getCategoriesByArticle($article);
|
||||||
$data['tags'] = self::getTagsByArticle($article);
|
$data['tags'] = ArticleTags::getTagsByArticle($article);
|
||||||
$data['comments'] = Comments::getByModel($article);
|
$data['comments'] = Comments::getByModel($article);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInherited($id)
|
|
||||||
{
|
|
||||||
$article = Article::with('product.tags.tag_group')->findOrFail($id);
|
|
||||||
|
|
||||||
return self::getInheritedByProduct($article->product_id, $article->product_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getInheritedByProduct($product_id, $product_type)
|
|
||||||
{
|
|
||||||
$data = [];
|
|
||||||
switch ($product_type) {
|
|
||||||
case 'App\Models\Botanic\Variety':
|
|
||||||
$product = Varieties::get($product_id);
|
|
||||||
if (! $product) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$data[] = [
|
|
||||||
'name' => 'Espèces',
|
|
||||||
'description' => Species::getDescription($product->specie_id),
|
|
||||||
'tags' => Species::getTags($product->specie_id),
|
|
||||||
];
|
|
||||||
$data[] = [
|
|
||||||
'name' => 'Variétés',
|
|
||||||
'description' => $product->description,
|
|
||||||
'tags' => $product->tags->toArray(),
|
|
||||||
];
|
|
||||||
break;
|
|
||||||
case 'App\Models\Botanic\Specie':
|
|
||||||
$product = Species::get($product_id);
|
|
||||||
if (! $product) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$data[] = [
|
|
||||||
'name' => 'Espèces',
|
|
||||||
'description' => $product->description,
|
|
||||||
'tags' => $product->tags->toArray(),
|
|
||||||
];
|
|
||||||
break;
|
|
||||||
case 'App\Models\Shop\Merchandise':
|
|
||||||
$product = Merchandises::get($product_id);
|
|
||||||
if (! $product) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$data[] = [
|
|
||||||
'name' => 'Marchandise',
|
|
||||||
'description' => $product->description,
|
|
||||||
'tags' => $product->tags->toArray(),
|
|
||||||
];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getInheritedImagesByProduct($product_id, $product_type)
|
|
||||||
{
|
|
||||||
switch ($product_type) {
|
|
||||||
case 'App\Models\Botanic\Variety':
|
|
||||||
$images = Varieties::getImages($product_id);
|
|
||||||
break;
|
|
||||||
case 'App\Models\Botanic\Specie':
|
|
||||||
$images = Species::getImages($product_id);
|
|
||||||
break;
|
|
||||||
case 'App\Models\Shop\Merchandise':
|
|
||||||
$images = Merchandises::getImages($product_id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
return $images ?? false ? ['images' => $images] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getMeta(&$data = [])
|
public static function getMeta(&$data = [])
|
||||||
{
|
{
|
||||||
switch ($data['article']['product_type'] ?? false) {
|
switch ($data['article']['product_type'] ?? false) {
|
||||||
@@ -424,163 +324,11 @@ class Articles
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getByCategory($category_id)
|
|
||||||
{
|
|
||||||
return Article::byCategory($category_id)->with(['prices', 'product', 'image'])->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCategoriesByArticle($article)
|
|
||||||
{
|
|
||||||
return $article->categories->pluck('id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getProductTypeByCategory($category_id)
|
|
||||||
{
|
|
||||||
$models = self::getProductTypesModelsByCategory($category_id);
|
|
||||||
|
|
||||||
return ($models[0] ?? false) === Merchandise::class ? 'merchandise' : 'botanic';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getProductTypesModelsByCategory($category_id)
|
|
||||||
{
|
|
||||||
return Article::byCategory($category_id)->select('product_type')->distinct()->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function countProductTypesByCategory($category_id)
|
|
||||||
{
|
|
||||||
return Article::byCategory($category_id)->select('product_type')->distinct()->count();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getCategoriesNameByArticle($article)
|
|
||||||
{
|
|
||||||
return $article->categories->pluck('name', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTagsByArticle($article)
|
|
||||||
{
|
|
||||||
return $article->tags->pluck('id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTagsNameByArticle($article)
|
|
||||||
{
|
|
||||||
return $article->tags->pluck('name', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getTagsSlugByArticle($article)
|
|
||||||
{
|
|
||||||
return $article->tags->pluck('slug', 'id')->toArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getFullTagsSlugByArticle($article)
|
|
||||||
{
|
|
||||||
$data = [];
|
|
||||||
|
|
||||||
switch ($article->product_type) {
|
|
||||||
case 'App\Models\Botanic\Variety':
|
|
||||||
$data += $article->product->tags->toArray();
|
|
||||||
if ($article->product->specie ?? false) {
|
|
||||||
$data += $article->product->specie->tags->toArray();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'App\Models\Botanic\Specie':
|
|
||||||
$data += $article->product->tags->toArray();
|
|
||||||
break;
|
|
||||||
case 'App\Models\Shop\Merchandise':
|
|
||||||
$data += $article->product->tags->toArray();
|
|
||||||
$data += $article->product->producer->tags->toArray();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
$data += $article->tags->toArray();
|
|
||||||
|
|
||||||
foreach ($data as $tag) {
|
|
||||||
if (! isset($tags[$tag['group']][$tag['name']])) {
|
|
||||||
$tags[$tag['group']][] = $tag['name'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tags ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getPricesByArticle($article)
|
public static function getPricesByArticle($article)
|
||||||
{
|
{
|
||||||
return Prices::getByArticle($article->id);
|
return Prices::getByArticle($article->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFullImagesByArticleId($id)
|
|
||||||
{
|
|
||||||
$article = self::get($id);
|
|
||||||
|
|
||||||
return $article ? self::getFullImagesByArticle($article) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function countFullImagesByArticleId($id)
|
|
||||||
{
|
|
||||||
$article = self::get($id);
|
|
||||||
|
|
||||||
return $article ? self::countFullImagesByArticle($article) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function countFullImagesByArticle($article)
|
|
||||||
{
|
|
||||||
return count(self::getFullImagesByArticle($article));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getFullImagesByArticle($article)
|
|
||||||
{
|
|
||||||
$images = count($article->images) ? $article->images : collect([]);
|
|
||||||
switch ($article->product_type) {
|
|
||||||
case 'App\Models\Botanic\Variety':
|
|
||||||
$variety = $article->product ?? false;
|
|
||||||
$specie = $variety->specie ?? false;
|
|
||||||
if ($variety) {
|
|
||||||
$images = count($variety->images ?? []) ? $images->merge($variety->images) : $images;
|
|
||||||
}
|
|
||||||
if ($specie) {
|
|
||||||
$images = count($specie->images ?? []) ? $images->merge($specie->images) : $images;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'App\Models\Botanic\Specie':
|
|
||||||
$specie = $article->product ?? false;
|
|
||||||
$images = count($specie->images ?? []) ? $specie->images : $images;
|
|
||||||
break;
|
|
||||||
case 'App\Models\Shop\Merchandise':
|
|
||||||
$merchandise = $article->product ?? false;
|
|
||||||
$images = count($merchandise->images ?? []) ? $merchandise->images : $images;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
return $images;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getFullImageById($id)
|
|
||||||
{
|
|
||||||
return self::getFullImageByArticle(self::get($id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getFullImageByArticle($article)
|
|
||||||
{
|
|
||||||
$image = $article->image;
|
|
||||||
if ($image) {
|
|
||||||
return $image;
|
|
||||||
}
|
|
||||||
switch ($article->product_type) {
|
|
||||||
case 'App\Models\Botanic\Variety':
|
|
||||||
$image = $article->product->image ?? ($article->product->specie->image ?? false);
|
|
||||||
break;
|
|
||||||
case 'App\Models\Botanic\Specie':
|
|
||||||
$image = $article->product->image ?? false;
|
|
||||||
break;
|
|
||||||
case 'App\Models\Shop\Merchandise':
|
|
||||||
$image = $article->product->image ?? false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
return $image;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function storeFull($data)
|
public static function storeFull($data)
|
||||||
{
|
{
|
||||||
$images = $data['images'] ?? false;
|
$images = $data['images'] ?? false;
|
||||||
@@ -594,31 +342,12 @@ class Articles
|
|||||||
|
|
||||||
$article = self::store($data);
|
$article = self::store($data);
|
||||||
self::storeImages($article, $images);
|
self::storeImages($article, $images);
|
||||||
self::storeCategories($article, $categories);
|
ArticleCategories::storeCategories($article, $categories);
|
||||||
self::storeTags($article, $tags);
|
ArticleTags::storeTags($article, $tags);
|
||||||
|
|
||||||
return $article->id;
|
return $article->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storeCategories($article, $categories)
|
|
||||||
{
|
|
||||||
if (! $categories) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$categories = collect($categories)->transform(
|
|
||||||
function ($item, $key) {
|
|
||||||
return (int) $item;
|
|
||||||
}
|
|
||||||
)->toArray();
|
|
||||||
|
|
||||||
return $article->syncCategories($categories, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function storeTags($article, $tags)
|
|
||||||
{
|
|
||||||
return Tag::storeTags($article, $tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function toggleVisible($id, $visible)
|
public static function toggleVisible($id, $visible)
|
||||||
{
|
{
|
||||||
return self::update(['visible' => $visible], $id);
|
return self::update(['visible' => $visible], $id);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Baskets
|
|||||||
'quantity' => (int) $item->quantity,
|
'quantity' => (int) $item->quantity,
|
||||||
'price' => $item->price,
|
'price' => $item->price,
|
||||||
'variation' => $offer->variation->name,
|
'variation' => $offer->variation->name,
|
||||||
'image' => Articles::getPreviewSrc(Articles::getFullImageByArticle($offer->article)),
|
'image' => Articles::getPreviewSrc(ArticleImages::getFullImageByArticle($offer->article)),
|
||||||
'latin' => $offer->article->product->specie->latin ?? false,
|
'latin' => $offer->article->product->specie->latin ?? false,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,66 +2,41 @@
|
|||||||
|
|
||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
use App\Models\Shop\Invoice;
|
use Carbon\Carbon;
|
||||||
use LaravelDaily\Invoices\Invoice;
|
use LaravelDaily\Invoices\Invoice;
|
||||||
use LaravelDaily\Invoices\Classes\Party;
|
use LaravelDaily\Invoices\Classes\Party;
|
||||||
use LaravelDaily\Invoices\Classes\InvoiceItem;
|
use LaravelDaily\Invoices\Classes\InvoiceItem;
|
||||||
|
|
||||||
class InvoicePDF
|
class InvoicePDF
|
||||||
{
|
{
|
||||||
|
public static function getByUUID($uuid)
|
||||||
|
{
|
||||||
|
return self::get(Invoices::getIdByUUID($uuid));
|
||||||
|
}
|
||||||
|
|
||||||
public static function get($id)
|
public static function get($id)
|
||||||
{
|
{
|
||||||
$invoice = Invoices::getFull($id);
|
$invoice = Invoices::getFull($id);
|
||||||
|
|
||||||
$client = new Party([
|
|
||||||
'name' => 'Roosevelt Lloyd',
|
|
||||||
'phone' => '(520) 318-9486',
|
|
||||||
'custom_fields' => [
|
|
||||||
'note' => 'IDDQD',
|
|
||||||
'business id' => '365#GG',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
|
|
||||||
$customer = new Party([
|
$customer = new Party([
|
||||||
'name' => 'Ashley Medina',
|
'name' => $invoice->customer->name,
|
||||||
'address' => 'The Green Street 12',
|
'address' => self::makeAddress($invoice->address),
|
||||||
'code' => '#22663214',
|
|
||||||
'custom_fields' => [
|
'custom_fields' => [
|
||||||
'order number' => '> 654321 <',
|
'order number' => $invoice->order->ref,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$items = self::makeItems($order->details);
|
$items = self::makeItems($invoice->order->detail);
|
||||||
|
|
||||||
$notes = [
|
$invoice = Invoice::make(__('invoices::invoice.invoice') . ' ' .$invoice->ref)
|
||||||
'your multiline',
|
->status(Invoices::getStatus($invoice->status))
|
||||||
'additional notes',
|
|
||||||
'in regards of delivery or something else',
|
|
||||||
];
|
|
||||||
$notes = implode("<br>", $notes);
|
|
||||||
|
|
||||||
$invoice = Invoice::make('receipt')
|
|
||||||
->series('BIG')
|
|
||||||
// ability to include translated invoice status
|
|
||||||
// in case it was paid
|
|
||||||
->status(__('invoices::invoice.paid'))
|
|
||||||
->sequence(667)
|
|
||||||
->serialNumberFormat('{SEQUENCE}/{SERIES}')
|
|
||||||
->seller($client)
|
|
||||||
->buyer($customer)
|
->buyer($customer)
|
||||||
->date(now()->subWeeks(3))
|
->shipping($invoice->shipping)
|
||||||
->dateFormat('m/d/Y')
|
->date(Carbon::parse($invoice->date_invoice))
|
||||||
->payUntilDays(14)
|
->payUntilDays(14)
|
||||||
->currencySymbol('$')
|
->filename('invoice-' . $invoice->ref . '-' . $invoice->uuid)
|
||||||
->currencyCode('USD')
|
|
||||||
->currencyFormat('{SYMBOL}{VALUE}')
|
|
||||||
->currencyThousandsSeparator('.')
|
|
||||||
->currencyDecimalPoint(',')
|
|
||||||
->filename($client->name . ' ' . $customer->name)
|
|
||||||
->addItems($items)
|
->addItems($items)
|
||||||
->notes($notes)
|
->notes($invoice->comment ?? '')
|
||||||
->logo(public_path('vendor/invoices/sample-logo.png'))
|
->logo(public_path('img/logo.png'))
|
||||||
// You can additionally save generated invoice to configured disk
|
|
||||||
->save('public');
|
->save('public');
|
||||||
|
|
||||||
$link = $invoice->url();
|
$link = $invoice->url();
|
||||||
@@ -71,12 +46,20 @@ class InvoicePDF
|
|||||||
return $invoice->stream();
|
return $invoice->stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function makeAddress($address)
|
||||||
|
{
|
||||||
|
return $address->address . '<br>' . $address->zipcode . ' ' . $address->city;
|
||||||
|
}
|
||||||
|
|
||||||
public static function makeItems($details)
|
public static function makeItems($details)
|
||||||
{
|
{
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
||||||
foreach ($details as $detail) {
|
foreach ($details as $detail) {
|
||||||
$items[] = InvoiceItem::make($detail->name)->pricePerUnit($detail->price)->quantity($detail->quantity);
|
$items[] = InvoiceItem::make($detail->name)
|
||||||
|
->pricePerUnit($detail->price)
|
||||||
|
->taxByPercent($detail->vat)
|
||||||
|
->quantity($detail->quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items;
|
return $items;
|
||||||
|
|||||||
25
app/Repositories/Shop/OfferStocks.php
Normal file
25
app/Repositories/Shop/OfferStocks.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Offer;
|
||||||
|
use App\Traits\Model\Basic;
|
||||||
|
|
||||||
|
class OfferStocks
|
||||||
|
{
|
||||||
|
public static function decreaseStock($item)
|
||||||
|
{
|
||||||
|
$offer = Offers::get($item['offer_id']);
|
||||||
|
$offer->stock_current = $offer->stock_current - $item['quantity'];
|
||||||
|
if ($offer->stock_current <= 0) {
|
||||||
|
$offer->stock_current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $offer->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getStockCurrent($id)
|
||||||
|
{
|
||||||
|
return Offers::getField($id, 'stock_current');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,22 @@ class Offers
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function decreaseStock($item)
|
||||||
|
{
|
||||||
|
$offer = self::get($item['offer_id']);
|
||||||
|
$offer->stock_current = $offer->stock_current - $item['quantity'];
|
||||||
|
if ($offer->stock_current <= 0) {
|
||||||
|
$offer->stock_current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $offer->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getStockCurrent($id)
|
||||||
|
{
|
||||||
|
return self::getField($id, 'stock_current');
|
||||||
|
}
|
||||||
|
|
||||||
public static function getWeight($id, $quantity = 1)
|
public static function getWeight($id, $quantity = 1)
|
||||||
{
|
{
|
||||||
$offer = self::get($id);
|
$offer = self::get($id);
|
||||||
@@ -58,7 +74,7 @@ class Offers
|
|||||||
'tariff.price_lists.price_list_values',
|
'tariff.price_lists.price_list_values',
|
||||||
'variation',
|
'variation',
|
||||||
])->find($id);
|
])->find($id);
|
||||||
$images = Articles::getFullImagesByArticle($offer->article);
|
$images = ArticleImages::getFullImagesByArticle($offer->article);
|
||||||
$offer->article->image = Articles::getPreviewSrc($images[0] ?? false);
|
$offer->article->image = Articles::getPreviewSrc($images[0] ?? false);
|
||||||
|
|
||||||
return $offer;
|
return $offer;
|
||||||
@@ -111,7 +127,7 @@ class Offers
|
|||||||
|
|
||||||
public static function getThumbSrc(Offer $offer)
|
public static function getThumbSrc(Offer $offer)
|
||||||
{
|
{
|
||||||
$image = $offer->article ? Articles::getFullImageByArticle($offer->article) : false;
|
$image = $offer->article ? ArticleImages::getFullImageByArticle($offer->article) : false;
|
||||||
|
|
||||||
return $image ? Articles::getThumbSrc($image) : false;
|
return $image ? Articles::getThumbSrc($image) : false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ class OrderDetails
|
|||||||
foreach ($data as $item) {
|
foreach ($data as $item) {
|
||||||
$item['order_id'] = $order_id;
|
$item['order_id'] = $order_id;
|
||||||
$detail = self::store($item);
|
$detail = self::store($item);
|
||||||
|
if ($detail) {
|
||||||
|
OfferStocks::decreaseStock($item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ return [
|
|||||||
/*
|
/*
|
||||||
* Carbon date format
|
* Carbon date format
|
||||||
*/
|
*/
|
||||||
'format' => 'Y-m-d',
|
'format' => 'd/m/Y',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Due date for payment since invoice's date.
|
* Due date for payment since invoice's date.
|
||||||
*/
|
*/
|
||||||
'pay_until_days' => 7,
|
'pay_until_days' => 30,
|
||||||
],
|
],
|
||||||
|
|
||||||
'serial_number' => [
|
'serial_number' => [
|
||||||
@@ -87,7 +87,7 @@ return [
|
|||||||
* Default attributes for Seller::class
|
* Default attributes for Seller::class
|
||||||
*/
|
*/
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'name' => 'Towne, Smith and Ebert',
|
'name' => 'Jardin\'Envie',
|
||||||
'address' => '89982 Pfeffer Falls Damianstad, CO 66972-8160',
|
'address' => '89982 Pfeffer Falls Damianstad, CO 66972-8160',
|
||||||
'code' => '41-1985581',
|
'code' => '41-1985581',
|
||||||
'vat' => '123456789',
|
'vat' => '123456789',
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-4 col-xs-12">
|
<div class="col-sm-12 col-lg-4">
|
||||||
<div style="max-width: 360px;">
|
<div style="max-width: 100%;">
|
||||||
@include('components.multi-images', ['image' => $article['image'], 'images' => $article['images']])
|
@include('components.multi-images', [
|
||||||
|
'image' => $article['image'],
|
||||||
|
'images' => $article['images'],
|
||||||
|
])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-5 col-xs-12 text-justify">
|
<div class="col-lg-5 col-xs-12 text-justify">
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="@if ($basket['count']) col-8 @else col-12 @endif">
|
<div class="@if ($basket['count']) col-sm-12 col-lg-8 @else col-12 @endif">
|
||||||
@if (App\Repositories\Shop\Customers::isNotConnected())
|
@if (App\Repositories\Shop\Customers::isNotConnected())
|
||||||
<p>
|
<p>
|
||||||
<a href="#" id="customer" class="pr-5">Déja client ?</a>
|
<a href="#" id="customer" class="pr-5">Déja client ?</a>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
@if ($basket['count'])
|
@if ($basket['count'])
|
||||||
<div class="col-4">
|
<div class="col-sm-12 col-lg-4">
|
||||||
<x-card class='shadow'>
|
<x-card class='shadow'>
|
||||||
<div id="basketTotal">
|
<div id="basketTotal">
|
||||||
@include('Shop.Baskets.partials.basketTotal', ['basket' => $basket])
|
@include('Shop.Baskets.partials.basketTotal', ['basket' => $basket])
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
<div class="row bg-light">
|
<div class="row bg-light">
|
||||||
|
|
||||||
<div class="col-sm-6 col-lg-5">
|
<div class="col-sm-12 col-lg-5">
|
||||||
<a href="/"><img src="/img/logo.png" height="52"></a>
|
<a href="/"><img src="/img/logo.png" height="52" alt="Jardin'Envie"></a>
|
||||||
<span class="green ml-3">Variétés Paysannes de la Semence à l'Assiette</span>
|
<span class="green ml-3">Variétés Paysannes de la Semence à l'Assiette</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-6 col-lg-3 pt-2">
|
<div class="col-sm-12 col-lg-3 pt-2">
|
||||||
@include("Shop.layout.partials.search")
|
@include('Shop.layout.partials.search')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-12 col-lg-4 pt-2 text-right">
|
<div class="col-sm-12 col-lg-4 pt-2 text-right">
|
||||||
@include('Shop.layout.partials.header-catalog')
|
@include('Shop.layout.partials.header-catalog')
|
||||||
@include("Shop.layout.partials.header-profile")
|
@include('Shop.layout.partials.header-profile')
|
||||||
@include("Shop.layout.partials.header-basket")
|
@include('Shop.layout.partials.header-basket')
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user