|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace JustBetter\AkeneoProductsNova\Nova; |
| 4 | + |
| 5 | +use Illuminate\Http\Request; |
| 6 | +use JustBetter\AkeneoProducts\Models\ProductModel; |
| 7 | +use Laravel\Nova\Fields\Boolean; |
| 8 | +use Laravel\Nova\Fields\Code; |
| 9 | +use Laravel\Nova\Fields\DateTime; |
| 10 | +use Laravel\Nova\Fields\Text; |
| 11 | +use Laravel\Nova\Http\Requests\NovaRequest; |
| 12 | +use Laravel\Nova\Resource; |
| 13 | + |
| 14 | +class ProductModelResource extends Resource |
| 15 | +{ |
| 16 | + public static $model = ProductModel::class; |
| 17 | + |
| 18 | + public static $title = 'code'; |
| 19 | + |
| 20 | + public static $group = 'Akeneo Products'; |
| 21 | + |
| 22 | + public static $search = [ |
| 23 | + 'code', |
| 24 | + ]; |
| 25 | + |
| 26 | + public static function label(): string |
| 27 | + { |
| 28 | + return __('Product Models'); |
| 29 | + } |
| 30 | + |
| 31 | + public static function uriKey(): string |
| 32 | + { |
| 33 | + return 'akeneo-products-product-models'; |
| 34 | + } |
| 35 | + |
| 36 | + public function fields(NovaRequest $request): array |
| 37 | + { |
| 38 | + return [ |
| 39 | + Text::make(__('Code'), 'code') |
| 40 | + ->sortable(), |
| 41 | + |
| 42 | + Boolean::make(__('Synchronize'), 'synchronize') |
| 43 | + ->help(__('Determines if the product model should be synchronized.')) |
| 44 | + ->sortable(), |
| 45 | + |
| 46 | + Boolean::make(__('Retrieve'), 'retrieve') |
| 47 | + ->help(__('Determines if the product model should be retrieved.')) |
| 48 | + ->sortable(), |
| 49 | + |
| 50 | + Boolean::make(__('Update'), 'update') |
| 51 | + ->help(__('Determines if the product model should be updated.')) |
| 52 | + ->sortable(), |
| 53 | + |
| 54 | + Code::make(__('Data'), 'data') |
| 55 | + ->json(), |
| 56 | + |
| 57 | + DateTime::make(__('Retrieved At'), 'retrieved_at') |
| 58 | + ->help(__('Last date the product model has been retrieved.')) |
| 59 | + ->sortable(), |
| 60 | + |
| 61 | + DateTime::make(__('Updated At'), 'modified_at') |
| 62 | + ->help(__('Last date the product model has been updated.')) |
| 63 | + ->sortable(), |
| 64 | + ]; |
| 65 | + } |
| 66 | + |
| 67 | + public function filters(NovaRequest $request): array |
| 68 | + { |
| 69 | + return [ |
| 70 | + Filters\RetrieveFilter::make(), |
| 71 | + Filters\UpdateFilter::make(), |
| 72 | + Filters\SynchronizeFilter::make(), |
| 73 | + ]; |
| 74 | + } |
| 75 | + |
| 76 | + public function actions(NovaRequest $request): array |
| 77 | + { |
| 78 | + return [ |
| 79 | + Actions\ProductModel\RetrieveAction::make(), |
| 80 | + Actions\ProductModel\UpdateAction::make(), |
| 81 | + Actions\ProductModel\ResetAction::make(), |
| 82 | + ]; |
| 83 | + } |
| 84 | + |
| 85 | + public static function authorizedToCreate(Request $request): bool |
| 86 | + { |
| 87 | + return false; |
| 88 | + } |
| 89 | + |
| 90 | + public function authorizedToUpdate(Request $request): bool |
| 91 | + { |
| 92 | + return false; |
| 93 | + } |
| 94 | + |
| 95 | + public function authorizedToReplicate(Request $request): bool |
| 96 | + { |
| 97 | + return false; |
| 98 | + } |
| 99 | +} |
0 commit comments