diff --git a/app/Http/Livewire/Tables/BookCaseTable.php b/app/Http/Livewire/Tables/BookCaseTable.php index 00eb53a0..4555d942 100644 --- a/app/Http/Livewire/Tables/BookCaseTable.php +++ b/app/Http/Livewire/Tables/BookCaseTable.php @@ -68,6 +68,22 @@ class BookCaseTable extends DataTableComponent Column::make("Adresse", "address") ->sortable() ->searchable(), + Column::make("Bitcoin-Bücher") + ->label( + fn( + $row, + Column $column + ) => $row->orangePills->sum('amount') + ), + Column::make("Letzter Input") + ->label( + fn( + $row, + Column $column + ) => $row->orangePills() + ->latest() + ->first()?->date->asDate() + ), Column::make("Link") ->label( fn( diff --git a/app/Models/BookCase.php b/app/Models/BookCase.php index 3d1430f5..7919a2f1 100644 --- a/app/Models/BookCase.php +++ b/app/Models/BookCase.php @@ -60,12 +60,12 @@ class BookCase extends Model implements HasMedia } /* - * This string will be used in notifications on what a new comment - * was made. - */ + * This string will be used in notifications on what a new comment + * was made. + */ public function commentableName(): string { - // + return __('Bookcase'); } /* @@ -74,6 +74,6 @@ class BookCase extends Model implements HasMedia */ public function commentUrl(): string { - + return url()->route('comment.bookcase', ['bookCase' => $this->id]); } } diff --git a/app/Nova/BookCase.php b/app/Nova/BookCase.php index 1786a27b..03b8bd4f 100644 --- a/app/Nova/BookCase.php +++ b/app/Nova/BookCase.php @@ -2,58 +2,63 @@ namespace App\Nova; -use Laravel\Nova\Fields\ID; use Illuminate\Http\Request; -use Laravel\Nova\Fields\Code; -use Laravel\Nova\Fields\Text; -use Laravel\Nova\Fields\Number; use Laravel\Nova\Fields\Boolean; +use Laravel\Nova\Fields\Code; +use Laravel\Nova\Fields\HasMany; +use Laravel\Nova\Fields\ID; +use Laravel\Nova\Fields\MorphMany; +use Laravel\Nova\Fields\Number; +use Laravel\Nova\Fields\Text; class BookCase extends Resource { /** * The model the resource corresponds to. - * * @var string */ public static $model = \App\Models\BookCase::class; /** * The single value that should be used to represent the resource when being displayed. - * * @var string */ - public static $title = 'id'; + public static $title = 'title'; /** * The columns that should be searched. - * * @var array */ public static $search = [ 'id', + 'title', ]; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request + * * @return array */ public function fields(Request $request) { return [ - ID::make()->sortable(), + ID::make() + ->sortable(), Text::make('Title') ->rules('required', 'string'), - Number::make('Lat') - ->rules('required', 'numeric'), + Number::make('Latitude') + ->rules('required', 'numeric') + ->step(0.000001) + ->hideFromIndex(), - Code::make('Lon') - ->rules('required', 'json') - ->json(), + Number::make('Longitude') + ->rules('required', 'numeric') + ->step(0.000001) + ->hideFromIndex(), Text::make('Address') ->rules('required', 'string'), @@ -62,35 +67,47 @@ class BookCase extends Resource ->rules('required', 'string'), Text::make('Open') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Text::make('Comment') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Text::make('Contact') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Text::make('Bcz') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Boolean::make('Digital') - ->rules('required'), + ->rules('required') + ->hideFromIndex(), Text::make('Icontype') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Boolean::make('Deactivated') - ->rules('required'), + ->rules('required'), Text::make('Deactreason') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Text::make('Entrytype') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), Text::make('Homepage') - ->rules('required', 'string'), + ->rules('required', 'string') + ->hideFromIndex(), + HasMany::make('OrangePills'), + + MorphMany::make('Comments'), ]; } @@ -99,6 +116,7 @@ class BookCase extends Resource * Get the cards available for the request. * * @param \Illuminate\Http\Request $request + * * @return array */ public function cards(Request $request) @@ -110,6 +128,7 @@ class BookCase extends Resource * Get the filters available for the resource. * * @param \Illuminate\Http\Request $request + * * @return array */ public function filters(Request $request) @@ -121,6 +140,7 @@ class BookCase extends Resource * Get the lenses available for the resource. * * @param \Illuminate\Http\Request $request + * * @return array */ public function lenses(Request $request) @@ -132,6 +152,7 @@ class BookCase extends Resource * Get the actions available for the resource. * * @param \Illuminate\Http\Request $request + * * @return array */ public function actions(Request $request) diff --git a/app/Nova/Comment.php b/app/Nova/Comment.php new file mode 100644 index 00000000..f27fb5ad --- /dev/null +++ b/app/Nova/Comment.php @@ -0,0 +1,53 @@ +topLevel()->commentable?->commentableName() ?? 'Deleted...'; + })->readonly(), + + MorphTo::make('Commentator')->types([ + User::class, + ]), + + Markdown::make('Original text'), + + Text::make('', function (CommentModel $comment) { + if (! $url = $comment?->commentUrl()) { + return ''; + } + + return "Show"; + + })->asHtml(), + + Text::make('status', function(CommentModel $comment) { + if ($comment->isApproved()) { + return "
Approved
"; + } + + return "
Pending
"; + })->asHtml(), + + DateTime::make('Created at'), + ]; + } +} diff --git a/app/Nova/OrangePill.php b/app/Nova/OrangePill.php index 6cb883cd..34d6861a 100644 --- a/app/Nova/OrangePill.php +++ b/app/Nova/OrangePill.php @@ -17,6 +17,11 @@ class OrangePill extends Resource */ public static $model = \App\Models\OrangePill::class; + public static function label() + { + return 'Inputs'; + } + /** * The single value that should be used to represent the resource when being displayed. * diff --git a/app/Policies/BookCasePolicy.php b/app/Policies/BookCasePolicy.php new file mode 100644 index 00000000..95d2fae9 --- /dev/null +++ b/app/Policies/BookCasePolicy.php @@ -0,0 +1,101 @@ +icon('microphone') ->collapsable(), + MenuSection::make('Books', [ + MenuItem::resource(BookCase::class), + MenuItem::resource(OrangePill::class), + ]) + ->icon('book-open') + ->collapsable(), + + MenuSection::make('Comments', [ + MenuItem::resource(Comment::class), + ]) + ->icon('chat') + ->collapsable(), + MenuSection::make('Admin', [ MenuItem::resource(Category::class), MenuItem::resource(Country::class), diff --git a/lang/de.json b/lang/de.json index 97405972..196aba7d 100644 --- a/lang/de.json +++ b/lang/de.json @@ -1,6 +1,7 @@ { "Orange Pill Book Case": "Wie viele Bitcoin-Bücher hast du hinzu gefügt?", "Book": "Buch", + "Bookcase": "Bücher-Schrank", "Article": "Artikel", "Markdown Article": "Interner Artikel", "Youtube Video": "Youtube Video", diff --git a/resources/views/navigation-menu.blade.php b/resources/views/navigation-menu.blade.php index 86c218c4..b5ffd43a 100644 --- a/resources/views/navigation-menu.blade.php +++ b/resources/views/navigation-menu.blade.php @@ -24,6 +24,9 @@ {{ __('Inhalte eintragen') }} + + {{ __('Bücher-Schränke verwalten') }} + {{ __('Mein Profil') }}