Attributes
This commit is contained in:
@@ -10,8 +10,9 @@ class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticleAttributeFamilies';
|
||||
|
||||
public function query(ArticleFamily $model)
|
||||
public function query(ArticleAttributeFamily $model)
|
||||
{
|
||||
$model = $model::withCount(['values']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -19,6 +20,7 @@ class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('values_count')->title('Nb valeurs')->searchable(false),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
|
||||
@@ -10,15 +10,17 @@ class ArticleAttributeValuesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'ArticleAttributeValues';
|
||||
|
||||
public function query(ArticleFamily $model)
|
||||
public function query(ArticleAttributeValue $model)
|
||||
{
|
||||
$model = $model::with(['attribute_family']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('attribute_family.name')->title('Famille d\'attributs'),
|
||||
Column::make('value'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace App\Http\Controllers\Shop\Admin;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Model\Shop\ArticleAttributeFamily;
|
||||
use App\Repositories\Shop\ArticleAttributeFamilies;
|
||||
use App\DataTables\Shop\ArticleAttributeFamiliesDataTable;
|
||||
|
||||
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);
|
||||
$menu->addTo('shop', 'Familles d\'articles', [ 'route' => 'Shop.Admin.ArticleFamilies.index', 'permission' => 'backend_access' ])
|
||||
->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);
|
||||
$menu->addTo('shop', 'Attributs d\'articles', [ 'route' => 'Shop.Admin.ArticleAttributes.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributes.*'])->order(5);
|
||||
$menu->addTo('shop', 'Attributs', [ 'route' => 'Shop.Admin.ArticleAttributeValues.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.ArticleAttributeValues.*'])->order(5);
|
||||
|
||||
$menu->addTo('shop', 'Commandes', [ 'route' => 'Shop.Admin.Orders.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Shop.Admin.Orders.*'])->order(6);
|
||||
|
||||
@@ -30,7 +30,7 @@ class Article extends Model
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
||||
}
|
||||
|
||||
public function ProductAttributes()
|
||||
public function ArticleAttributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||
|
||||
class ArticleAttribute extends Pivot
|
||||
{
|
||||
public function Article()
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function Attribute()
|
||||
public function value()
|
||||
{
|
||||
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::get('dashboard', 'DashboardController@index')->name('dashboard');
|
||||
include( __DIR__ . '/ArticleAttributeFamilies.php');
|
||||
include( __DIR__ . '/ArticleAttributeValues.php');
|
||||
include( __DIR__ . '/ArticleAttributes.php');
|
||||
include( __DIR__ . '/ArticleFamilies.php');
|
||||
include( __DIR__ . '/ArticlePrices.php');
|
||||
|
||||
Reference in New Issue
Block a user