Attributes
This commit is contained in:
@@ -8,23 +8,25 @@ use App\Models\Shop\ArticleAttributeFamily;
|
|||||||
|
|
||||||
class ArticleAttributeFamiliesDataTable extends DataTable
|
class ArticleAttributeFamiliesDataTable extends DataTable
|
||||||
{
|
{
|
||||||
public $model_name = 'ArticleAttributeFamilies';
|
public $model_name = 'ArticleAttributeFamilies';
|
||||||
|
|
||||||
public function query(ArticleFamily $model)
|
public function query(ArticleAttributeFamily $model)
|
||||||
{
|
{
|
||||||
return self::buildQuery($model);
|
$model = $model::withCount(['values']);
|
||||||
}
|
return self::buildQuery($model);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('name'),
|
Column::make('name'),
|
||||||
Column::computed('action')
|
Column::make('values_count')->title('Nb valeurs')->searchable(false),
|
||||||
->exportable(false)
|
Column::computed('action')
|
||||||
->printable(false)
|
->exportable(false)
|
||||||
->width(120)
|
->printable(false)
|
||||||
->addClass('text-center'),
|
->width(120)
|
||||||
];
|
->addClass('text-center'),
|
||||||
}
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,23 +8,25 @@ use App\Models\Shop\ArticleAttributeValue;
|
|||||||
|
|
||||||
class ArticleAttributeValuesDataTable extends DataTable
|
class ArticleAttributeValuesDataTable extends DataTable
|
||||||
{
|
{
|
||||||
public $model_name = 'ArticleAttributeValues';
|
public $model_name = 'ArticleAttributeValues';
|
||||||
|
|
||||||
public function query(ArticleFamily $model)
|
public function query(ArticleAttributeValue $model)
|
||||||
{
|
{
|
||||||
return self::buildQuery($model);
|
$model = $model::with(['attribute_family']);
|
||||||
}
|
return self::buildQuery($model);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getColumns()
|
protected function getColumns()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Column::make('name'),
|
Column::make('attribute_family.name')->title('Famille d\'attributs'),
|
||||||
Column::computed('action')
|
Column::make('value'),
|
||||||
->exportable(false)
|
Column::computed('action')
|
||||||
->printable(false)
|
->exportable(false)
|
||||||
->width(120)
|
->printable(false)
|
||||||
->addClass('text-center'),
|
->width(120)
|
||||||
];
|
->addClass('text-center'),
|
||||||
}
|
];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ namespace App\Http\Controllers\Shop\Admin;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
use App\Model\Shop\ArticleAttributeFamily;
|
use App\Repositories\Shop\ArticleAttributeFamilies;
|
||||||
|
use App\DataTables\Shop\ArticleAttributeFamiliesDataTable;
|
||||||
|
|
||||||
class ArticleAttributeFamilyController extends Controller
|
class ArticleAttributeFamilyController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Shop\Admin;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use App\Repositories\Shop\ArticleAttributeValues;
|
||||||
|
use App\DataTables\Shop\ArticleAttributeValuesDataTable;
|
||||||
|
|
||||||
|
class ArticleAttributeValueController extends Controller
|
||||||
|
{
|
||||||
|
public function index(ArticleAttributeValuesDataTable $dataTable)
|
||||||
|
{
|
||||||
|
return $dataTable->render('Shop.Admin.ArticleAttributeValues.list');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatatable(Request $request)
|
||||||
|
{
|
||||||
|
return ArticleAttributeValues::getTables($request->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('Shop.Admin.ArticleAttributeValues.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$ret = ArticleAttributeValues::store($request->all());
|
||||||
|
return redirect()->route('Shop.Admin.ArticleAttributeValues.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show($id)
|
||||||
|
{
|
||||||
|
$data = ArticleAttributeValues::get($id);
|
||||||
|
return view('Shop.Admin.ArticleAttributeValues.view', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$data = ArticleAttributeValues::get($id);
|
||||||
|
return view('Shop.Admin.ArticleAttributeValues.edit', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
return ArticleAttributeValues::destroy($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,10 +21,10 @@ class Shop
|
|||||||
->activeIfRoute(['Shop.Admin.Articles.*'])->order(2);
|
->activeIfRoute(['Shop.Admin.Articles.*'])->order(2);
|
||||||
$menu->addTo('shop', 'Familles d\'articles', [ 'route' => 'Shop.Admin.ArticleFamilies.index', 'permission' => 'backend_access' ])
|
$menu->addTo('shop', 'Familles d\'articles', [ 'route' => 'Shop.Admin.ArticleFamilies.index', 'permission' => 'backend_access' ])
|
||||||
->activeIfRoute(['Shop.Admin.ArticleFamilies.*'])->order(3);
|
->activeIfRoute(['Shop.Admin.ArticleFamilies.*'])->order(3);
|
||||||
$menu->addTo('shop', 'Familles d\'attributs d\'articles', [ 'route' => 'Shop.Admin.ArticleAttributeFamilies.index', 'permission' => 'backend_access' ])
|
$menu->addTo('shop', 'Familles d\'attributs', [ 'route' => 'Shop.Admin.ArticleAttributeFamilies.index', 'permission' => 'backend_access' ])
|
||||||
->activeIfRoute(['Shop.Admin.ArticleAttributeFamilies.*'])->order(4);
|
->activeIfRoute(['Shop.Admin.ArticleAttributeFamilies.*'])->order(4);
|
||||||
$menu->addTo('shop', 'Attributs d\'articles', [ 'route' => 'Shop.Admin.ArticleAttributes.index', 'permission' => 'backend_access' ])
|
$menu->addTo('shop', 'Attributs', [ 'route' => 'Shop.Admin.ArticleAttributeValues.index', 'permission' => 'backend_access' ])
|
||||||
->activeIfRoute(['Shop.Admin.ArticleAttributes.*'])->order(5);
|
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(5);
|
||||||
|
|
||||||
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend_access' ])
|
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend_access' ])
|
||||||
->activeIfRoute(['Shop.Admin.Orders.*'])->order(6);
|
->activeIfRoute(['Shop.Admin.Orders.*'])->order(6);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Article extends Model
|
|||||||
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ProductAttributes()
|
public function ArticleAttributes()
|
||||||
{
|
{
|
||||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ use Illuminate\Database\Eloquent\Relations\Pivot;
|
|||||||
|
|
||||||
class ArticleAttribute extends Pivot
|
class ArticleAttribute extends Pivot
|
||||||
{
|
{
|
||||||
public function Article()
|
public function article()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Shop\Article');
|
return $this->belongsTo('App\Models\Shop\Article');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Attribute()
|
public function value()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Shop\ArticleAttribute');
|
return $this->belongsTo('App\Models\Shop\ArticleAttribute');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
17
app/Models/Shop/ArticleAttributeFamily.php
Normal file
17
app/Models/Shop/ArticleAttributeFamily.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Shop;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ArticleAttributeFamily extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
protected $table = 'shop_article_attribute_families';
|
||||||
|
|
||||||
|
public function Values()
|
||||||
|
{
|
||||||
|
return $this->hasMany('App\Models\Shop\ArticleAttributeValue','attribute_family_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
16
app/Models/Shop/ArticleAttributeValue.php
Normal file
16
app/Models/Shop/ArticleAttributeValue.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Shop;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ArticleAttributeValue extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
protected $table = 'shop_article_attribute_values';
|
||||||
|
|
||||||
|
public function attribute_family()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('App\Models\Shop\ArticleAttributeFamily');
|
||||||
|
}
|
||||||
|
}
|
||||||
4
routes/Shop/Admin/ArticleAttributeValues.php
Normal file
4
routes/Shop/Admin/ArticleAttributeValues.php
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Route::resource('ArticleAttributeValues', 'ArticleAttributeValueController');
|
||||||
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
Route::middleware('auth')->prefix('Admin')->namespace('Admin')->name('Admin.')->group(function () {
|
Route::middleware('auth')->prefix('Admin')->namespace('Admin')->name('Admin.')->group(function () {
|
||||||
Route::get('dashboard', 'DashboardController@index')->name('dashboard');
|
Route::get('dashboard', 'DashboardController@index')->name('dashboard');
|
||||||
include( __DIR__ . '/ArticleAttributeFamilies.php');
|
include( __DIR__ . '/ArticleAttributeFamilies.php');
|
||||||
|
include( __DIR__ . '/ArticleAttributeValues.php');
|
||||||
include( __DIR__ . '/ArticleAttributes.php');
|
include( __DIR__ . '/ArticleAttributes.php');
|
||||||
include( __DIR__ . '/ArticleFamilies.php');
|
include( __DIR__ . '/ArticleFamilies.php');
|
||||||
include( __DIR__ . '/ArticlePrices.php');
|
include( __DIR__ . '/ArticlePrices.php');
|
||||||
|
|||||||
Reference in New Issue
Block a user