This commit is contained in:
2025-09-25 03:03:31 +05:00
commit ae480cf2f6
2768 changed files with 1485826 additions and 0 deletions

View File

@@ -0,0 +1,166 @@
<?php
namespace App\Nova\Resources\Ecommerce\Product\Attribute;
use App\Models\Ecommerce\Product\Property\Attribute as AttributeModel;
use App\Nova\Resource;
use App\Nova\Resources\Ecommerce\Product\Category\Category;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Trix;
use Laravel\Nova\Http\Requests\NovaRequest;
use NovaAttachMany\AttachMany;
use Outl1ne\MultiselectField\Multiselect;
use Outl1ne\NovaSortable\Traits\HasSortableRows;
use Trin4ik\NovaSwitcher\NovaSwitcher;
class Attribute extends Resource
{
/**
* Sortable behavior
*/
use HasSortableRows;
/**
* The model the resource corresponds to.
*
* @var class-string<AttributeModel>
*/
public static $model = AttributeModel::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'name';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'name',
];
/**
* Get the displayable label of the resource.
*/
public static function label(): string
{
return __('Attributes');
}
/**
* Get the displayable singular label of the resource.
*/
public static function singularLabel(): string
{
return __('Attribute');
}
/**
* Get the fields displayed by the resource.
*/
public function fields(NovaRequest $request): array
{
return [
ID::make()->sortable(),
Text::make(__('Name'), 'name')
->rules('required', 'string')
->translatable(),
Select::make(__('Type'), 'type')
->displayUsingLabels()
->searchable()
->default(AttributeModel::typesFields()['text'])
->options(AttributeModel::typesFields())
->rules('required'),
Trix::make(__('Description'), 'description')
->translatable(),
NovaSwitcher::make(__('Is enabled'), 'is_visible')
->default(true)
->canSeeWhen('systemUser', $this),
NovaSwitcher::make(__('Is required'), 'is_required')
->default(true)
->canSeeWhen('systemUser', $this),
NovaSwitcher::make(__('Is searchable'), 'is_searchable')
->default(false)
->canSeeWhen('systemUser', $this),
NovaSwitcher::make(__('Is filterable'), 'is_filterable')
->default(false)
->canSeeWhen('systemUser', $this),
Boolean::make(__('Is enabled'), 'is_visible')
->canSeeWhen('vendor', $this),
Boolean::make(__('Is required'), 'is_required')
->canSeeWhen('vendor', $this),
Boolean::make(__('Is searchable'), 'is_searchable')
->canSeeWhen('vendor', $this),
Boolean::make(__('Is filterable'), 'is_filterable')
->canSeeWhen('vendor', $this),
AttachMany::make(__('Categories'), 'categories', Category::class),
Multiselect::make(__('Categories'), 'categories')->belongsToMany(Category::class)
->onlyOnDetail(),
HasMany::make(__('Attribute values'), 'values', AttributeValue::class)
->hideFromDetail(function (NovaRequest $request, $resource) {
return $this->type !== 'select';
}),
];
}
/**
* Get the cards available for the request.
*
* @return array
*/
public function cards(NovaRequest $request)
{
return [];
}
/**
* Get the filters available for the resource.
*
* @return array
*/
public function filters(NovaRequest $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* @return array
*/
public function lenses(NovaRequest $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* @return array
*/
public function actions(NovaRequest $request)
{
return [];
}
}

View File

@@ -0,0 +1,129 @@
<?php
namespace App\Nova\Resources\Ecommerce\Product\Attribute;
use App\Models\Ecommerce\Product\Property\AttributeValue as AttributeValueModel;
use App\Nova\Resource;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class AttributeValue extends Resource
{
/**
* The model the resource corresponds to.
*
* @var class-string<AttributeValueModel>
*/
public static $model = AttributeValueModel::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'value';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'id', 'value',
];
/**
* Get the displayable label of the resource.
*/
public static function label(): string
{
return __('Attribute Values');
}
/**
* Get the displayable singular label of the resource.
*/
public static function singularLabel(): string
{
return __('Attribute Value');
}
/**
* Return the location to redirect the user after creation.
*
* @param \Laravel\Nova\Resource $resource
* @return \Laravel\Nova\URL|string
*/
public static function redirectAfterCreate(NovaRequest $request, $resource): string
{
return sprintf('/resources/attributes/%s', $resource->attribute_id);
}
/**
* Return the location to redirect the user after update.
*
* @param \Laravel\Nova\Resource $resource
* @return \Laravel\Nova\URL|string
*/
public static function redirectAfterUpdate(NovaRequest $request, $resource)
{
return sprintf('/resources/attributes/%s', $resource->attribute_id);
}
/**
* Get the fields displayed by the resource.
*
* @return array
*/
public function fields(NovaRequest $request)
{
return [
ID::make()->sortable(),
Text::make(__('Value'), 'value')
->translatable()
->rules('required'),
];
}
/**
* Get the cards available for the request.
*
* @return array
*/
public function cards(NovaRequest $request)
{
return [];
}
/**
* Get the filters available for the resource.
*
* @return array
*/
public function filters(NovaRequest $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* @return array
*/
public function lenses(NovaRequest $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* @return array
*/
public function actions(NovaRequest $request)
{
return [];
}
}