Skip to content

Commit

Permalink
Create nova resource for key #5
Browse files Browse the repository at this point in the history
  • Loading branch information
drewroberts authored Feb 28, 2021
1 parent b4b03ff commit 4007de4
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/Nova/Key.php
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(),
]);
}
}

0 comments on commit 4007de4

Please sign in to comment.