Add producers
This commit is contained in:
51
app/Datatables/Shop/ProducersDataTable.php
Normal file
51
app/Datatables/Shop/ProducersDataTable.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
69
app/Http/Controllers/Admin/Shop/ProducerController.php
Normal file
69
app/Http/Controllers/Admin/Shop/ProducerController.php
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ class CategoryController extends Controller
|
||||
// dump($data['articles']);
|
||||
// exit;
|
||||
$data['tags'] = TagGroups::getWithTagsAndCountOffers();
|
||||
return view('Shop.shelve', $data);
|
||||
return view('Shop.Shelves.shelve', $data);
|
||||
}
|
||||
|
||||
public function getTree()
|
||||
|
||||
31
app/Models/Shop/Producer.php
Normal file
31
app/Models/Shop/Producer.php
Normal 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');
|
||||
}
|
||||
}
|
||||
11
resources/views/Admin/Shop/Producers/create.blade.php
Normal file
11
resources/views/Admin/Shop/Producers/create.blade.php
Normal 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
|
||||
12
resources/views/Admin/Shop/Producers/edit.blade.php
Normal file
12
resources/views/Admin/Shop/Producers/edit.blade.php
Normal 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
|
||||
67
resources/views/Admin/Shop/Producers/form.blade.php
Normal file
67
resources/views/Admin/Shop/Producers/form.blade.php
Normal 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
|
||||
12
resources/views/Admin/Shop/Producers/list.blade.php
Normal file
12
resources/views/Admin/Shop/Producers/list.blade.php
Normal 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
|
||||
|
||||
30
resources/views/Admin/Shop/Producers/show.blade.php
Normal file
30
resources/views/Admin/Shop/Producers/show.blade.php
Normal 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
|
||||
@@ -14,20 +14,24 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<strong>Semence</strong><br/>
|
||||
<span style="font-size: 1.4em">
|
||||
@if ($article['semences'] ?? false)
|
||||
<span style="font-size: 1.4em">{{ $article['semences']['price'] ?? null }}</span> €<br>
|
||||
{{ $article['semences']['price'] ?? null }}</span> €
|
||||
@else
|
||||
Indisponible<br>
|
||||
-
|
||||
@endif
|
||||
</span><br/>
|
||||
<strong>Semence</strong>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<strong>Plant</strong><br/>
|
||||
<span style="font-size: 1.4em">
|
||||
@if ($article['plants'] ?? false)
|
||||
<span style="font-size: 1.4em">{{ $article['plants']['price'] }}</span> €<br>
|
||||
{{ $article['plants']['price'] }}</span> €
|
||||
@else
|
||||
Indisponible<br>
|
||||
-
|
||||
@endif
|
||||
</span><br/>
|
||||
<strong>Plant</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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="col-6">
|
||||
@include('components.form.button', ['id' => 'by_cards', 'icon' => 'fa-th', 'class' => 'btn-success'])
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -11,13 +11,13 @@
|
||||
<h3 style="font-size: 1.2em;">{!! $category['description'] !!}</h3>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@include('Shop.layout.partials.category_add')
|
||||
@include('Shop.Shelves.partials.category_add')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if ($display_by_rows ?? false)
|
||||
@include('Shop.layout.partials.category_articles_rows')
|
||||
@include('Shop.Shelves.partials.category_articles_rows')
|
||||
@else
|
||||
@include('Shop.layout.partials.category_articles')
|
||||
@include('Shop.Shelves.partials.category_articles')
|
||||
@endif
|
||||
@endsection
|
||||
16
routes/Admin/Shop/Producers.php
Normal file
16
routes/Admin/Shop/Producers.php
Normal 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');
|
||||
});
|
||||
|
||||
@@ -17,6 +17,7 @@ Route::middleware('auth')->prefix('Shop')->namespace('Shop')->name('Shop.')->gro
|
||||
include __DIR__ . '/Packages.php';
|
||||
include __DIR__ . '/PriceLists.php';
|
||||
include __DIR__ . '/PriceListValues.php';
|
||||
include __DIR__ . '/Producers.php';
|
||||
include __DIR__ . '/SaleChannels.php';
|
||||
include __DIR__ . '/Tags.php';
|
||||
include __DIR__ . '/TagGroups.php';
|
||||
|
||||
Reference in New Issue
Block a user