Add producers

This commit is contained in:
Ludovic CANDELLIER
2022-04-25 11:07:02 +02:00
parent 570374bab7
commit 5747b93952
19 changed files with 339 additions and 37 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Datatables\Shop;
use Yajra\DataTables\Html\Column;
use App\Datatables\ParentDataTable as DataTable;
use App\Models\Shop\Merchandise;
use App\Repositories\Shop\Merchandises;
class MerchandisesDataTable extends DataTable
{
public $model_name = 'merchandises';
public function query(Merchandise $model)
{
$model = $model::with(['image', 'tags'])->withCount(['Articles', 'tags', 'images']);
return $this->buildQuery($model);
}
public function modifier($datatables)
{
$datatables
->editColumn('thumb', function (Merchandise $merchandise) {
return Merchandises::getThumb($merchandise->image);
})
->editColumn('tags2', function (Merchandise $merchandise) {
$html = '';
foreach ($merchandise->tags as $tag) {
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
}
return $html;
})
->rawColumns(['thumb', 'tags2', 'action']);
return parent::modifier($datatables);
}
protected function getColumns()
{
return [
Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'),
Column::make('name')->title('Nom'),
Column::make('tags2')->title('Tags')->searchable(false)->orderable(false),
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false),
Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false),
Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false),
$this->makeColumnButtons(),
];
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Http\Controllers\Admin\Shop;
use Illuminate\Http\Request;
use App\Repositories\Shop\Producers;
use App\Repositories\Shop\TagGroups;
use App\Datatables\Shop\ProducersDataTable;
use App\Models\Shop\Producer;
class ProducerController extends Controller
{
public function index(ProducersDataTable $dataTable)
{
return $dataTable->render('Admin.Shop.Producers.list');
}
public function create()
{
$data['tags_list'] = TagGroups::getTreeTags();
return view('Admin.Shop.Producers.create', $data);
}
public function store(Request $request)
{
$data = $request->all();
Producers::storeFull($data);
return redirect()->route('Admin.Shop.Producers.index');
}
public function show($id)
{
return view('Admin.Shop.Producers.view', Producers::get($id));
}
public function edit($id)
{
$data['producer'] = Producers::getFull($id);
$data['tags_list'] = TagGroups::getTreeTags();
return view('Admin.Shop.Producers.edit', $data);
}
public function destroy($id)
{
return Producers::destroy($id);
}
public function getImages(Request $request, $id = false, $can_edit = true)
{
$id = $id ? $id : $request->input('id');
$data['images'] = Producers::getImages($id);
$data['can_edit'] = $can_edit;
return view('components.uploader.mini-gallery-items', $data);
}
public function deleteImage(Request $request)
{
$id = $request->input('id');
$index = $request->input('index');
return Producers::deleteImage($id, $index);
}
public function exportExcel()
{
return Producers::exportExcel();
}
}

View File

@@ -27,7 +27,7 @@ class CategoryController extends Controller
// dump($data['articles']); // dump($data['articles']);
// exit; // exit;
$data['tags'] = TagGroups::getWithTagsAndCountOffers(); $data['tags'] = TagGroups::getWithTagsAndCountOffers();
return view('Shop.shelve', $data); return view('Shop.Shelves.shelve', $data);
} }
public function getTree() public function getTree()

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\HasMedia;
use Rinvex\Tags\Traits\Taggable;
use Kirschbaum\PowerJoins\PowerJoins;
use Wildside\Userstamps\Userstamps;
use App\Traits\Model\Imageable;
class Producer extends Model implements HasMedia
{
use Imageable, PowerJoins, SoftDeletes, Taggable, UserStamps;
protected $guarded = ['id'];
protected $table = 'shop_producers';
public function Merchandises()
{
return $this->morphMany(Article::class, 'product');
}
public function tags()
{
return $this->morphToMany(Tag::class, 'taggable');
}
}

View File

