Add breadcrumb support using Laravel Breadcrumbs package
- Install `diglactic/laravel-breadcrumbs` and update composer dependencies. - Configure breadcrumbs in `config/breadcrumbs.php`. - Define breadcrumbs for admin and site views. - Update base admin controller to include default breadcrumb view.
This commit is contained in:
@@ -44,6 +44,7 @@ final class Translations
|
||||
'site.Choose version',
|
||||
'site.alert-status-not-supported',
|
||||
'site.alert-status-future',
|
||||
'Home',
|
||||
];
|
||||
|
||||
foreach (DocumentationVersionStatus::cases() as $status) {
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller as BaseController;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
Config::set('breadcrumbs.view', 'breadcrumbs::bootstrap4');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ final class LanguagesController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly LanguageService $languageService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function newLanguage(NewLanguageRequest $request): JsonResponse
|
||||
{
|
||||
|
||||
@@ -13,7 +13,9 @@ final class AboutController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AboutService $aboutService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function languages(int $project, Request $request): View
|
||||
{
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@ final class DocumentationCategoriesController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DocumentationCategoryService $documentationCategoryService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(int $projectId, int $versionId, IndexRequest $request): View
|
||||
{
|
||||
|
||||
+3
-1
@@ -15,7 +15,9 @@ final class DocumentationVersionController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DocumentationVersionService $documentationVersionService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(int $projectId, IndexRequest $request): View
|
||||
{
|
||||
|
||||
@@ -16,7 +16,9 @@ final class DocumentationsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DocumentationService $documentationService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(int $projectId, int $versionId, IndexRequest $request): View
|
||||
{
|
||||
|
||||
@@ -12,7 +12,9 @@ final class FeedbacksController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly FeedbackService $feedbackService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(IndexRequest $request): View
|
||||
{
|
||||
|
||||
@@ -15,7 +15,9 @@ final class LinksController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly LinkService $linkService
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(int $projectId, IndexRequest $request): View
|
||||
{
|
||||
|
||||
@@ -13,7 +13,9 @@ final class ServiceTranslateController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ServiceTranslateService $serviceTranslateService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function view(int $projectId, Request $request): View
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin\Projects;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Admin\Controller;
|
||||
use App\Http\Requests\Admin\Projects\Translations\UpdateRequest;
|
||||
use App\Services\Admin\Project\TranslationService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -13,7 +13,9 @@ final class TranslationsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TranslationService $translationService,
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function languages(int $projectId, Request $request): View
|
||||
{
|
||||
|
||||
@@ -14,7 +14,9 @@ final class ProjectsController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProjectService $projectService
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(IndexRequest $request): View
|
||||
{
|
||||
|
||||
@@ -14,7 +14,9 @@ final class RolesController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RoleService $roleService
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
public function index(IndexRequest $request): View
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
@@ -15,7 +15,9 @@ final class UsersController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly UserService $userService
|
||||
) { }
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(IndexRequest $request): View
|
||||
{
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
|
||||
Breadcrumbs::for('admin.home', function ($trail) {
|
||||
$trail->push(__('Home'), route('admin.home'));
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Services\WebsiteTranslations;
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
|
||||
Breadcrumbs::for('home', function ($trail, WebsiteTranslations $websiteTranslations) {
|
||||
$trail->push($websiteTranslations->translate('Home'), route('home'));
|
||||
});
|
||||
@@ -7,6 +7,7 @@
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.3",
|
||||
"diglactic/laravel-breadcrumbs": "^10.1",
|
||||
"intervention/image-laravel": "^4.0",
|
||||
"kor-elf/captcha-rule-for-laravel": "^1.0",
|
||||
"kor-elf/translate-laravel": "^2.0",
|
||||
|
||||
Generated
+125
-2
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a920317eed14f3d09c7ed37a87c65ec1",
|
||||
"content-hash": "497caf2eb305e80d19ee6e7fbeffd7b7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@@ -209,6 +209,76 @@
|
||||
},
|
||||
"time": "2024-07-08T12:26:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "diglactic/laravel-breadcrumbs",
|
||||
"version": "v10.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/diglactic/laravel-breadcrumbs.git",
|
||||
"reference": "64245821155ccfe721832898840408ee6136db31"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/diglactic/laravel-breadcrumbs/zipball/64245821155ccfe721832898840408ee6136db31",
|
||||
"reference": "64245821155ccfe721832898840408ee6136db31",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"facade/ignition-contracts": "^1.0",
|
||||
"laravel/framework": "^10.0 || ^11.0 || ^12.0 || ^13.0",
|
||||
"php": "^8.1"
|
||||
},
|
||||
"conflict": {
|
||||
"davejamesmiller/laravel-breadcrumbs": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": "^8.0 || ^9.0 || ^10.0 || ^11.0",
|
||||
"phpunit/phpunit": "^10.5 || ^11.5 || ^12.5",
|
||||
"spatie/phpunit-snapshot-assertions": "^5.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"Breadcrumbs": "Diglactic\\Breadcrumbs\\Breadcrumbs"
|
||||
},
|
||||
"providers": [
|
||||
"Diglactic\\Breadcrumbs\\ServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Diglactic\\Breadcrumbs\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sheng Slogar",
|
||||
"email": "sheng@diglactic.com",
|
||||
"role": "Maintainer"
|
||||
},
|
||||
{
|
||||
"name": "Dave James Miller",
|
||||
"email": "dave@davejamesmiller.com",
|
||||
"role": "Original Creator"
|
||||
}
|
||||
],
|
||||
"description": "A simple Laravel-style way to create breadcrumbs.",
|
||||
"homepage": "https://github.com/diglactic/laravel-breadcrumbs",
|
||||
"keywords": [
|
||||
"laravel"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/diglactic/laravel-breadcrumbs/issues",
|
||||
"source": "https://github.com/diglactic/laravel-breadcrumbs/tree/v10.1.0"
|
||||
},
|
||||
"time": "2026-03-30T05:25:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"version": "2.1.0",
|
||||
@@ -507,6 +577,59 @@
|
||||
],
|
||||
"time": "2025-03-06T22:45:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "facade/ignition-contracts",
|
||||
"version": "1.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facade/ignition-contracts.git",
|
||||
"reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
|
||||
"reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^v2.15.8",
|
||||
"phpunit/phpunit": "^9.3.11",
|
||||
"vimeo/psalm": "^3.17.1"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Facade\\IgnitionContracts\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://flareapp.io",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Solution contracts for Ignition",
|
||||
"homepage": "https://github.com/facade/ignition-contracts",
|
||||
"keywords": [
|
||||
"contracts",
|
||||
"flare",
|
||||
"ignition"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/facade/ignition-contracts/issues",
|
||||
"source": "https://github.com/facade/ignition-contracts/tree/1.0.2"
|
||||
},
|
||||
"time": "2020-10-16T08:27:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fruitcake/php-cors",
|
||||
"version": "v1.4.0",
|
||||
@@ -9789,5 +9912,5 @@
|
||||
"php": "^8.3"
|
||||
},
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
"plugin-api-version": "2.9.0"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| View Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Choose a view to display when Breadcrumbs::render() is called.
|
||||
| Built in templates are:
|
||||
|
|
||||
| - 'breadcrumbs::bootstrap5' - Bootstrap 5
|
||||
| - 'breadcrumbs::bootstrap4' - Bootstrap 4
|
||||
| - 'breadcrumbs::bulma' - Bulma
|
||||
| - 'breadcrumbs::foundation6' - Foundation 6
|
||||
| - 'breadcrumbs::json-ld' - JSON-LD Structured Data
|
||||
| - 'breadcrumbs::materialize' - Materialize
|
||||
| - 'breadcrumbs::tailwind' - Tailwind CSS
|
||||
| - 'breadcrumbs::uikit' - UIkit
|
||||
|
|
||||
| Or a custom view, e.g. '_partials/breadcrumbs'.
|
||||
|
|
||||
*/
|
||||
|
||||
'view' => 'breadcrumbs.site',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Breadcrumbs File(s)
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The file(s) where breadcrumbs are defined. e.g.
|
||||
|
|
||||
| - base_path('routes/breadcrumbs.php')
|
||||
| - glob(base_path('breadcrumbs/*.php'))
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => [
|
||||
base_path('breadcrumbs/site.php'),
|
||||
base_path('breadcrumbs/admin.php'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Exceptions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Determine when to throw an exception.
|
||||
|
|
||||
*/
|
||||
|
||||
// When route-bound breadcrumbs are used but the current route doesn't have a name (UnnamedRouteException)
|
||||
'unnamed-route-exception' => true,
|
||||
|
||||
// When route-bound breadcrumbs are used and the matching breadcrumb doesn't exist (InvalidBreadcrumbException)
|
||||
'missing-route-bound-breadcrumb-exception' => true,
|
||||
|
||||
// When a named breadcrumb is used but doesn't exist (InvalidBreadcrumbException)
|
||||
'invalid-named-breadcrumb-exception' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Subclass the default classes for more advanced customisations.
|
||||
|
|
||||
*/
|
||||
|
||||
// Manager
|
||||
'manager-class' => Diglactic\Breadcrumbs\Manager::class,
|
||||
|
||||
// Generator
|
||||
'generator-class' => Diglactic\Breadcrumbs\Generator::class,
|
||||
|
||||
];
|
||||
Reference in New Issue
Block a user