Add plus on products
This commit is contained in:
@@ -4,16 +4,16 @@ 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;
|
||||
use App\Models\Shop\Producer;
|
||||
use App\Repositories\Shop\Producers;
|
||||
|
||||
class MerchandisesDataTable extends DataTable
|
||||
class ProducersDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'merchandises';
|
||||
public $model_name = 'producers';
|
||||
|
||||
public function query(Merchandise $model)
|
||||
public function query(Producer $model)
|
||||
{
|
||||
$model = $model::with(['image', 'tags'])->withCount(['Articles', 'tags', 'images']);
|
||||
$model = $model::with(['image', 'tags'])->withCount(['Merchandises', 'tags', 'images']);
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ class MerchandisesDataTable extends DataTable
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('thumb', function (Merchandise $merchandise) {
|
||||
return Merchandises::getThumb($merchandise->image);
|
||||
->editColumn('thumb', function (Producer $producer) {
|
||||
return $producer->image ? Producers::getThumb($producer->image) : '';
|
||||
})
|
||||
->editColumn('tags2', function (Merchandise $merchandise) {
|
||||
->editColumn('tags2', function (Producer $producer) {
|
||||
$html = '';
|
||||
foreach ($merchandise->tags as $tag) {
|
||||
foreach ($producer->tags as $tag) {
|
||||
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
|
||||
}
|
||||
return $html;
|
||||
@@ -42,7 +42,7 @@ class MerchandisesDataTable extends DataTable
|
||||
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('merchandises_count')->title('#Mar')->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(),
|
||||
|
||||
Reference in New Issue
Block a user