|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace App\Nova; |
| 4 | + |
| 5 | +use App\Helpers\Helper; |
| 6 | +use Illuminate\Http\Request; |
| 7 | +use Laravel\Nova\Fields\BelongsTo; |
| 8 | +use Laravel\Nova\Fields\Date; |
| 9 | +use Laravel\Nova\Fields\ID; |
| 10 | +use Laravel\Nova\Fields\Select; |
| 11 | +use Laravel\Nova\Fields\Text; |
| 12 | +use Laravel\Nova\Http\Requests\NovaRequest; |
| 13 | + |
| 14 | +class DataPegawai extends Resource |
| 15 | +{ |
| 16 | + /** |
| 17 | + * The model the resource corresponds to. |
| 18 | + * |
| 19 | + * @var class-string<\App\Models\DataPegawai> |
| 20 | + */ |
| 21 | + public static $model = \App\Models\DataPegawai::class; |
| 22 | + |
| 23 | + public static function label() |
| 24 | + { |
| 25 | + return 'Data Pegawai'; |
| 26 | + } |
| 27 | + |
| 28 | + public static $with = ['user', 'unitKerja']; |
| 29 | + public static $displayInNavigation = false; |
| 30 | + /** |
| 31 | + * The single value that should be used to represent the resource when being displayed. |
| 32 | + * |
| 33 | + * @var string |
| 34 | + */ |
| 35 | + public static $title = 'user_id'; |
| 36 | + |
| 37 | + /** |
| 38 | + * The columns that should be searched. |
| 39 | + * |
| 40 | + * @var array |
| 41 | + */ |
| 42 | + public static $search = [ |
| 43 | + 'user_id', |
| 44 | + ]; |
| 45 | + |
| 46 | + /** |
| 47 | + * Get the fields displayed by the resource. |
| 48 | + * |
| 49 | + * @param \Laravel\Nova\Http\Requests\NovaRequest $request |
| 50 | + * @return array |
| 51 | + */ |
| 52 | + public function fields(NovaRequest $request) |
| 53 | + { |
| 54 | + return [ |
| 55 | + Date::make('Tanggal Perubahan', 'tanggal') |
| 56 | + ->rules('required') |
| 57 | + ->displayUsing(fn ($tanggal) => Helper::terbilangTanggal($tanggal)), |
| 58 | + Select::make('Golongan') |
| 59 | + ->options(Helper::$golongan) |
| 60 | + ->rules('required') |
| 61 | + ->searchable(), |
| 62 | + Text::make('Pangkat') |
| 63 | + ->hideWhenCreating() |
| 64 | + ->hideWhenUpdating(), |
| 65 | + Text::make('Jabatan') |
| 66 | + ->rules('required'), |
| 67 | + BelongsTo::make('Unit Kerja') |
| 68 | + ->filterable() |
| 69 | + ->rules('required'), |
| 70 | + ]; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Get the cards available for the request. |
| 75 | + * |
| 76 | + * @param \Laravel\Nova\Http\Requests\NovaRequest $request |
| 77 | + * @return array |
| 78 | + */ |
| 79 | + public function cards(NovaRequest $request) |
| 80 | + { |
| 81 | + return []; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Get the filters available for the resource. |
| 86 | + * |
| 87 | + * @param \Laravel\Nova\Http\Requests\NovaRequest $request |
| 88 | + * @return array |
| 89 | + */ |
| 90 | + public function filters(NovaRequest $request) |
| 91 | + { |
| 92 | + return []; |
| 93 | + } |
| 94 | + |
| 95 | + /** |
| 96 | + * Get the lenses available for the resource. |
| 97 | + * |
| 98 | + * @param \Laravel\Nova\Http\Requests\NovaRequest $request |
| 99 | + * @return array |
| 100 | + */ |
| 101 | + public function lenses(NovaRequest $request) |
| 102 | + { |
| 103 | + return []; |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Get the actions available for the resource. |
| 108 | + * |
| 109 | + * @param \Laravel\Nova\Http\Requests\NovaRequest $request |
| 110 | + * @return array |
| 111 | + */ |
| 112 | + public function actions(NovaRequest $request) |
| 113 | + { |
| 114 | + return []; |
| 115 | + } |
| 116 | +} |
0 commit comments