Fixes for deliveries vs sale_channels
This commit is contained in:
@@ -20,7 +20,7 @@ class ArticleNaturesDataTable extends DataTable
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('name')->title('Nom'),
|
Column::make('name')->title('Nom'),
|
||||||
Column::make('articles_count')->title('Nb articles')->addClass('text-right')->searchable(false),
|
Column::make('articles_count')->title('#Art')->addClass('text-right')->searchable(false)->width(60),
|
||||||
$this->makeColumnButtons(),
|
$this->makeColumnButtons(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class ArticlesDataTable extends DataTable
|
|||||||
->editColumn('tags2', function (Article $article) {
|
->editColumn('tags2', function (Article $article) {
|
||||||
$html = '';
|
$html = '';
|
||||||
foreach ($article->tags as $tag) {
|
foreach ($article->tags as $tag) {
|
||||||
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
|
$html .= '<span class="btn btn-xs btn-success pb-2">' . $tag->slug . '</span> ';
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,15 +12,42 @@ class CategoriesDataTable extends DataTable
|
|||||||
|
|
||||||
public function query(Category $model)
|
public function query(Category $model)
|
||||||
{
|
{
|
||||||
$model = $model::withCount('articles');
|
$model = $model::with(['tags.articles'])->withCount(['articles', 'tags']);
|
||||||
return $this->buildQuery($model);
|
return $this->buildQuery($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function modifier($datatables)
|
||||||
|
{
|
||||||
|
$datatables
|
||||||
|
->editColumn('visible', function (Category $category) {
|
||||||
|
return view("components.form.toggle", [
|
||||||
|
'value' => $category->visible,
|
||||||
|
'on' => __('visible'),
|
||||||
|
'off' => __('invisible'),
|
||||||
|
'meta' => 'data-id=' . $category->id,
|
||||||
|
'size' => 'sm',
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
->editColumn('articles_tagged_count', function (Category $category) {
|
||||||
|
$count = 0;
|
||||||
|
foreach ($category->tags as $tag) {
|
||||||
|
$nb = collect($tag->articles)->count();
|
||||||
|
$count += $nb;
|
||||||
|
}
|
||||||
|
return $count;
|
||||||
|
})
|
||||||
|
->rawColumns(['visible', 'action']);
|
||||||
|
return parent::modifier($datatables);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Column::make('visible')->title('visible')->width(60)->title(''),
|
||||||
Column::make('name')->title('Nom'),
|
Column::make('name')->title('Nom'),
|
||||||
Column::make('articles_count')->title('Nb Articles')->class('text-right')->searchable(false),
|
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false)->width(60),
|
||||||
|
Column::make('tags_count')->title('#Tags')->class('text-right')->searchable(false)->width(60),
|
||||||
|
Column::make('articles_tagged_count')->title('#ArtTag')->class('text-right')->searchable(false)->width(60),
|
||||||
$this->makeColumnButtons(),
|
$this->makeColumnButtons(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
28
app/Datatables/Shop/CustomerDeliveriesDataTable.php
Normal file
28
app/Datatables/Shop/CustomerDeliveriesDataTable.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Datatables\Shop;
|
||||||
|
|
||||||
|
use Yajra\DataTables\Html\Column;
|
||||||
|
use App\Datatables\ParentDataTable as DataTable;
|
||||||
|
use App\Models\Shop\Customer;
|
||||||
|
|
||||||
|
class CustomerDeliveriesDataTable extends DataTable
|
||||||
|
{
|
||||||
|
public $model_name = 'customer_deliveries';
|
||||||
|
|
||||||
|
public function query(Customer $model)
|
||||||
|
{
|
||||||
|
return $this->buildQuery($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getColumns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Column::make('name')->title('Nom'),
|
||||||
|
Column::make('address')->title('Adresse'),
|
||||||
|
Column::make('zipcode')->title('Code postal'),
|
||||||
|
Column::make('city')->title('Ville'),
|
||||||
|
$this->makeColumnButtons(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,10 +18,7 @@ class CustomersDataTable extends DataTable
|
|||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('name')->title('Nom'),
|
Column::make('last_name')->title('Nom'),
|
||||||
Column::make('address')->title('Adresse'),
|
|
||||||
Column::make('zipcode')->title('Code postal'),
|
|
||||||
Column::make('city')->title('Ville'),
|
|
||||||
$this->makeColumnButtons(),
|
$this->makeColumnButtons(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ class OffersDataTable extends DataTable
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('status_id')->title('')->width(40),
|
Column::make('status_id')->title('')->width(40),
|
||||||
Column::make('article.name')->title('Article'),
|
|
||||||
Column::make('article.article_nature.name')->title('Nature'),
|
Column::make('article.article_nature.name')->title('Nature'),
|
||||||
|
Column::make('article.name')->title('Article'),
|
||||||
Column::make('variation.name')->title('Déclinaison'),
|
Column::make('variation.name')->title('Déclinaison'),
|
||||||
Column::make('tariff.name')->title('Tarif'),
|
Column::make('tariff.name')->title('Tarif'),
|
||||||
Column::make('stock_current')->title('Appro im'),
|
Column::make('stock_current')->title('Appro im'),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class PriceListsDataTable extends DataTable
|
|||||||
|
|
||||||
public function query(PriceList $model)
|
public function query(PriceList $model)
|
||||||
{
|
{
|
||||||
$model = $model->with(['sale_channel','price_list_values']);
|
$model = $model->with(['sale_channel', 'price_list_values']);
|
||||||
$model = self::filterByTariff($model);
|
$model = self::filterByTariff($model);
|
||||||
return $this->buildQuery($model);
|
return $this->buildQuery($model);
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ class PriceListsDataTable extends DataTable
|
|||||||
->editColumn('tariff_id', function (PriceList $price_list) {
|
->editColumn('tariff_id', function (PriceList $price_list) {
|
||||||
return view('Admin.Shop.PriceLists.partials.table-prices', ['prices' => $price_list['price_list_values']]);
|
return view('Admin.Shop.PriceLists.partials.table-prices', ['prices' => $price_list['price_list_values']]);
|
||||||
})
|
})
|
||||||
->rawColumns(['tariff_id','action']);
|
->rawColumns(['tariff_id', 'action']);
|
||||||
return parent::modifier($datatables);
|
return parent::modifier($datatables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class TagGroupsDataTable extends DataTable
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('name'),
|
Column::make('name'),
|
||||||
Column::make('tags_count')->title('Nb de tags')->searchable(false)->addClass('text-right'),
|
Column::make('tags_count')->title('#Tags')->searchable(false)->addClass('text-right')->width(60),
|
||||||
$this->makeColumnButtons(),
|
$this->makeColumnButtons(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ class TagsDataTable extends DataTable
|
|||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('group.name')->title('Groupe'),
|
Column::make('group.name')->title('Groupe')->width(200),
|
||||||
Column::make('name')->title('Nom'),
|
Column::make('name')->title('Nom'),
|
||||||
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false),
|
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false)->width(60),
|
||||||
Column::make('species_count')->title('#Esp')->class('text-right')->searchable(false),
|
Column::make('species_count')->title('#Esp')->class('text-right')->searchable(false)->width(60),
|
||||||
Column::make('varieties_count')->title('#Var')->class('text-right')->searchable(false),
|
Column::make('varieties_count')->title('#Var')->class('text-right')->searchable(false)->width(60),
|
||||||
Column::make('shelves_count')->title('#Ray')->class('text-right')->searchable(false),
|
Column::make('shelves_count')->title('#Ray')->class('text-right')->searchable(false)->width(60),
|
||||||
$this->makeColumnButtons(),
|
$this->makeColumnButtons(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,9 @@ class TariffsDataTable extends DataTable
|
|||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
})
|
})
|
||||||
->rawColumns(['sale_channels2', 'action'])
|
->rawColumns(['sale_channels2', 'action']);
|
||||||
;
|
|
||||||
return parent::modifier($datatables);
|
return parent::modifier($datatables);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class VariationsDataTable extends DataTable
|
|||||||
|
|
||||||
public function query(Variation $model)
|
public function query(Variation $model)
|
||||||
{
|
{
|
||||||
$model = $model->with(['package','unity'])->withCount('offers');
|
$model = $model->with(['package', 'unity'])->withCount('offers');
|
||||||
return $this->buildQuery($model);
|
return $this->buildQuery($model);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,10 +22,9 @@ class VariationsDataTable extends DataTable
|
|||||||
->editColumn('unity_value', function (Variation $variation) {
|
->editColumn('unity_value', function (Variation $variation) {
|
||||||
return $variation->unity ? $variation->unity->value : '';
|
return $variation->unity ? $variation->unity->value : '';
|
||||||
})
|
})
|
||||||
->rawColumns(['description','action'])
|
->rawColumns(['description', 'action']);
|
||||||
;
|
|
||||||
return parent::modifier($datatables);
|
return parent::modifier($datatables);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,10 +17,11 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [
|
||||||
$data['category_id'] = 0;
|
'category_id' => 0,
|
||||||
$data['categories'] = Categories::getOptions();
|
'categories' => Categories::getOptions(),
|
||||||
$data['tags_list'] = TagGroups::getTreeTags();
|
'tags_list' => TagGroups::getTreeTags(),
|
||||||
|
];
|
||||||
return view('Admin.Shop.Categories.create', $data);
|
return view('Admin.Shop.Categories.create', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,17 +39,12 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data['category'] = Categories::get($id)->toArray();
|
$data['category'] = Categories::getFull($id);
|
||||||
$data['categories'] = Categories::getOptions();
|
$data['categories'] = Categories::getOptions();
|
||||||
$data['tags_list'] = TagGroups::getTreeTags();
|
$data['tags_list'] = TagGroups::getTreeTags();
|
||||||
return view('Admin.Shop.Categories.edit', $data);
|
return view('Admin.Shop.Categories.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update(Request $request)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
return Categories::destroy($id);
|
return Categories::destroy($id);
|
||||||
@@ -75,4 +71,11 @@ class CategoryController extends Controller
|
|||||||
$type = $request->input('type');
|
$type = $request->input('type');
|
||||||
return Categories::moveTree($node_id, $target_id, $type);
|
return Categories::moveTree($node_id, $target_id, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toggleVisible(Request $request)
|
||||||
|
{
|
||||||
|
$data = Categories::toggle_visible($request->input('id'), ($request->input('visible') == 'true') ? 1 : 0);
|
||||||
|
return response()->json(['error' => 0]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin\Shop;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use App\Repositories\Shop\Customers;
|
use App\Repositories\Shop\Customers;
|
||||||
use App\Repositories\Shop\SaleChannels;
|
use App\Repositories\Shop\Deliveries;
|
||||||
use App\Datatables\Shop\CustomersDataTable;
|
use App\Datatables\Shop\CustomersDataTable;
|
||||||
|
|
||||||
class CustomerController extends Controller
|
class CustomerController extends Controller
|
||||||
@@ -18,7 +18,7 @@ class CustomerController extends Controller
|
|||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$data['sale_channels'] = SaleChannels::getOptions();
|
$data['deliveries'] = Deliveries::getOptions();
|
||||||
return view('Admin.Shop.Customers.create', $data);
|
return view('Admin.Shop.Customers.create', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ class CustomerController extends Controller
|
|||||||
public function edit($id)
|
public function edit($id)
|
||||||
{
|
{
|
||||||
$data['customer'] = Customers::get($id)->toArray();
|
$data['customer'] = Customers::get($id)->toArray();
|
||||||
$data['sale_channels'] = SaleChannels::getOptions();
|
$data['deliveries'] = Deliveries::getOptions();
|
||||||
return view('Admin.Shop.Customers.edit', $data);
|
return view('Admin.Shop.Customers.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models\Shop;
|
namespace App\Models\Shop;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
@@ -10,12 +11,12 @@ use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
|||||||
|
|
||||||
// use Rinvex\Categories\Traits\Categorizable;
|
// use Rinvex\Categories\Traits\Categorizable;
|
||||||
use Rinvex\Tags\Traits\Taggable;
|
use Rinvex\Tags\Traits\Taggable;
|
||||||
// use Conner\Tagging\Taggable;
|
|
||||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||||
|
use Wildside\Userstamps\Userstamps;
|
||||||
|
|
||||||
class Category extends Model
|
class Category extends Model
|
||||||
{
|
{
|
||||||
use InteractsWithMedia, Taggable;
|
use InteractsWithMedia, SoftDeletes, Taggable, Userstamps;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
protected $table = 'shop_categories';
|
protected $table = 'shop_categories';
|
||||||
@@ -25,6 +26,11 @@ class Category extends Model
|
|||||||
return $this->morphedByMany(Article::class, 'categorizable');
|
return $this->morphedByMany(Article::class, 'categorizable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ArticlesTagged()
|
||||||
|
{
|
||||||
|
return $this->tags->articles;
|
||||||
|
}
|
||||||
|
|
||||||
public function Shelves()
|
public function Shelves()
|
||||||
{
|
{
|
||||||
return $this->morphedByMany(Category::class, 'categorizable');
|
return $this->morphedByMany(Category::class, 'categorizable');
|
||||||
|
|||||||
@@ -19,9 +19,14 @@ class Customer extends Model
|
|||||||
return $this->hasMany(Invoice::class);
|
return $this->hasMany(Invoice::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Delivery()
|
public function customer_deliveries()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Delivery::class);
|
return $this->hasMany(CustomerDelivery::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deliveries()
|
||||||
|
{
|
||||||
|
return $this->hasManyThrough(Delivery::class, CustomerDelivery::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Orders()
|
public function Orders()
|
||||||
|
|||||||
31
app/Models/Shop/CustomerDelivery.php
Normal file
31
app/Models/Shop/CustomerDelivery.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Shop;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class CustomerDelivery extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
protected $table = 'shop_customer_deliveries';
|
||||||
|
|
||||||
|
public function customer()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Customer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delivery()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Delivery::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeByCustomer($query, $customer_id)
|
||||||
|
{
|
||||||
|
return $query->where($this->table . '.customer_id', $customer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeByDelivery($query, $customer_id)
|
||||||
|
{
|
||||||
|
return $query->where($this->table . '.delivery_id', $customer_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,10 +5,12 @@ namespace App\Models\Shop;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
use Spatie\Translatable\HasTranslations;
|
use Spatie\Translatable\HasTranslations;
|
||||||
|
use Rinvex\Tags\Models\Tag as parentTag;
|
||||||
|
|
||||||
use App\Models\Botanic\Specie;
|
use App\Models\Botanic\Specie;
|
||||||
use App\Models\Botanic\Variety;
|
use App\Models\Botanic\Variety;
|
||||||
|
|
||||||
class Tag extends Model
|
class Tag extends parentTag
|
||||||
{
|
{
|
||||||
use HasTranslations;
|
use HasTranslations;
|
||||||
|
|
||||||
@@ -27,6 +29,11 @@ class Tag extends Model
|
|||||||
return $this->morphedByMany(Article::class, 'taggable');
|
return $this->morphedByMany(Article::class, 'taggable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function categories()
|
||||||
|
{
|
||||||
|
return $this->morphedByMany(Category::class, 'taggable');
|
||||||
|
}
|
||||||
|
|
||||||
public function group()
|
public function group()
|
||||||
{
|
{
|
||||||
return $this->hasOne(TagGroup::class, 'id', 'tag_group_id');
|
return $this->hasOne(TagGroup::class, 'id', 'tag_group_id');
|
||||||
|
|||||||
@@ -12,15 +12,11 @@ class Tag
|
|||||||
|
|
||||||
public static function storeTags($model, $tags)
|
public static function storeTags($model, $tags)
|
||||||
{
|
{
|
||||||
if ($tags) {
|
$tags = $tags ? collect($tags)->transform(
|
||||||
$tags = collect($tags)->transform(
|
function ($item, $key) {
|
||||||
function ($item, $key) {
|
return (int) $item;
|
||||||
return (int) $item;
|
}
|
||||||
}
|
)->toArray() : false;
|
||||||
)->toArray();
|
return $tags ? $model->syncTags($tags, true) : false;
|
||||||
return $model->syncTags($tags, true);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,8 +173,11 @@ class Articles
|
|||||||
case 'App\Models\Botanic\Variety':
|
case 'App\Models\Botanic\Variety':
|
||||||
$data['products'] = Species::getOptions();
|
$data['products'] = Species::getOptions();
|
||||||
break;
|
break;
|
||||||
|
case 'App\Models\Shop\Merchandise':
|
||||||
|
$data['products'] = Merchandises::getOptions();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$data['products'] = Species::getOptions();
|
$data['products'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['categories_options'] = Categories::getOptions();
|
$data['categories_options'] = Categories::getOptions();
|
||||||
@@ -184,6 +187,8 @@ class Articles
|
|||||||
$data['models_options'] = [
|
$data['models_options'] = [
|
||||||
'App\Models\Botanic\Specie' => 'Espèces',
|
'App\Models\Botanic\Specie' => 'Espèces',
|
||||||
'App\Models\Botanic\Variety' => 'Variétés',
|
'App\Models\Botanic\Variety' => 'Variétés',
|
||||||
|
'App\Models\Shop\Merchandise' => 'Marchandise',
|
||||||
|
'App\Models\Shop\Merchandise' => 'Autres',
|
||||||
];
|
];
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
use App\Models\Shop\Category;
|
use App\Models\Shop\Category;
|
||||||
|
use App\Repositories\Core\Tag;
|
||||||
|
|
||||||
class Categories
|
class Categories
|
||||||
{
|
{
|
||||||
@@ -13,7 +14,25 @@ class Categories
|
|||||||
|
|
||||||
public static function get($id)
|
public static function get($id)
|
||||||
{
|
{
|
||||||
return Category::with('CategoryTree')->find($id);
|
return Category::findOrFail($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getFull($id)
|
||||||
|
{
|
||||||
|
$category = Category::with('CategoryTree')->find($id);
|
||||||
|
$data = $category->toArray();
|
||||||
|
$data['tags'] = self::getTagsByCategory($category);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTagsByCategory($category)
|
||||||
|
{
|
||||||
|
return $category->tags->pluck('id')->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTagsNameByCategory($category)
|
||||||
|
{
|
||||||
|
return $category->tags->pluck('name', 'id')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getByCategory($category_id)
|
public static function getByCategory($category_id)
|
||||||
@@ -28,7 +47,7 @@ class Categories
|
|||||||
|
|
||||||
public static function getOptions()
|
public static function getOptions()
|
||||||
{
|
{
|
||||||
return Category::get()->pluck('name', 'category_id')->toArray();
|
return Category::orderBy('name', 'asc')->pluck('name', 'category_id')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storeFull($data)
|
public static function storeFull($data)
|
||||||
@@ -53,17 +72,7 @@ class Categories
|
|||||||
|
|
||||||
public static function storeTags($category, $tags)
|
public static function storeTags($category, $tags)
|
||||||
{
|
{
|
||||||
if ($tags) {
|
return Tag::storeTags($category, $tags);
|
||||||
$tags = collect($tags)->transform(
|
|
||||||
function ($item, $key) {
|
|
||||||
return (int) $item;
|
|
||||||
}
|
|
||||||
)->toArray();
|
|
||||||
|
|
||||||
return $category->syncTags($tags, true);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storeImages($category, $files)
|
public static function storeImages($category, $files)
|
||||||
@@ -131,6 +140,11 @@ class Categories
|
|||||||
return Category::destroy($id);
|
return Category::destroy($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function toggle_visible($id, $visible)
|
||||||
|
{
|
||||||
|
return self::update(['visible' => $visible], $id);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getRoot()
|
public static function getRoot()
|
||||||
{
|
{
|
||||||
return app('rinvex.categories.category')->find(1);
|
return app('rinvex.categories.category')->find(1);
|
||||||
|
|||||||
@@ -53,3 +53,7 @@ ul .jqtree_common {
|
|||||||
.yellow {
|
.yellow {
|
||||||
color: #F2B90F!important;
|
color: #F2B90F!important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
"olssonm/laravel-backup-shield": "^3.1",
|
"olssonm/laravel-backup-shield": "^3.1",
|
||||||
"orangehill/iseed": "^3.0",
|
"orangehill/iseed": "^3.0",
|
||||||
"php-console/php-console": "^3.1",
|
"php-console/php-console": "^3.1",
|
||||||
|
"proengsoft/laravel-jsvalidation": "^4.5",
|
||||||
"qoraiche/laravel-mail-editor": "^3.2",
|
"qoraiche/laravel-mail-editor": "^3.2",
|
||||||
"respect/validation": "^2.2",
|
"respect/validation": "^2.2",
|
||||||
"rinvex/laravel-categories": "^5.0",
|
"rinvex/laravel-categories": "^5.0",
|
||||||
@@ -97,6 +98,7 @@
|
|||||||
"fakerphp/faker": "^1.13",
|
"fakerphp/faker": "^1.13",
|
||||||
"fossbarrow/laravel-phpcs": "dev-main",
|
"fossbarrow/laravel-phpcs": "dev-main",
|
||||||
"imanghafoori/laravel-microscope": "^1.0",
|
"imanghafoori/laravel-microscope": "^1.0",
|
||||||
|
"kevincobain2000/laravel-erd": "^1.3",
|
||||||
"mockery/mockery": "^1.4.2",
|
"mockery/mockery": "^1.4.2",
|
||||||
"nunomaduro/collision": "^5.4",
|
"nunomaduro/collision": "^5.4",
|
||||||
"nunomaduro/larastan": "^0.7",
|
"nunomaduro/larastan": "^0.7",
|
||||||
|
|||||||
40
config/laravel-erd.php
Normal file
40
config/laravel-erd.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'url' => 'erd',
|
||||||
|
'middlewares' => [
|
||||||
|
//Example
|
||||||
|
//\App\Http\Middleware\NotFoundWhenProduction::class,
|
||||||
|
],
|
||||||
|
'models_path' => base_path('app/Models'),
|
||||||
|
'docs_path' => base_path('docs/erd/'),
|
||||||
|
|
||||||
|
"display" => [
|
||||||
|
"show_data_type" => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
"from_text" => [
|
||||||
|
"BelongsTo" => "1..1\nBelongs To",
|
||||||
|
"BelongsToMany" => "1..*\nBelongs To Many",
|
||||||
|
"HasMany" => "1..*\nHas Many",
|
||||||
|
"HasOne" => "1..1\nHas One",
|
||||||
|
"ManyToMany" => "*..*\nMany To Many",
|
||||||
|
"ManyToOne" => "*..1\nMany To One",
|
||||||
|
"OneToMany" => "1..*\nOne To Many",
|
||||||
|
"OneToOne" => "1..1\nOne To One",
|
||||||
|
"MorphTo" => "1..1\n",
|
||||||
|
"MorphToMany" => "1..*\n",
|
||||||
|
],
|
||||||
|
"to_text" => [
|
||||||
|
"BelongsTo" => "",
|
||||||
|
"BelongsToMany" => "",
|
||||||
|
"HasMany" => "",
|
||||||
|
"HasOne" => "",
|
||||||
|
"ManyToMany" => "",
|
||||||
|
"ManyToOne" => "",
|
||||||
|
"OneToMany" => "",
|
||||||
|
"OneToOne" => "",
|
||||||
|
"MorphTo" => "",
|
||||||
|
"MorphToMany" => "",
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -17,7 +17,8 @@ return [
|
|||||||
|
|
||||||
// Tags Models
|
// Tags Models
|
||||||
'models' => [
|
'models' => [
|
||||||
'tag' => \Rinvex\Tags\Models\Tag::class,
|
// 'tag' => \Rinvex\Tags\Models\Tag::class,
|
||||||
|
'tag' => \App\Models\Shop\Tag::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -182,6 +182,19 @@ return [
|
|||||||
'successdel' => 'Le tag a été correctement effacé',
|
'successdel' => 'Le tag a été correctement effacé',
|
||||||
'confirmdelete' => 'Confirmez-vous la suppression du tag ?',
|
'confirmdelete' => 'Confirmez-vous la suppression du tag ?',
|
||||||
],
|
],
|
||||||
|
'tag_families' => [
|
||||||
|
'title' => 'Familles de tags',
|
||||||
|
'name' => 'Famille de tag',
|
||||||
|
'description' => 'Gérer les familles de tags',
|
||||||
|
'add' => 'Ajouter une famille de tag',
|
||||||
|
'edit' => 'Editer une famille de tag',
|
||||||
|
'del' => 'Effacer une famille de tag',
|
||||||
|
'list' => 'Liste des familles de tags',
|
||||||
|
'successadd' => 'La famille de tag été correctement ajoutée',
|
||||||
|
'successmod' => 'La famille de tag a été correctement modifiée',
|
||||||
|
'successdel' => 'La famille de tag a été correctement effacée',
|
||||||
|
'confirmdelete' => 'Confirmez-vous la suppression de la famille de tag ?',
|
||||||
|
],
|
||||||
'tariffs' => [
|
'tariffs' => [
|
||||||
'title' => 'Tarifs',
|
'title' => 'Tarifs',
|
||||||
'name' => 'Tarif',
|
'name' => 'Tarif',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<form id="{{ $model }}-filters">
|
<form id="{{ $model }}-filters">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-4">{{ __('article_natures.title') }}</label>
|
<label class="col-4">{{ __('shop.article_natures.title') }}</label>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
@include('components.form.select', ['name' => 'article_nature_id', 'list' => $article_natures ?? [], 'value' => $filters['article_nature_id'] ?? null, 'class' => 'form-control-sm select2', 'with_empty' => ' '])
|
@include('components.form.select', ['name' => 'article_nature_id', 'list' => $article_natures ?? [], 'value' => $filters['article_nature_id'] ?? null, 'class' => 'form-control-sm select2', 'with_empty' => ' '])
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
@if ($inherited['tags'])
|
@if ($inherited['tags'])
|
||||||
<h6> Tags</h6>
|
<h6> Tags</h6>
|
||||||
@foreach ($inherited['tags'] as $tag)
|
@foreach ($inherited['tags'] as $tag)
|
||||||
<button type="button" class="btn btn-secondary btn-xs">{{ $tag['group']['name'] }}-{{ $tag['name'] }}</button>
|
<button type="button" class="btn btn-secondary btn-xs">{{ $tag['group']['name'] }}-{{ $tag['name']['fr'] }}</button>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{{ Form::open(['route' => 'Admin.Shop.Categories.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
|
{{ Form::open(['route' => 'Admin.Shop.Categories.store', 'id' => 'category-form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||||
@include('Admin.Shop.Categories.form')
|
@include('Admin.Shop.Categories.form')
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{{ Form::open(['route' => 'Admin.Shop.Categories.store', 'id' => 'form', 'autocomplete' => 'off']) }}
|
{{ Form::open(['route' => 'Admin.Shop.Categories.store', 'id' => 'category-form', 'autocomplete' => 'off']) }}
|
||||||
<input type="hidden" name="id" value="{{ $category['id'] }}">
|
<input type="hidden" name="id" value="{{ $category['id'] }}">
|
||||||
@include('Admin.Shop.Categories.form')
|
@include('Admin.Shop.Categories.form')
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -39,10 +39,12 @@
|
|||||||
|
|
||||||
@include('load.form.select2')
|
@include('load.form.select2')
|
||||||
@include('load.form.editor')
|
@include('load.form.editor')
|
||||||
|
@include('load.form.save')
|
||||||
|
|
||||||
@push('js')
|
@push('js')
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
initSaveForm('#category-form');
|
||||||
initSelect2();
|
initSelect2();
|
||||||
initEditor();
|
initEditor();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,17 +5,29 @@
|
|||||||
])
|
])
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
@component('components.card')
|
@component('components.card')
|
||||||
@include('components.datatable', ['route' => route('Admin.Shop.Categories.index'), 'model' => 'categories'])
|
@include('components.datatable', ['route' => route('Admin.Shop.Categories.index'), 'model' => 'categories', 'callback' => 'handleCategory();'])
|
||||||
@endcomponent
|
@endcomponent
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@include('Admin.Shop.Categories.partials.tree')
|
@include('Admin.Shop.Categories.partials.tree')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@include('load.form.select2')
|
||||||
|
@include('load.form.toggle')
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
function handleCategory() {
|
||||||
|
initToggle("{{ route('Admin.Shop.Categories.toggleVisible') }}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
initSelect2();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -4,8 +4,6 @@
|
|||||||
'breadcrumb' => [__('shop.customers.title')]
|
'breadcrumb' => [__('shop.customers.title')]
|
||||||
])
|
])
|
||||||
|
|
||||||
@include('boilerplate::load.fileinput')
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
{{ Form::open(['route' => 'Admin.Shop.Customers.update', 'id' => 'customer-form', 'autocomplete' => 'off']) }}
|
{{ Form::open(['route' => 'Admin.Shop.Customers.update', 'id' => 'customer-form', 'autocomplete' => 'off']) }}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
{{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }}
|
{{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }}
|
||||||
@include('components.form.select', ['name' => 'sale_delivery_id', 'list' => $sale_deliveries ?? [], 'value' => $customer['sale_delivery_id'] ?? null, 'with_empty' => '', 'class' => 'select2'])
|
@include('components.form.select', ['name' => 'sale_delivery_id', 'list' => $deliveries ?? [], 'values' => $customer['deliveries'] ?? null, 'with_empty' => '', 'class' => 'select2', 'multiple' => true])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@include('components.address', ['with_country' => false])
|
@include('components.address', ['with_country' => false])
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
@if (count($prices ?? []))
|
@if (count($prices ?? []))
|
||||||
<table class="table table-bordered table-hover table-striped w-100 mb-0 dataTable">
|
<table class="table table-bordered table-hover table-striped w-100 mb-0">
|
||||||
<tr>
|
<tr>
|
||||||
@foreach ($prices as $price)
|
@foreach ($prices as $price)
|
||||||
<td>
|
<td>
|
||||||
{{ $price['code'] ?? null }} - {{ $price['quantity'] ?? null }} : {{ $price['price_taxed'] ?? null }} €
|
{{ "{" . ($price['code'] ?? null) . "}" }} - {{ $price['quantity'] ?? null }} : {{ $price['price_taxed'] ?? null }} € TTC
|
||||||
</td>
|
</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -11,10 +11,6 @@
|
|||||||
<option value=''>{{ $with_empty }}</option>
|
<option value=''>{{ $with_empty }}</option>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (isset($multiple))
|
@include('components.form.options')
|
||||||
@include('components.form.options.options-multiple')
|
|
||||||
@else
|
|
||||||
@include('components.form.options')
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
<?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('create', 'CategoryController@create')->name('create');
|
Route::get('create', 'CategoryController@create')->name('create');
|
||||||
Route::delete('destroy/{id?}', 'CategoryController@destroy')->name('destroy');
|
Route::delete('destroy/{id?}', 'CategoryController@destroy')->name('destroy');
|
||||||
Route::post('update', 'CategoryController@update')->name('update');
|
Route::post('update', 'CategoryController@update')->name('update');
|
||||||
Route::post('store', 'CategoryController@store')->name('store');
|
Route::post('store', 'CategoryController@store')->name('store');
|
||||||
Route::get('edit/{id}', 'CategoryController@edit')->name('edit');
|
Route::get('edit/{id}', 'CategoryController@edit')->name('edit');
|
||||||
|
|
||||||
Route::any('getImages/{id?}', 'CategoryController@getImages')->name('getImages');
|
Route::any('getImages/{id?}', 'CategoryController@getImages')->name('getImages');
|
||||||
Route::post('deleteImage', 'CategoryController@deleteImage')->name('deleteImage');
|
Route::post('deleteImage', 'CategoryController@deleteImage')->name('deleteImage');
|
||||||
Route::post('moveTree', 'CategoryController@moveTree')->name('moveTree');
|
Route::post('moveTree', 'CategoryController@moveTree')->name('moveTree');
|
||||||
|
|
||||||
|
Route::post('toggleVisible', 'CategoryController@toggleVisible')->name('toggleVisible');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user