From 090d4714dc7f70c6e4288fd30a559a188377cdeb Mon Sep 17 00:00:00 2001 From: CaddyDz Date: Tue, 9 Jun 2020 19:59:57 +0100 Subject: [PATCH 1/9] Made navigation links on the side bar localizable Laravel reads config files before the Translator class is initialized, so config options must be localized on the view level Signed-off-by: CaddyDz --- resources/views/navigation.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/navigation.blade.php b/resources/views/navigation.blade.php index 7bd2bd1..a7f4ce4 100644 --- a/resources/views/navigation.blade.php +++ b/resources/views/navigation.blade.php @@ -5,7 +5,7 @@ } }" class="cursor-pointer flex items-center font-normal dim text-white mb-6 text-base no-underline"> - {{ config('novapage.labels.pages') }} + {{ __(config('novapage.labels.pages')) }} - {{ config('novapage.labels.options') }} + {{ __(config('novapage.labels.options')) }} From cdbade75fb494365ab995f73f1542f280927f341 Mon Sep 17 00:00:00 2001 From: CaddyDz Date: Wed, 10 Jun 2020 13:03:00 +0100 Subject: [PATCH 2/9] Indicate translation keys option Signed-off-by: CaddyDz --- src/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config.php b/src/config.php index 02802ca..c88a47d 100644 --- a/src/config.php +++ b/src/config.php @@ -8,6 +8,7 @@ |-------------------------------------------------------------------------- | | How should we name the links in Laravel Nova's sidebar? + | Note that translation keys can be used instead of plain text. | */ 'labels' => [ From 58fd3106d4c7d4115fc6c30b9b8b00c76e5d9cb0 Mon Sep 17 00:00:00 2001 From: Adrien Leloup Date: Wed, 10 Jun 2020 14:06:01 +0200 Subject: [PATCH 3/9] Changed tab indent to spaces indent --- src/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.php b/src/config.php index c88a47d..93aaa3b 100644 --- a/src/config.php +++ b/src/config.php @@ -8,7 +8,7 @@ |-------------------------------------------------------------------------- | | How should we name the links in Laravel Nova's sidebar? - | Note that translation keys can be used instead of plain text. + | Note that translation keys can be used instead of plain text. | */ 'labels' => [ From 51111cbc9a5e74bd9d889f1ec75331da96fc5be2 Mon Sep 17 00:00:00 2001 From: Moshe Date: Fri, 12 Jun 2020 02:38:02 +0300 Subject: [PATCH 4/9] Fixed deletion of files and images. --- routes/api.php | 4 ++ .../Option/FieldDestroyController.php | 15 ++++++ .../Page/FieldDestroyController.php | 15 ++++++ .../ResourceFieldDestroyController.php | 46 +++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 src/Http/Controllers/Option/FieldDestroyController.php create mode 100644 src/Http/Controllers/Page/FieldDestroyController.php create mode 100644 src/Http/Controllers/ResourceFieldDestroyController.php diff --git a/routes/api.php b/routes/api.php index d53cf87..fba560f 100644 --- a/routes/api.php +++ b/routes/api.php @@ -8,9 +8,11 @@ use Whitecube\NovaPage\Http\Controllers\Page\IndexController as PageResourceIndexController; use Whitecube\NovaPage\Http\Controllers\Page\CountController as PageResourceCountController; use Whitecube\NovaPage\Http\Controllers\Page\UpdateController as PageResourceUpdateController; +use Whitecube\NovaPage\Http\Controllers\Page\FieldDestroyController as PageFieldDestroyController; use Whitecube\NovaPage\Http\Controllers\Option\IndexController as OptionResourceIndexController; use Whitecube\NovaPage\Http\Controllers\Option\CountController as OptionResourceCountController; use Whitecube\NovaPage\Http\Controllers\Option\UpdateController as OptionResourceUpdateController; +use Whitecube\NovaPage\Http\Controllers\Option\FieldDestroyController as OptionFieldDestroyController; /* |-------------------------------------------------------------------------- @@ -43,7 +45,9 @@ Route::get('/nova-api/nova-page', PageResourceIndexController::class . '@handle'); Route::get('/nova-api/nova-page/count', PageResourceCountController::class . '@show'); Route::put('/nova-api/nova-page/{resourceId}', PageResourceUpdateController::class . '@handle'); +Route::delete('/nova-api/nova-page/{resourceId}/field/{field}', PageFieldDestroyController::class . '@handle'); Route::get('/nova-api/nova-option', OptionResourceIndexController::class . '@handle'); Route::get('/nova-api/nova-option/count', OptionResourceCountController::class . '@show'); Route::put('/nova-api/nova-option/{resourceId}', OptionResourceUpdateController::class . '@handle'); +Route::delete('/nova-api/nova-page/{resourceId}/field/{field}', OptionFieldDestroyController::class . '@handle'); \ No newline at end of file diff --git a/src/Http/Controllers/Option/FieldDestroyController.php b/src/Http/Controllers/Option/FieldDestroyController.php new file mode 100644 index 0000000..e4bf540 --- /dev/null +++ b/src/Http/Controllers/Option/FieldDestroyController.php @@ -0,0 +1,15 @@ +getRouteResolver()); + $route->setParameter('resource', $this->resourceName); + $request->findResourceOrFail()->authorizeToUpdate($request); + + $resource = $request->newResource(); + $field = $resource->updateFields($request)->findFieldByAttribute($request->field); + + if (!($field instanceof File)) { + abort(404); + } + + $template = $request->findModelQuery()->firstOrFail(); + + DeleteField::forRequest( + $request, + $field, + $template + )->save(); + } +} From e55d01fab8963a3e16e3ff1b3fdf034f61554392 Mon Sep 17 00:00:00 2001 From: Moshe Revah Date: Fri, 12 Jun 2020 03:44:53 +0300 Subject: [PATCH 5/9] Tiny fix. --- routes/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.php b/routes/api.php index fba560f..14ff18e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -50,4 +50,4 @@ Route::get('/nova-api/nova-option', OptionResourceIndexController::class . '@handle'); Route::get('/nova-api/nova-option/count', OptionResourceCountController::class . '@show'); Route::put('/nova-api/nova-option/{resourceId}', OptionResourceUpdateController::class . '@handle'); -Route::delete('/nova-api/nova-page/{resourceId}/field/{field}', OptionFieldDestroyController::class . '@handle'); \ No newline at end of file +Route::delete('/nova-api/nova-option/{resourceId}/field/{field}', OptionFieldDestroyController::class . '@handle'); From 8e110fd6d60751fc9f999c7d5f51093349a6d11e Mon Sep 17 00:00:00 2001 From: Toon Van den Bos Date: Tue, 16 Jun 2020 21:01:58 +0200 Subject: [PATCH 6/9] Added static model names (placeholders). Closes #61. References #11. References #15. Closes #33. --- src/Pages/OptionResource.php | 7 +++++++ src/Pages/PageResource.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Pages/OptionResource.php b/src/Pages/OptionResource.php index d2b4dc8..1d13e49 100644 --- a/src/Pages/OptionResource.php +++ b/src/Pages/OptionResource.php @@ -8,6 +8,13 @@ class OptionResource extends StaticResource { + /** + * The model the resource corresponds to. + * + * @var string + */ + public static $model = 'nova-option'; + /** * Get the URI key for the resource. * diff --git a/src/Pages/PageResource.php b/src/Pages/PageResource.php index f77f460..48a1f31 100644 --- a/src/Pages/PageResource.php +++ b/src/Pages/PageResource.php @@ -8,6 +8,13 @@ class PageResource extends StaticResource { + /** + * The model the resource corresponds to. + * + * @var string + */ + public static $model = 'nova-page'; + /** * Get the URI key for the resource. * From 4845ce9274b4de71407bfa8ff5ec502ddefccd1b Mon Sep 17 00:00:00 2001 From: duchenean Date: Sat, 17 Oct 2020 17:47:01 +0200 Subject: [PATCH 7/9] Fixed #63 - NaN-NaN in Nova pagination --- src/Http/Controllers/ResourceIndexController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Http/Controllers/ResourceIndexController.php b/src/Http/Controllers/ResourceIndexController.php index f8dffdc..726b391 100644 --- a/src/Http/Controllers/ResourceIndexController.php +++ b/src/Http/Controllers/ResourceIndexController.php @@ -42,6 +42,7 @@ public function handle(ResourceIndexRequest $request, Manager $manager) 'resources' => $paginator->getCollection()->values()->map->serializeForIndex($request), 'prev_page_url' => $paginator->previousPageUrl(), 'next_page_url' => $paginator->nextPageUrl(), + 'per_page' => $paginator->perPage(), 'softDeletes' => null, ]); } From 16133407e055f8ab050669137ac4606595e90b2f Mon Sep 17 00:00:00 2001 From: Martijn Gastkemper Date: Wed, 16 Dec 2020 08:49:26 +0100 Subject: [PATCH 8/9] Replace`loadFromRoute` by `loadForRoute` in docs --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 6371263..6b83e5c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -214,7 +214,7 @@ class AboutController extends Controller } ``` -In most cases, this will probably not be very convenient since we alreay registered the current route's template in our routes definitions. Therefore, it is also possible to load the page's content with an `Illuminate\Routing\Route` instance using the `loadFromRoute($route, $locale = null, $current = true)` method: +In most cases, this will probably not be very convenient since we alreay registered the current route's template in our routes definitions. Therefore, it is also possible to load the page's content with an `Illuminate\Routing\Route` instance using the `loadForRoute($route, $locale = null, $current = true)` method: ```php use Illuminate\Http\Request; @@ -225,14 +225,14 @@ class AboutController extends Controller public function show(Request $request, Manager $page) { - $page->loadFromRoute($request->route()); + $page->loadForRoute($request->route()); return view('pages.about'); } } ``` -Anyway, if no locale is provided, NovaPage will use the application's current locale (using `App::getLocale()`). By default, loading a page's content will define it as the current page, making its attributes accessible with the `Page` facade. If you just want to load content without setting it as the current page, you should call `load()` or `loadFromRoute()` with `$current` set to `false`. +Anyway, if no locale is provided, NovaPage will use the application's current locale (using `App::getLocale()`). By default, loading a page's content will define it as the current page, making its attributes accessible with the `Page` facade. If you just want to load content without setting it as the current page, you should call `load()` or `loadForRoute()` with `$current` set to `false`. ## Front-end Template Usage From c0029fe89e5e42c83a85b495b8adb0c92be2a210 Mon Sep 17 00:00:00 2001 From: Martijn Gastkemper Date: Wed, 20 Jan 2021 15:54:17 +0100 Subject: [PATCH 9/9] Fix PHP 8 error in Template.php Required parameter $closure follows optional parameter $date fixes #76 --- src/Pages/Template.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Pages/Template.php b/src/Pages/Template.php index 022e709..538b541 100644 --- a/src/Pages/Template.php +++ b/src/Pages/Template.php @@ -356,12 +356,11 @@ public function setDate($moment, $date = null) * @param Closure $closure * @return mixed */ - public function setDateIf($moment, $date = null, Closure $closure) + public function setDateIf($moment, $date, Closure $closure) { if(!($date instanceof Carbon)) { $date = new Carbon($date); } - if($closure($date, $this->getDate($moment))) { return $this->setDate($moment, $date); }