first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace Modules\Attribute\Admin;
use Modules\Admin\Ui\Tab;
use Modules\Admin\Ui\Tabs;
class AttributeSetTabs extends Tabs
{
public function make()
{
$this->group('attribute_set_information', trans('attribute::attribute_sets.tabs.group.attribute_set_information'))
->active()
->add($this->general());
}
private function general()
{
return tap(new Tab('general', trans('attribute::attribute_sets.tabs.general')), function (Tab $tab) {
$tab->active();
$tab->fields('name');
$tab->view('attribute::admin.attribute_sets.tabs.general');
});
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Modules\Attribute\Admin;
use Modules\Admin\Ui\AdminTable;
class AttributeTable extends AdminTable
{
/**
* Make table response for the resource.
*
* @return \Illuminate\Http\JsonResponse
*/
public function make()
{
return $this->newTable()
->addColumn('attribute_set', function ($attribute) {
return $attribute->attributeSet->name;
})
->addColumn('is_filterable', function ($attribute) {
return $attribute->is_filterable
? trans('attribute::admin.table.yes')
: trans('attribute::admin.table.no');
});
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Modules\Attribute\Admin;
use Modules\Admin\Ui\Tab;
use Modules\Admin\Ui\Tabs;
use Modules\Category\Entities\Category;
use Modules\Attribute\Entities\AttributeSet;
class AttributeTabs extends Tabs
{
public function make()
{
$this->group('attribute_set_information', trans('attribute::admin.tabs.group.attribute_information'))
->active()
->add($this->general())
->add($this->values());
}
private function general()
{
return tap(new Tab('general', trans('attribute::admin.tabs.general')), function (Tab $tab) {
$tab->active();
$tab->weight(5);
$tab->fields(['attribute_set_id', 'name', 'slug']);
$tab->view('attribute::admin.attributes.tabs.general', [
'attributeSets' => $this->getAttributeSets(),
'categories' => Category::treeList(),
]);
});
}
private function getAttributeSets()
{
return AttributeSet::all()->sortBy('name')->pluck('name', 'id')
->prepend(trans('admin::admin.form.please_select'), '');
}
private function values()
{
return tap(new Tab('values', trans('attribute::admin.tabs.values')), function (Tab $tab) {
$tab->weight(10);
$tab->view('attribute::admin.attributes.tabs.values');
});
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Modules\Attribute\Admin;
use Modules\Admin\Ui\Tab;
use Modules\Admin\Ui\Tabs;
use Modules\Attribute\Entities\Attribute;
use Modules\Attribute\Entities\AttributeSet;
class ProductTabsExtender
{
public function extend(Tabs $tabs)
{
$tabs->group('advanced_information')
->add($this->attributes());
}
private function attributes()
{
if (! auth()->user()->hasAccess(['admin.attributes.index'])) {
return;
}
return tap(new Tab('attributes', trans('attribute::admin.tabs.product.attributes')), function (Tab $tab) {
$tab->weight(30);
$tab->fields(['attributes.*.attribute_id', 'attributes.*.values']);
$tab->view(function ($data) {
return view('attribute::admin.products.tabs.attributes', [
'productAttributes' => $this->getProductAttributes($data['product']),
'attributeSets' => $this->getAttributeSets(),
]);
});
});
}
private function getProductAttributes($product)
{
$old = old('attributes');
if (is_null($old)) {
return $product->load('attributes')->attributes;
}
return $this->getOldAttributes($old);
}
public function getOldAttributes($old)
{
return Attribute::with(['values' => function ($query) use ($old) {
$query->whereIn('id', array_flatten(array_pluck($old, 'values')));
}])
->whereIn('id', array_pluck($old, 'attribute_id'))
->get();
}
private function getAttributeSets()
{
return AttributeSet::with('attributes.values')->get()->sortBy('name');
}
}