From 8abf391a53283969c62fd9cdf42436978350436d Mon Sep 17 00:00:00 2001 From: Ludovic CANDELLIER Date: Tue, 31 May 2022 23:21:04 +0200 Subject: [PATCH] change display on categories --- .../Controllers/Shop/CategoryController.php | 5 +- app/Repositories/Shop/Categories.php | 15 ++++ config/captcha.php | 90 +++++++++++++++++++ config/geographical_calculator.php | 34 +++++++ config/htmlmin.php | 70 +++++++++++++++ config/httpauth.php | 49 ++++++++++ config/min-auth.php | 17 ++++ config/rinvex.categories.php | 2 +- .../Shelves/partials/category_add.blade.php | 11 ++- resources/views/Shop/Shelves/shelve.blade.php | 9 +- 10 files changed, 297 insertions(+), 5 deletions(-) create mode 100644 config/captcha.php create mode 100644 config/geographical_calculator.php create mode 100644 config/htmlmin.php create mode 100644 config/httpauth.php create mode 100644 config/min-auth.php diff --git a/app/Http/Controllers/Shop/CategoryController.php b/app/Http/Controllers/Shop/CategoryController.php index 46cbe2ac..14af9389 100644 --- a/app/Http/Controllers/Shop/CategoryController.php +++ b/app/Http/Controllers/Shop/CategoryController.php @@ -11,9 +11,11 @@ use App\Repositories\Shop\Offers; use App\Repositories\Shop\Tags; use App\Repositories\Shop\TagGroups; +use App\Datatables\Shop\CategoriesDataTable; + class CategoryController extends Controller { - public function index() + public function index(CategoriesDataTable $dataTable) { return $dataTable->render('Shop.Categories.list'); } @@ -23,6 +25,7 @@ class CategoryController extends Controller $data = self::init(); $data['display_by_rows'] = $by_rows; $data['category'] = Categories::getFull($category_id); + $data['breadcrumb'] = Categories::getAncestorsByCategory($category_id); $data['tags_selected'] = request()->input('tags') ?? []; $data['articles'] = Articles::getArticlesToSell([ 'category_id' => $category_id, diff --git a/app/Repositories/Shop/Categories.php b/app/Repositories/Shop/Categories.php index e4da4c4a..75dce938 100644 --- a/app/Repositories/Shop/Categories.php +++ b/app/Repositories/Shop/Categories.php @@ -8,6 +8,21 @@ use App\Repositories\Core\Categories as CategoryTrees; class Categories { + public static function getAncestorsByArticle($id) + { + $category = Articles::get($id)->categories()->first(); + $ancestors = self::getAncestorsByCategory($category->id); + $ancestors[] = $category->toArray(); + return $ancestors; + } + + public static function getAncestorsByCategory($id) + { + $category = self::get($id); + $ancestors = $category->getAncestors()->toArray(); + unset($ancestors[0]); + return $ancestors; + } public static function getByHomepage() { diff --git a/config/captcha.php b/config/captcha.php new file mode 100644 index 00000000..5725823c --- /dev/null +++ b/config/captcha.php @@ -0,0 +1,90 @@ + env('CAPTCHA_DRIVER', 'hCaptcha'), + + /* + |------------------------------------------------------------ + | Captcha Site Key + |------------------------------------------------------------ + | + | The site key is used for showing the captcha in the front + | end. You will get your site key from your preferred + | vendor like "ReCaptcha" or "HCaptcha". + | + | ReCaptcha Docs: https://developers.google.com/recaptcha/docs/display + | HCaptcha Docs: https://docs.hcaptcha.com/configuration + | + */ + 'sitekey' => env('CAPTCHA_SITE_KEY', ''), + + /* + |------------------------------------------------------------ + | Captcha Secret Key + |------------------------------------------------------------ + | + | The site key is used for validating the captcha responses. + | You will get you secret key from your preferred vendor + | like "ReCaptcha" or "HCaptcha". + | + | ReCaptcha Docs: https://developers.google.com/recaptcha/docs/display + | HCaptcha Docs: https://docs.hcaptcha.com/configuration + | + */ + 'secret' => env('CAPTCHA_SECRET_KEY', ''), + + /* + |------------------------------------------------------------ + | Captcha Locale Configuration + |------------------------------------------------------------ + | + | The captcha locale determines the default locale of your + | Captcha. You can add any locale value that supported + | by your captcha provider. + | + | ReCaptcha Language List: https://developers.google.com/recaptcha/docs/language + | HCaptcha Language List: https://docs.hcaptcha.com/languages + | + */ + 'locale' => env('CAPTCHA_LOCALE', 'en'), + + /* + |------------------------------------------------------------ + | Captcha Theme + |------------------------------------------------------------ + | + | The captcha theme is the default theme that will display + | the captcha checkbox. + | + | Supported: "light", "dark" + | + */ + 'theme' => env('CAPTCHA_THEME', 'light'), + + /* + |------------------------------------------------------------ + | Captcha Size + |------------------------------------------------------------ + | + | The captcha size is the default size of the captcha + | checkbox. According to your style preference you + | can use any of the supported captcha size. + | + | Supported: "normal", "compact" + | + */ + 'size' => env('CAPTCHA_SIZE', 'normal'), +]; diff --git a/config/geographical_calculator.php b/config/geographical_calculator.php new file mode 100644 index 00000000..dd399ed4 --- /dev/null +++ b/config/geographical_calculator.php @@ -0,0 +1,34 @@ + [ + 'mile' => 1, + 'km' => 1.609344, + 'm' => (1.609344 * 1000), + 'cm' => (1.609344 * 100), + 'mm' => (1.609344 * 1000 * 1000), + ], + + /* + |-------------------------------------------------------------------------- + | distance_key_prefix + |-------------------------------------------------------------------------- + | if you declared more than tow points to resolve their distance, + | you will see the result in the following format: + | "1-2" => ["km" => "some result"], + | "2-3" => ["km" => "some result"], + | "3-4" => ["km" => "some result"], + | and if you want to set any prefix before each index + | you must change the below value to any value you want. + | + */ + 'distance_key_prefix' => '', +]; diff --git a/config/htmlmin.php b/config/htmlmin.php new file mode 100644 index 00000000..fe69d8e2 --- /dev/null +++ b/config/htmlmin.php @@ -0,0 +1,70 @@ + + * (c) Raza Mehdi + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /* + |-------------------------------------------------------------------------- + | Automatic Blade Optimizations + |-------------------------------------------------------------------------- + | + | This option enables minification of the blade views as they are + | compiled. These optimizations have little impact on php processing time + | as the optimizations are only applied once and are cached. This package + | will do nothing by default to allow it to be used without minifying + | pages automatically. + | + | Default: false + | + */ + + 'blade' => false, + + /* + |-------------------------------------------------------------------------- + | Force Blade Optimizations + |-------------------------------------------------------------------------- + | + | This option forces blade minification on views where there such + | minification may be dangerous. This should only be used if you are fully + | aware of the potential issues this may cause. Obviously, this setting is + | dependent on blade minification actually being enabled. + | + | PLEASE USE WITH CAUTION + | + | Default: false + | + */ + + 'force' => false, + + /* + |-------------------------------------------------------------------------- + | Ignore Blade Files + |-------------------------------------------------------------------------- + | + | Here you can specify paths, which you don't want to minify. + | + */ + + 'ignore' => [ + 'resources/views/emails', + 'resources/views/html', + 'resources/views/notifications', + 'resources/views/markdown', + 'resources/views/vendor/emails', + 'resources/views/vendor/html', + 'resources/views/vendor/notifications', + 'resources/views/vendor/markdown', + ], + +]; diff --git a/config/httpauth.php b/config/httpauth.php new file mode 100644 index 00000000..b809ed9b --- /dev/null +++ b/config/httpauth.php @@ -0,0 +1,49 @@ + 'basic', + + /* + |-------------------------------------------------------------------------- + | Authentication name + |-------------------------------------------------------------------------- + | + | Name of secured resource. Clients must authentificate to each named realm. + | + */ + 'realm' => 'Secured', + + /* + |-------------------------------------------------------------------------- + | Authentication username + |-------------------------------------------------------------------------- + | + | Username to access the secured realm in combination with a password. + | + */ + 'username' => 'admin', + + /* + |-------------------------------------------------------------------------- + | Password + |-------------------------------------------------------------------------- + | + | Password to access the secured realm in combination with the username. + | + */ + 'password' => '1234' + +]; diff --git a/config/min-auth.php b/config/min-auth.php new file mode 100644 index 00000000..46b63fe0 --- /dev/null +++ b/config/min-auth.php @@ -0,0 +1,17 @@ + true, + + /** + * Set the default request header name here eg. api-key, token, x-api-key. + */ + 'header_name' => 'api-key', +]; diff --git a/config/rinvex.categories.php b/config/rinvex.categories.php index 02d5ae4a..86ffb72b 100644 --- a/config/rinvex.categories.php +++ b/config/rinvex.categories.php @@ -17,7 +17,7 @@ return [ // Categories Models 'models' => [ - 'category' => App\Models\Core\Category::class, + 'category' => App\Models\Shop\Category::class, ], ]; diff --git a/resources/views/Shop/Shelves/partials/category_add.blade.php b/resources/views/Shop/Shelves/partials/category_add.blade.php index 290b0011..40beed9a 100644 --- a/resources/views/Shop/Shelves/partials/category_add.blade.php +++ b/resources/views/Shop/Shelves/partials/category_add.blade.php @@ -1,7 +1,14 @@
- @include('components.form.button', ['id' => 'by_cards', 'icon' => 'fa-th', 'class' => 'btn-success']) - @include('components.form.button', ['id' => 'by_rows', 'icon' => 'fa-list', 'class' => 'btn-success']) + @if ($display_by_rows ?? false) + @include('components.form.button', ['id' => 'by_cards', 'icon' => 'fa-th', 'class' => 'btn-secondary']) + @else + @include('components.form.button', ['id' => 'by_rows', 'icon' => 'fa-list', 'class' => 'btn-secondary']) + @endif + + @include('components.form.button', ['id' => 'semences', 'icon' => 'fa-leaf', 'class' => 'bg-yellow yellow-dark']) + @include('components.form.button', ['id' => 'plants', 'icon' => 'fa-seedling', 'class' => 'bg-green text-white']) +
diff --git a/resources/views/Shop/Shelves/shelve.blade.php b/resources/views/Shop/Shelves/shelve.blade.php index eb492dbd..e7a2102b 100644 --- a/resources/views/Shop/Shelves/shelve.blade.php +++ b/resources/views/Shop/Shelves/shelve.blade.php @@ -8,7 +8,14 @@ @include('Shop._partials.display_filters')
-

{{ $category['name'] }}

+

+ @foreach($breadcrumb ?? [] as $parent) + {{ $parent['name'] }} / + @endforeach + + {{ $category['name'] }} + +

{!! $category['description'] !!}