Skip to content

Commit

Permalink
Merge pull request #60 from Jaspur/master
Browse files Browse the repository at this point in the history
Also options view translatable
  • Loading branch information
toonvandenbos authored Feb 28, 2020
2 parents 98d2f02 + e60a621 commit a5206e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/Pages/OptionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Whitecube\NovaPage\Pages;

use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\Heading;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\DateTime;

class OptionResource extends StaticResource
{
Expand Down Expand Up @@ -46,7 +46,7 @@ public static function singularLabel()
protected function getFormIntroductionFields()
{
return [
Heading::make($this->getFormattedName())
Heading::make($this->getFormattedName()),
];
}

Expand All @@ -58,24 +58,25 @@ protected function getFormIntroductionFields()
protected function getIndexTableFields()
{
return [
Text::make('Name', function() {
Text::make(__('Name'), 'name', function () {
return $this->getFormattedName();
})->sortable(),

DateTime::make('Last updated on', function() {
DateTime::make(__('Last updated on'), 'last_updated_on', function () {
$updated_at = $this->getDate('updated_at');
return $updated_at ? $updated_at->toDateTimeString() : null;
})->format(config('novapage.date_format'))->sortable()
})->format(config('novapage.date_format'))->sortable(),
];
}

/**
* Format template class name for display
*
*
* @return string
*/
public function getFormattedName() {
public function getFormattedName()
{
return ucfirst(preg_replace('/(?<!\ )[A-Z]/', ' $0', $this->getName()));
}

}
}
6 changes: 3 additions & 3 deletions src/Pages/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ protected function getBaseAttributeFields()
protected function getIndexTableFields()
{
return [
Text::make(__('Name'), function () {
Text::make(__('Name'), 'name', function () {
return $this->getName();
})->sortable(),

Text::make(__('Title'), function () {
Text::make(__('Title'), 'title', function () {
return $this->getTitle();
})->sortable(),

DateTime::make(__('Last updated on'), function () {
DateTime::make(__('Last updated on'), 'last_updated_on', function () {
$updated_at = $this->getDate('updated_at');
return $updated_at ? $updated_at->toDateTimeString() : null;
})->format(config('novapage.date_format'))->sortable(),
Expand Down

0 comments on commit a5206e5

Please sign in to comment.