Ajout du titre du produit sur l'article
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\DataTables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\TagFamily;
|
||||
|
||||
class TagFamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'TagFamilies';
|
||||
|
||||
public function query(TagFamily $model)
|
||||
{
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
27
app/DataTables/Shop/TagGroupsDataTable.php
Normal file
27
app/DataTables/Shop/TagGroupsDataTable.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\DataTables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\TagGroup;
|
||||
|
||||
class TagGroupsDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'TagGroups';
|
||||
|
||||
public function query(TagGroup $model)
|
||||
{
|
||||
$model = $model::withCount('tags');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,11 +19,7 @@ class TagsDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(120)
|
||||
->addClass('text-center'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\Tags;
|
||||
use App\Repositories\Shop\TagFamilies;
|
||||
use App\Repositories\Shop\TagGroups;
|
||||
use App\DataTables\Shop\TagsDataTable;
|
||||
|
||||
class TagController extends Controller
|
||||
@@ -24,10 +24,7 @@ class TagController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$data = [];
|
||||
$data['categories'] = Categories::getOptions();
|
||||
$data['families'] = TagFamilies::getOptions();
|
||||
$data['attribute_families'] = TagAttributeFamilies::getOptions();
|
||||
$data['models'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
$data['groups'] = TagGroups::getOptions();
|
||||
return view('Shop.Admin.Tags.create', $data);
|
||||
}
|
||||
|
||||
@@ -46,7 +43,7 @@ class TagController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Tags::get($id);
|
||||
$data['categories'] = Tags::getOptions();
|
||||
$data['groups'] = TagGroups::getOptions();
|
||||
return view('Shop.Admin.Tags.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\TagFamily;
|
||||
use App\DataTables\Shop\TagFamiliesDataTable;
|
||||
|
||||
class TagFamilyController extends Controller
|
||||
{
|
||||
public function index(TagFamiliesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.TagFamilies.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return TagFamilies::getTables($request->all());
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = [];
|
||||
$data['categories'] = Categories::getOptions();
|
||||
$data['families'] = TagFamilyFamilies::getOptions();
|
||||
$data['attribute_families'] = TagFamilyAttributeFamilies::getOptions();
|
||||
$data['models'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
return view('Shop.Admin.TagFamilies.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$ret = TagFamilies::store($request->all());
|
||||
return redirect()->route('Shop.Admin.TagFamilies.index');
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$data = TagFamilies::get($id);
|
||||
return view('Shop.Admin.TagFamilies.view', $data);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = TagFamilies::get($id);
|
||||
$data['categories'] = TagFamilies::getOptions();
|
||||
return view('Shop.Admin.TagFamilies.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return TagFamilies::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
56
app/Http/Controllers/Shop/Admin/TagGroupController.php
Normal file
56
app/Http/Controllers/Shop/Admin/TagGroupController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Repositories\Shop\TagGroup;
|
||||
use App\DataTables\Shop\TagGroupsDataTable;
|
||||
|
||||
class TagGroupController extends Controller
|
||||
{
|
||||
public function index(TagGroupsDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.TagGroups.list');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
return TagGroups::getTables($request->all());
|
||||
}
|
||||
|
||||
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 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 update(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return TagGroups::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,8 +23,8 @@ class Shop
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeFamilies.*'])->order(4);
|
||||
$menu->addTo('shop', 'Attributs', [ 'route' => 'Shop.Admin.ArticleAttributeValues.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(5);
|
||||
$menu->addTo('shop', 'Familles de tags', [ 'route' => 'Shop.Admin.TagFamilies.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.TagFamilies.*'])->order(6);
|
||||
$menu->addTo('shop', 'Familles de tags', [ 'route' => 'Shop.Admin.TagGroups.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.TagGroups.*'])->order(6);
|
||||
$menu->addTo('shop', 'Tags', [ 'route' => 'Shop.Admin.Tags.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Tags.*'])->order(7);
|
||||
|
||||
|
||||
@@ -4,9 +4,15 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TagFamily extends Model
|
||||
class Tag extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'tagging_tag_groups';
|
||||
protected $table = 'tagging_tags';
|
||||
|
||||
|
||||
public function group()
|
||||
{
|
||||
return $this->hasOne('App\Models\Shop\TagGroup');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,14 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TagFamily extends Model
|
||||
class TagGroup extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'tagging_tag_groups';
|
||||
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Tag');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,10 +15,15 @@ class TagGroups
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = TagGroup::orderBy('name');
|
||||
$model = TagGroup::query();
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return TagGroup::get()->SortBy('name')->pluck('name','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return TagGroup::orderBy('name','asc')->get();
|
||||
|
||||
54
app/Repositories/Shop/Tags.php
Normal file
54
app/Repositories/Shop/Tags.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use Yajra\DataTables\DataTables;
|
||||
|
||||
use App\Models\Shop\TagGroup;
|
||||
|
||||
class TagGroups
|
||||
{
|
||||
|
||||
public static function getDatatable()
|
||||
{
|
||||
$model = TagGroup::orderBy('name');
|
||||
return Datatables::of($model)->make(true);
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
return TagGroup::orderBy('name','asc')->get();
|
||||
}
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return TagGroup::find($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
$id = isset($data['id']) ? $data['id'] : false;
|
||||
$item = $id ? self::update($data) : self::create($data);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
return TagGroup::create($data);
|
||||
}
|
||||
|
||||
public static function update($data)
|
||||
{
|
||||
return TagGroup::find($id)->update($data);
|
||||
}
|
||||
|
||||
public static function destroy($id)
|
||||
{
|
||||
return TagGroup::destroy($id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user