1. Go to this page and download the library: Download dewsign/nova-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/ */
dewsign / nova-navigation example snippets
// app/Nova/HeaderNavigation.php
namespace App\Nova;
use Dewsign\NovaNavigation\Nova\Navigation;
class HeaderNavigation extends Navigation
{
public static $zone = 'header';
public static function label()
{
return __('Header Links');
}
}
// app/Navigation/Models/Category.php
use Dewsign\NovaNavigation\Models\NavigationItem;
class Section extends NavigationItem
{
public static $viewTemplate = 'nova-navigation::category';
public function category()
{
// BlogCategoryModel is used as an example. Include your actual blog category model.
return $this->belongsTo(BlogCategoryModel::class);
}
// Return the url for this navigation item
public function resolveAction()
{
return route('blog.category', $this->category);
}
// Return the label to display in the navigation
public function resolveLabel($category = null)
{
// Automatically use the category title as navigation label
return $category->title;
}
}
// app/Navigation/Nova/Category.php
...
use Dewsign\NovaNavigation\Nova\Items\NavigationItem;
class Section extends NavigationItem
{
// The model we just created
public static $model = App\Navigation\Models\Category::class;
public static function label()
{
return __('Category');
}
public function fields(Request $request)
{
return [
// BlogCategoryResource is used as an example. Include your actual blog category nova resource.
BelongsTo::make('Category', 'category', BlogCategoryResource::class)->searchable(),
];
}
}