146 lines
3.2 KiB
PHP
146 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Nova\Resources\Ecommerce\Product\Collection;
|
|
|
|
use App\Models\Ecommerce\Product\Collection\Collection as CollectionModel;
|
|
use App\Nova\Resource;
|
|
use App\Nova\Resources\Ecommerce\Product\Product\Product;
|
|
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
|
|
use Laravel\Nova\Fields\ID;
|
|
use Laravel\Nova\Fields\MorphMany;
|
|
use Laravel\Nova\Fields\Text;
|
|
use Laravel\Nova\Fields\Trix;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
use Outl1ne\NovaSortable\Traits\HasSortableRows;
|
|
use Trin4ik\NovaSwitcher\NovaSwitcher;
|
|
|
|
class Collection extends Resource
|
|
{
|
|
/**
|
|
* Sortable behavior
|
|
*/
|
|
use HasSortableRows;
|
|
|
|
/**
|
|
* The model the resource corresponds to.
|
|
*
|
|
* @var string
|
|
*/
|
|
public static $model = CollectionModel::class;
|
|
|
|
/**
|
|
* The single value that should be used to represent the resource when being displayed.
|
|
*
|
|
* @var string
|
|
*/
|
|
public static $title = 'name';
|
|
|
|
/**
|
|
* The relationships that should be eager loaded on index queries.
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $with = ['media'];
|
|
|
|
/**
|
|
* 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 __('Collections');
|
|
}
|
|
|
|
/**
|
|
* Get the displayable singular label of the resource.
|
|
*/
|
|
public static function singularLabel(): string
|
|
{
|
|
return __('Collection');
|
|
}
|
|
|
|
/**
|
|
* Get the fields displayed by the resource.
|
|
*/
|
|
public function fields(NovaRequest $request): array
|
|
{
|
|
return [
|
|
ID::make()->sortable(),
|
|
|
|
Images::make(__('Image'), 'uploads')
|
|
->conversionOnIndexView('thumb200x200')
|
|
->rules('required')
|
|
->required(),
|
|
|
|
Text::make(__('Name'), 'name')
|
|
->rules('required')
|
|
->translatable(),
|
|
|
|
Trix::make(__('description'), 'description')
|
|
->translatable(),
|
|
|
|
NovaSwitcher::make(__('Active'), 'is_visible')
|
|
->canSeeWhen('systemUser', $this)
|
|
->default(false),
|
|
|
|
Text::make(__('SEO title'), 'seo_title')->hideFromIndex(),
|
|
Text::make(__('SEO description'), 'seo_description')->hideFromIndex(),
|
|
|
|
MorphMany::make('Products', 'products', Product::class),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 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 [];
|
|
}
|
|
|
|
public static function canSort(NovaRequest $request, $resource): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|