-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4b03ff
commit 4007de4
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tipoff\GoogleApi\Nova; | ||
|
||
use Illuminate\Http\Request; | ||
use Laravel\Nova\Fields\BelongsTo; | ||
use Laravel\Nova\Fields\DateTime; | ||
use Laravel\Nova\Fields\HasMany; | ||
use Laravel\Nova\Fields\ID; | ||
use Laravel\Nova\Fields\Markdown; | ||
use Laravel\Nova\Fields\Slug; | ||
use Laravel\Nova\Fields\Text; | ||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
use Laravel\Nova\Panel; | ||
use Tipoff\Support\Nova\BaseResource; | ||
|
||
class Key extends BaseResource | ||
{ | ||
public static $model = \Tipoff\GoogleApi\Models\Key::class; | ||
|
||
public static $orderBy = ['id' => 'asc']; | ||
|
||
public static $title = 'name'; | ||
|
||
public static $search = [ | ||
'id', | ||
]; | ||
|
||
public static $group = 'Z - Admin'; | ||
|
||
public function fieldsForIndex(NovaRequest $request) | ||
{ | ||
return array_filter([ | ||
ID::make()->sortable(), | ||
Text::make('Name')->sortable(), | ||
]); | ||
} | ||
|
||
public function fields(Request $request) | ||
{ | ||
return array_filter([ | ||
Text::make('Name')->required(), | ||
|
||
new Panel('Data Fields', $this->dataFields()), | ||
]); | ||
} | ||
|
||
protected function dataFields(): array | ||
{ | ||
return array_filter([ | ||
ID::make(), | ||
nova('user') ? BelongsTo::make('Created By', 'creator', nova('user'))->exceptOnForms() : null, | ||
DateTime::make('Created At')->exceptOnForms(), | ||
nova('user') ? BelongsTo::make('Updated By', 'updater', nova('user'))->exceptOnForms() : null, | ||
DateTime::make('Updated At')->exceptOnForms(), | ||
]); | ||
} | ||
} |