PHP code example of fuelviews / laravel-navigation

1. Go to this page and download the library: Download fuelviews/laravel-navigation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fuelviews / laravel-navigation example snippets


'navigation' => [
    // Simple link
    [
        'type' => 'link',
        'position' => 0,
        'name' => 'Home',
        'route' => 'home',
    ],
    
    // Dropdown menu
    [
        'type' => 'dropdown',
        'position' => 1,
        'name' => 'Services',
        'links' => [
            [
                'name' => 'Web Development',
                'route' => 'services.web',
            ],
            [
                'name' => 'Mobile Apps',
                'route' => 'services.mobile',
            ],
        ],
    ],
],

// logo config
'default_logo' => '',
'transparency_logo' => '',

// navigation config
'top_nav_enabled' => false,
'logo_swap_enabled' => true,
'transparent_nav_background' => true,

// logo shape config
'default_logo_shape' => 'square', // Can be 'horizontal', 'vertical', or 'square'
'transparency_logo_shape' => 'horizontal', // Can be 'horizontal', 'vertical', or 'square'

'pre_scrolled_routes' => [
    'careers',
    'contact',
    'services',
    'forms.*',
    'sabhero-blog.*',
],

use Fuelviews\Navigation\Facades\Navigation;

// Get all navigation items
$items = Navigation::getNavigationItems();

// Check if dropdown route is active
$isActive = Navigation::isDropdownRouteActive($dropdownLinks);

// Get configuration values
$logo = Navigation::getDefaultLogo();
$phone = Navigation::getPhone();
$isTransparent = Navigation::isTransparentNavBackground();

// Check route states
$isPreScrolled = Navigation::isPreScrolledRoute();
$preScrolledString = Navigation::getPreScrolledRoute(); // 'true' or 'false'

// In a service provider
config([
    'navigation.navigation' => array_merge(
        config('navigation.navigation'),
        [
            [
                'type' => 'link',
                'position' => 99,
                'name' => 'Admin',
                'route' => 'admin.dashboard',
            ]
        ]
    )
]);

// Create custom component
class CustomNavigationLink extends Component
{
    public function render()
    {
        return view('components.custom-navigation-link');
    }
}

// Register in AppServiceProvider
Blade::component('custom-nav-link', CustomNavigationLink::class);

// Feature test example
public function test_navigation_renders_correctly()
{
    $response = $this->get('/');
    
    $response->assertSeeLivewire(DesktopNavigation::class);
    $response->assertSee('Home');
    $response->assertSee('Services');
}
bash
php artisan navigation:install
bash
# Publish configuration
php artisan vendor:publish --tag="navigation-config"

# Publish views (optional)
php artisan vendor:publish --tag="navigation-views"

# Publish service provider for advanced customization (optional)
php artisan vendor:publish --tag="laravel-package-tools-service-provider"
blade
<!-- Top bar for contact info -->
<x-navigation::top-bar />

<!-- Footer with navigation links -->
<x-navigation::footer.footer />

<!-- Spacing component -->
<x-navigation::spacer />

<!-- Phone button -->
<x-navigation::phone-button />

<!-- Logo component -->
<x-navigation::logo />

<!-- Social media icons -->
<x-navigation::social.facebook />
<x-navigation::social.instagram />
<x-navigation::social.linkedin />
<x-navigation::social.youtube />
javascript
module.exports = {
    content: [
        './resources/**/*.blade.php',
        './resources/**/*.js',
        './vendor/fuelviews/laravel-navigation/resources/**/*.blade.php',
    ],
    // ... rest of your config
}
bash
php artisan navigation:list
bash
php artisan navigation:validate