Fix some enhancements & new features
This commit is contained in:
@@ -10,9 +10,9 @@ use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class ParentDataTable extends DataTable
|
||||
{
|
||||
public $rowReorder;
|
||||
public $colReorder; // ['selector' => 'tr']
|
||||
public $fixedColumns; // ['leftColumns' => 1, 'rightColumns' => 1]
|
||||
public $rowReorder; // ['selector' => 'tr']
|
||||
public $colReorder = true;
|
||||
public $fixedColumns = false;
|
||||
|
||||
/**
|
||||
* Build DataTable class.
|
||||
@@ -27,7 +27,7 @@ class ParentDataTable extends DataTable
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
return $this->addButtons($datatables);
|
||||
return $this->addButtons($datatables->setRowId('{{$id}}'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,6 +50,7 @@ class ParentDataTable extends DataTable
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-primary btn-edit mr-2"><i class="fa fa-fw fa-pencil-alt"></i></button>';
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-danger btn-del"><i class="fa fa-fw fa-trash"></i></button>';
|
||||
return $buttons;
|
||||
// return view('components.datatables.buttons.row_action');
|
||||
}
|
||||
|
||||
public function makeColumnButtons()
|
||||
@@ -72,8 +73,7 @@ class ParentDataTable extends DataTable
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Optional method if you want to use html builder.
|
||||
*
|
||||
@@ -126,7 +126,7 @@ class ParentDataTable extends DataTable
|
||||
{
|
||||
$dom = '';
|
||||
// $dom .= $this->getDatatablesHeaderDefault();
|
||||
$dom .= "<'overlay-block'r<t>>";
|
||||
$dom .= "rt";
|
||||
$dom .= $this->getDatatablesFooterDefault();
|
||||
return $dom;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
|
||||
public function query(ArticleAttributeFamily $model)
|
||||
{
|
||||
$model = $model::withCount(['Attributes']);
|
||||
$model = $model::withCount(['values','articles']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('attributes_count')->title('Nb attributs')->searchable(false)->addClass('text-right'),
|
||||
Column::make('values_count')->title('Nb attributs')->searchable(false)->addClass('text-right'),
|
||||
Column::make('articles_count')->title('Nb d\'articles')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class ArticleAttributeValuesDataTable extends DataTable
|
||||
|
||||
public function query(ArticleAttributeValue $model)
|
||||
{
|
||||
$model = $model::with(['ArticleAttributeFamily']);
|
||||
$model = $model::with(['article_attribute_family']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class ArticleAttributeFamilyController extends Controller
|
||||
{
|
||||
public function index(ArticleAttributeFamiliesDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('Shop.Admin.ArticleAttributeFamilies.list');
|
||||
return $dataTable->render('Shop.Admin.ArticleAttributeFamilies.index');
|
||||
}
|
||||
|
||||
public function getDatatable(Request $request)
|
||||
|
||||
@@ -11,40 +11,37 @@ use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||
|
||||
class Article extends Model implements HasMedia
|
||||
{
|
||||
use Categorizable;
|
||||
use Taggable;
|
||||
use HasMediaTrait;
|
||||
use EloquentJoin;
|
||||
use Categorizable, Taggable, HasMediaTrait, EloquentJoin;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_articles';
|
||||
|
||||
public function Family()
|
||||
public function article_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily','article_family_id');
|
||||
return $this->belongsTo('App\Models\Shop\ArticleFamily');
|
||||
}
|
||||
|
||||
public function Inventories()
|
||||
public function attributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\ArticlePrice','App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function inventories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Inventory');
|
||||
}
|
||||
|
||||
public function Prices()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
||||
}
|
||||
|
||||
public function Attributes()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\ArticleAttribute','App\Models\Shop\ArticlePrice');
|
||||
}
|
||||
|
||||
public function InvoiceItems()
|
||||
public function invoiceItems()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\InvoiceItem');
|
||||
}
|
||||
|
||||
public function Product()
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo($this->model, 'model_id');
|
||||
}
|
||||
|
||||
@@ -9,23 +9,28 @@ class ArticleAttribute extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_attributes';
|
||||
|
||||
public function Price()
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function attribute_value()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticlePrice','article_price_id');
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttributeValue');
|
||||
}
|
||||
|
||||
public function Value()
|
||||
public function prices()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttributeValue','attribute_value_id');
|
||||
return $this->hasMany('App\Models\Shop\ArticlePrice');
|
||||
}
|
||||
|
||||
public function scopeByPrice($query, $article_price_id)
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_price_id', $article_price_id);
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByAttribueValue($query, $article_value_id)
|
||||
public function scopeByAttributeValue($query, $id)
|
||||
{
|
||||
return $query->where('article_value_id', $article_value_id);
|
||||
return $query->where('attribute_value_id', $id);
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,23 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class ArticleAttributeFamily extends Model
|
||||
{
|
||||
use HasRelationships;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_attribute_families';
|
||||
|
||||
public function Attributes()
|
||||
public function values()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttributeValue');
|
||||
}
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Shop\ArticleAttribute','App\Models\Shop\ArticleAttributeValue');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,14 +9,24 @@ class ArticleAttributeValue extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_attribute_values';
|
||||
|
||||
public function ArticleAttributeFamily()
|
||||
public function article_attribute_family()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttributeFamily');
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $attribute_family_id)
|
||||
public function attributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute')->groupBy('article_id');
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
{
|
||||
return $query->where('article_attribute_family_id', $attribute_family_id);
|
||||
return $query->where('article_attribute_family_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,12 +9,12 @@ class ArticleCategory extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_categories';
|
||||
|
||||
public function Article()
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function Category()
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Category');
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@ class ArticleFamily extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_families';
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function Articles()
|
||||
public function articles()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
@@ -9,19 +9,14 @@ class ArticlePrice extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_prices';
|
||||
|
||||
public function Article()
|
||||
public function article_attribute()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function article()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\Article');
|
||||
}
|
||||
|
||||
public function ArticleAttributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttribute');
|
||||
}
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('article_id', $id);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user