@@ -0,0 +1,11 @@
@extends('layout.index', [
'title' => __('shop.merchandises.title'),
'subtitle' => __('shop.merchandises.add'),
'breadcrumb' => [__('shop.merchandises.title'), __('shop.merchandises.add')]
])
@section('content')
{{ Form::open(['route' => 'Admin.Shop.Merchandises.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
@include('Admin.Shop.Merchandises.form')
</form>
@endsection

View File

@@ -0,0 +1,12 @@
@extends('layout.index', [
'title' => __('Shop.merchandises.title'),
'subtitle' => __('Shop.merchandises.edit'),
'breadcrumb' => [__('Shop.merchandises.title'), __('Shop.merchandises.edit')]
])
@section('content')
{{ Form::open(['route' => 'Admin.Shop.Merchandises.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
<input type="hidden" name="id" id="id" value="{{ $merchandise['id'] }}">
@include('Admin.Shop.Merchandises.form')
</form>
@endsection

View File

@@ -0,0 +1,67 @@
<div class="row">
<div class="col-md-8">
<div class="row mb-3">
<div class="col-6">
{{ Form::label('name', 'Nom') }}
@include('components.form.input', ['name' => 'name', 'value' => $merchandise['name'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('tags', 'Tags') }}
@include('components.form.selects.select-tree', [
'name' => 'tags[]',
'list' => $tags_list,
'values' => $merchandise['tags'] ?? null,
'class' => 'select2 form-control',
'multiple' => true
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('description', 'Description') }}
@include('components.form.textarea', [
'name' => 'description',
'value' => $merchandise['description'] ?? null,
'class' => 'editor',
'rows' => 5,
'required' => false,
])
</div>
</div>
</div>
<div class="col-md-4">
@include('components.uploader.widget', [
'load_url' => route('Admin.Shop.Merchandises.getImages', ['id' => $merchandise['id'] ?? false]),
'delete_url' => route('Admin.Botanic.Varieties.deleteImage'),
'name' => 'images',
])
</div>
</div>
@include('components.save')
@include('load.form.appender')
@include('load.form.editor')
@include('load.form.save')
@include('load.form.select2')
@include('load.layout.chevron')
@include('boilerplate::load.fileinput')
@include('boilerplate::load.tinymce')
@push('js')
<script>
$(function() {
initSelect2();
initChevron();
initEditor();
initSaveForm();
});
</script>
@endpush

View File

@@ -0,0 +1,12 @@
@extends('layout.index', [
'title' => __('Marchandises'),
'subtitle' => __('Liste de marchandises'),
'breadcrumb' => [__('Shop.merchandises.title')]
])
@section('content')
@component('components.card')
@include('components.datatable', ['route' => route('Admin.Shop.Merchandises.index'), 'model' => 'merchandises'])
@endcomponent
@endsection

View File

@@ -0,0 +1,30 @@
@extends('layout.index', [
'title' => __('products.title'),
'subtitle' => __('products.title'),
'breadcrumb' => [__('products.title')]
])
@section('content')
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="box box-info">
<div class="box-body">
<div class="col-md-6">
<h3>{{ name }}</h3>
<h4>
{{ $product.section.name }}<br>
</h4>
</div>
<div class="col-md-12">
@include('components.carousel')
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@@ -14,20 +14,24 @@
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<strong>Semence</strong><br/> <span style="font-size: 1.4em">
@if ($article['semences'] ?? false) @if ($article['semences'] ?? false)
<span style="font-size: 1.4em">{{ $article['semences']['price'] ?? null }}</span> <br> {{ $article['semences']['price'] ?? null }}</span>
@else @else
Indisponible<br> -
@endif @endif
</span><br/>
<strong>Semence</strong>
</div> </div>
<div class="col-6"> <div class="col-6">
<strong>Plant</strong><br/> <span style="font-size: 1.4em">
@if ($article['plants'] ?? false) @if ($article['plants'] ?? false)
<span style="font-size: 1.4em">{{ $article['plants']['price'] }}</span> <br> {{ $article['plants']['price'] }}</span>
@else @else
Indisponible<br> -
@endif @endif
</span><br/>
<strong>Plant</strong>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,24 +1,3 @@
<div class="row">
<div class="col-6">
<button type="button" class="btn btn-success shadow">
<i class="fa fa-3x fa-seedling float-left"></i>
Ajouter au panier<br>la liste des <strong>semences</strong>
</button>
</div>
<div class="col-6">
<button type="button" class="btn btn-warning shadow">
<i class="fab fa-3x fa-pagelines float-left"></i>
Ajouter au panier<br>la liste des <strong>plants</strong>
</button>
</div>
</div>
<div class="row pt-3">
<div class="col-12">
Il y a {{ $articles ? count($articles) : 0 }} article(s) dans la liste
</div>
</div>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
@include('components.form.button', ['id' => 'by_cards', 'icon' => 'fa-th', 'class' => 'btn-success']) @include('components.form.button', ['id' => 'by_cards', 'icon' => 'fa-th', 'class' => 'btn-success'])

View File

@@ -0,0 +1,14 @@
<div class="row">
<div class="col-6">
<button type="button" class="btn btn-success shadow">
<i class="fa fa-3x fa-seedling float-left"></i>
Ajouter au panier<br>la liste des <strong>semences</strong>
</button>
</div>
<div class="col-6">
<button type="button" class="btn btn-warning shadow">
<i class="fab fa-3x fa-pagelines float-left"></i>
Ajouter au panier<br>la liste des <strong>plants</strong>
</button>
</div>
</div>

View File

@@ -0,0 +1,5 @@
<div class="row pt-3">
<div class="col-12">
Il y a {{ $articles ? count($articles) : 0 }} article(s) dans la liste
</div>
</div>

View File

@@ -11,13 +11,13 @@
<h3 style="font-size: 1.2em;">{!! $category['description'] !!}</h3> <h3 style="font-size: 1.2em;">{!! $category['description'] !!}</h3>
</div> </div>
<div class="col-4"> <div class="col-4">
@include('Shop.layout.partials.category_add') @include('Shop.Shelves.partials.category_add')
</div> </div>
</div> </div>
@if ($display_by_rows ?? false) @if ($display_by_rows ?? false)
@include('Shop.layout.partials.category_articles_rows') @include('Shop.Shelves.partials.category_articles_rows')
@else @else
@include('Shop.layout.partials.category_articles') @include('Shop.Shelves.partials.category_articles')
@endif @endif
@endsection @endsection

View File

@@ -0,0 +1,16 @@
<?php
Route::prefix('Producers')->name('Producers.')->group(function () {
Route::get('', 'ProducerController@index')->name('index');
Route::get('getDataTable', 'ProducerController@getDataTable')->name('getDataTable');
Route::get('create', 'ProducerController@create')->name('create');
Route::delete('destroy/{id?}', 'ProducerController@destroy')->name('destroy');
Route::post('update', 'ProducerController@update')->name('update');
Route::post('store', 'ProducerController@store')->name('store');
Route::get('edit/{id}', 'ProducerController@edit')->name('edit');
Route::post('getSelect', 'ProducerController@getOptions')->name('getSelect');
Route::post('deleteImage', 'ProducerController@deleteImage')->name('deleteImage');
Route::any('getImages/{id?}/{can_edit?}', 'ProducerController@getImages')->name('getImages');
Route::any('exportExcel', 'ProducerController@exportExcel')->name('exportExcel');
});

View File

@@ -17,6 +17,7 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
include __DIR__ . '/Packages.php'; include __DIR__ . '/Packages.php';
include __DIR__ . '/PriceLists.php'; include __DIR__ . '/PriceLists.php';
include __DIR__ . '/PriceListValues.php'; include __DIR__ . '/PriceListValues.php';
include __DIR__ . '/Producers.php';
include __DIR__ . '/SaleChannels.php'; include __DIR__ . '/SaleChannels.php';
include __DIR__ . '/Tags.php'; include __DIR__ . '/Tags.php';
include __DIR__ . '/TagGroups.php'; include __DIR__ . '/TagGroups.php';