Fixes
This commit is contained in:
@@ -8,7 +8,7 @@ use App\Models\Shop\TagGroup;
|
||||
|
||||
class TagGroupsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'TagGroups';
|
||||
public $model_name = 'tag_groups';
|
||||
|
||||
public function query(TagGroup $model)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,11 @@ class SpecieController extends Controller
|
||||
return Species::getDatatable($request->all());
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return response()->json(Species::getOptions());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Botanic.Admin.Species.create');
|
||||
|
||||
@@ -10,66 +10,66 @@ use App\DataTables\Shop\ArticlesDataTable;
|
||||
|
||||
class ArticleController extends Controller
|
||||
{
|
||||
public function index(ArticlesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.Articles.list');
|
||||
}
|
||||
public function index(ArticlesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.Articles.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return Articles::getTables($request->all());
|
||||
}
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return Articles::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = $this->getMeta();
|
||||
return view('Shop.Admin.Articles.create', $data);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
$data = $this->getMeta();
|
||||
return view('Shop.Admin.Articles.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
Articles::storeFull($request->all());
|
||||
return redirect()->route('Shop.Admin.Articles.index');
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
Articles::storeFull($request->all());
|
||||
return redirect()->route('Shop.Admin.Articles.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = Articles::get($id);
|
||||
return view('Shop.Admin.Articles.view', $data);
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
$data = Articles::get($id);
|
||||
return view('Shop.Admin.Articles.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Articles::getFull($id);
|
||||
return view('Shop.Admin.Articles.edit', $data);
|
||||
}
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Articles::getFull($id);
|
||||
return view('Shop.Admin.Articles.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return Articles::destroy($id);
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
return Articles::destroy($id);
|
||||
}
|
||||
|
||||
public function getMeta($data = [])
|
||||
{
|
||||
return Articles::getMeta($data);
|
||||
}
|
||||
public function getMeta($data = [])
|
||||
{
|
||||
return Articles::getMeta($data);
|
||||
}
|
||||
|
||||
public function getImages(Request $request, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $request->input('id');
|
||||
$data['images'] = Articles::getImages($id);
|
||||
return view('components.uploader.mini-gallery-items', $data);
|
||||
}
|
||||
public function getImages(Request $request, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $request->input('id');
|
||||
$data['images'] = Articles::getImages($id);
|
||||
return view('components.uploader.mini-gallery-items', $data);
|
||||
}
|
||||
|
||||
public function deleteImage(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$index = $request->input('index');
|
||||
return Articles::deleteImage($id, $index);
|
||||
}
|
||||
public function deleteImage(Request $request)
|
||||
{
|
||||
$id = $request->input('id');
|
||||
$index = $request->input('index');
|
||||
return Articles::deleteImage($id, $index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,52 +5,52 @@ namespace App\Http\Controllers\Shop\Admin;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\TagGroup;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
use App\DataTables\Shop\TagGroupsDataTable;
|
||||
|
||||
class TagGroupController extends Controller
|
||||
{
|
||||
public function index(TagGroupsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.TagGroups.list');
|
||||
}
|
||||
public function index(TagGroupsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.TagGroups.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return TagGroups::getTables($request->all());
|
||||
}
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return TagGroups::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create($data)
|
||||
{
|
||||
return view('Shop.Admin.TagGroups.create', $data);
|
||||
}
|
||||
public function create($data)
|
||||
{
|
||||
return view('Shop.Admin.TagGroups.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = TagGroups::store($request->all());
|
||||
return redirect()->route('Shop.Admin.TagGroups.index');
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = TagGroups::store($request->all());
|
||||
return redirect()->route('Shop.Admin.TagGroups.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = TagGroups::get($id);
|
||||
return view('Shop.Admin.TagGroups.view', $data);
|
||||
}
|
||||
public function show($id)
|
||||
{
|
||||
$data = TagGroups::get($id);
|
||||
return view('Shop.Admin.TagGroups.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = TagGroups::get($id);
|
||||
return view('Shop.Admin.TagGroups.edit', $data);
|
||||
}
|
||||
public function edit($id)
|
||||
{
|
||||
$data = TagGroups::get($id);
|
||||
return view('Shop.Admin.TagGroups.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return TagGroups::destroy($id);
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
return TagGroups::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class Shop
|
||||
|
||||
$menu->addTo('shop', 'Articles', [ 'route' => 'Shop.Admin.Articles.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Articles.*'])->order(1);
|
||||
$menu->addTo('shop', 'Categories', [ 'route' => 'Shop.Admin.Categories.index', 'permission' => 'backend_access' ])
|
||||
$menu->addTo('shop', 'Rayons', [ 'route' => 'Shop.Admin.Categories.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Categories.*'])->order(2);
|
||||
$menu->addTo('shop', 'Familles d\'articles', [ 'route' => 'Shop.Admin.ArticleFamilies.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleFamilies.*'])->order(3);
|
||||
|
||||
@@ -22,8 +22,8 @@ class ArticleFamily extends Model
|
||||
return $this->hasMany('App\Models\Shop\Price');
|
||||
}
|
||||
|
||||
public function unities()
|
||||
public function packages()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Unity');
|
||||
return $this->hasMany('App\Models\Shop\Package');
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,10 @@ class Varieties
|
||||
$data = [];
|
||||
foreach ($varieties as $variety)
|
||||
{
|
||||
$data[] = ['id' => $variety->id, 'text' => (isset($variety->specie->name) ? $variety->specie->name . ' ' : '') . $variety->name];
|
||||
$data[$variety->id] = (isset($variety->specie->name) ? $variety->specie->name . ' ' : '') . $variety->name;
|
||||
}
|
||||
return collect($data)->sortBy('text')->values()->all();
|
||||
asort($data, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
|
||||
@@ -8,6 +8,8 @@ use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Repositories\Botanic\Species;
|
||||
use App\Repositories\Botanic\Varieties;
|
||||
use App\Models\Shop\Article;
|
||||
|
||||
class Articles
|
||||
@@ -37,11 +39,12 @@ class Articles
|
||||
|
||||
public static function getMeta(&$data = [])
|
||||
{
|
||||
$data['products'] = ($data['product_type'] == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
||||
$data['categories_options'] = Categories::getOptions();
|
||||
$data['price_generics'] = PriceGenericCategories::getOptionsWithChildrens();
|
||||
$data['families_options'] = ArticleFamilies::getOptions();
|
||||
$data['taxes_options'] = Taxes::getOptions();
|
||||
$data['packages'] = Packages::getSelectByFamily($data['article_family_id']);
|
||||
$data['packages'] = ($data['article_family_id'] ?? false) ? Packages::getSelectByFamily($data['article_family_id']) : [];
|
||||
$data['unities'] = ($data['packages']['id'] ?? false) ? Unities::getSelectByPackage($data['packages']['id']) : [];
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
$data['models_options'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
'breadcrumb' => [__('Shop.articles.title'), __('Shop.articles.add')]
|
||||
])
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Shop.Admin.Articles.store', 'id' => 'article-form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
'breadcrumb' => ['Articles']
|
||||
])
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Shop.Admin.Articles.store', 'id' => 'article-form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@include('boilerplate::load.fileinput')
|
||||
@include('boilerplate::load.select2')
|
||||
@include('load.set_options')
|
||||
@include('boilerplate::load.tinymce')
|
||||
|
||||
<div class="row mt-3">
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div class="col-6">
|
||||
{{ Form::label('model_id', 'Produit') }}<br>
|
||||
@include('components.select2', ['name' => 'product_id', 'id_name' => 'product_id', 'value' => isset($product_id) ? $product_id : null, 'class' => 'select2 form-control'])
|
||||
@include('components.select', ['name' => 'product_id', 'id_name' => 'product_id', 'list' => $products ?? [], 'value' => isset($product_id) ? $product_id : null, 'class' => 'select2 form-control'])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -64,7 +64,16 @@
|
||||
});
|
||||
|
||||
$('#product_type').change( function() {
|
||||
loadVarieties();
|
||||
var product_type = $(this).val();
|
||||
switch (product_type) {
|
||||
case 'App\\Models\\Botanic\\Specie':
|
||||
loadSpecies();
|
||||
break;
|
||||
case 'App\\Models\\Botanic\\Variety':
|
||||
default:
|
||||
loadVarieties();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function loadVarieties() {
|
||||
@@ -73,12 +82,28 @@
|
||||
method : 'POST',
|
||||
data: {model: $('#product_type').val()},
|
||||
success : function(data) {
|
||||
$("#product_id").select2({data: data});
|
||||
$("#product_id").trigger('change');
|
||||
setOptions('#product_id', data);
|
||||
// $("#product_id").select2({data: data});
|
||||
// $("#product_id").trigger('change');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadVarieties();
|
||||
function loadSpecies() {
|
||||
console.log('loadSpecies');
|
||||
console.log($('#product_type').val());
|
||||
$.ajax({
|
||||
url : '{{ route('Botanic.Admin.Species.getSelect') }}',
|
||||
method : 'POST',
|
||||
data: {model: $('#product_type').val()},
|
||||
success : function(data) {
|
||||
setOptions('#product_id', data);
|
||||
// $("#product_id").select2({data: data});
|
||||
// $("#product_id").trigger('change');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// loadVarieties();
|
||||
</script>
|
||||
@endpush
|
||||
@@ -0,0 +1,52 @@
|
||||
@include('Shop.Admin.Articles.partials.generic_prices.block_generic_price_new')
|
||||
|
||||
<div id="append_generic_price" class="row">
|
||||
@include('Shop.Admin.Articles.partials.generic_prices.list-generic_prices')
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-primary add-new-generic_price">Associer un tarif générique<i class="fa fa-plus"></i></button>
|
||||
|
||||
|
||||
@include('components.select-tree', ['name' => "article_price_generic_id", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm w-100'])
|
||||
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
|
||||
function append_generic_price() {
|
||||
// handle_append_attribute();
|
||||
$('.select2').select2();
|
||||
// handle_change_attribute();
|
||||
// load_attribute_values($('.attributes-value'), $('.attributes-family').val());
|
||||
}
|
||||
|
||||
$("#append_generic_price").appender({
|
||||
rowSection: '.row-new-generic_price',
|
||||
type: '.row-generic_price',
|
||||
addBtn: '.add-new-generic_price',
|
||||
appendEffect: 'slide',
|
||||
addClass: 'animated bounceInLeft',
|
||||
rowNumber: '.row-generic_price-number',
|
||||
deleteBtn: '.delete-new-generic_price-btn',
|
||||
callback: append_generic_price,
|
||||
rowNumberStart: 2,
|
||||
hideSection: true
|
||||
});
|
||||
|
||||
|
||||
function handle_delete_generic_price() {
|
||||
$('.delete-generic_price-btn').click(function() {
|
||||
var $selector = $(this).parents('.row-generic_price');
|
||||
var id = $selector.find('.generic_price_id').val();
|
||||
|
||||
/*
|
||||
confirm_delete(id, "{## route('Shop.Admin.ArticlePrices.destroy') }}", function() {
|
||||
$selector.remove();
|
||||
});
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
@@ -8,8 +8,8 @@
|
||||
<script>
|
||||
$(function () {
|
||||
handle_delete_price();
|
||||
init_attribute_values();
|
||||
handle_change_attribute();
|
||||
init_unities();
|
||||
handle_change_package();
|
||||
handle_prices();
|
||||
handle_prices_taxed();
|
||||
});
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
function append_price() {
|
||||
// handle_append_attribute();
|
||||
$('.select2').select2();
|
||||
handle_change_attribute();
|
||||
load_attribute_values($('.unities'), $('.price-family').val());
|
||||
handle_change_package();
|
||||
load_unities($('.unities'), $('.package').val());
|
||||
}
|
||||
|
||||
$("#append_price").appender({
|
||||
@@ -29,35 +29,36 @@
|
||||
hideSection: true
|
||||
});
|
||||
|
||||
function handle_change_attribute() {
|
||||
$('.price-family').change( function() {
|
||||
var family_id = $(this).val();
|
||||
var $family = $(this);
|
||||
var $parent = $family.parent().parent();
|
||||
function handle_change_package() {
|
||||
$('.package').change( function() {
|
||||
var package_id = $(this).val();
|
||||
var $package = $(this);
|
||||
var $parent = $package.parent().parent();
|
||||
var $selector = $parent.find('.unities');
|
||||
load_attribute_values($selector, family_id);
|
||||
load_unities($selector, package_id);
|
||||
});
|
||||
}
|
||||
|
||||
function init_attribute_values() {
|
||||
$('.price-family').each( function() {
|
||||
var family_id = $(this).val();
|
||||
var $family = $(this);
|
||||
var $parent = $family.parent().parent();
|
||||
function init_unities() {
|
||||
$('.package').each( function() {
|
||||
var package_id = $(this).val();
|
||||
var $package = $(this);
|
||||
var $parent = $package.parent().parent();
|
||||
var $selector = $parent.find('.unities');
|
||||
load_attribute_values($selector, family_id);
|
||||
load_unities($selector, package_id);
|
||||
value_id = $selector.data('id');
|
||||
$selector.val(value_id).trigger('change');
|
||||
});
|
||||
}
|
||||
|
||||
function load_attribute_values($selector, family_id) {
|
||||
function load_unities($selector, package_id) {
|
||||
$.ajax({
|
||||
url : "{{ route('Shop.Admin.Unities.getOptionsByFamily') }}",
|
||||
url : "{{ route('Shop.Admin.Unities.getOptionsByPackage') }}",
|
||||
method : 'POST',
|
||||
data: { family_id: family_id },
|
||||
data: { package_id: package_id },
|
||||
success : function(data) {
|
||||
$selector.empty().select2({data: data});
|
||||
setOptions($selector, data);
|
||||
// $selector.empty().select2({data: data});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,16 @@
|
||||
})
|
||||
}
|
||||
|
||||
function handle_packages() {
|
||||
$('.delete-price-btn').click(function() {
|
||||
var $selector = $(this).parents('.row-price');
|
||||
var id = $selector.find('.price_id').val();
|
||||
|
||||
confirm_delete(id, laroute.route('Shop.Admin.PriceGenericValues.destroy', {id : id}), function() {
|
||||
$selector.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
])
|
||||
|
||||
@section('content')
|
||||
@include('components.datatable', ['route' => route('Shop.Admin.TagGroups.index'), 'model' => 'TagGroups'])
|
||||
@include('components.datatable', ['route' => route('Shop.Admin.TagGroups.index'), 'model' => 'tag_groups'])
|
||||
@endsection
|
||||
|
||||
@@ -7,6 +7,7 @@ Route::prefix('Species')->name('Species.')->group(function () {
|
||||
Route::post('update', 'SpecieController@update')->name('update');
|
||||
Route::post('store', 'SpecieController@store')->name('store');
|
||||
Route::get('edit/{id}', 'SpecieController@edit')->name('edit');
|
||||
Route::any('getSelect', 'SpecieController@getOptions')->name('getSelect');
|
||||
|
||||
Route::any('exportExcel', 'SpecieController@exportExcel')->name('exportExcel');
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
Route::resource('PriceFamilies', 'PriceFamilyController');
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
Route::prefix('PriceFamilyValues')->name('PriceFamilyValues.')->group(function () {
|
||||
Route::any('getOptionsByFamily', 'PriceFamilyValueController@getOptionsByFamily')->name('getOptionsByFamily');
|
||||
});
|
||||
|
||||
Route::resource('PriceFamilyValues', 'PriceFamilyValueController');
|
||||
@@ -13,7 +13,6 @@ Route::middleware('auth')->prefix('Admin')->namespace('Admin')->name('Admin.')->
|
||||
include __DIR__ . '/Invoices.php';
|
||||
include __DIR__ . '/OrderPayments.php';
|
||||
include __DIR__ . '/Orders.php';
|
||||
include __DIR__ . '/PriceFamilies.php';
|
||||
include __DIR__ . '/PriceGenerics.php';
|
||||
include __DIR__ . '/Tags.php';
|
||||
include __DIR__ . '/TagGroups.php';
|
||||
|
||||
Reference in New Issue
Block a user