spartnernl / laravel-sidebar Goto Github PK
View Code? Open in Web Editor NEWA Laravel Sidebar builder
License: MIT License
A Laravel Sidebar builder
License: MIT License
Hello, how I can change the default sidebar html with the one that I want?
studly_case()
is still used in SidebarFlusherFactory
and SidebarResolverFactory
. This appears to only cause errors when config:cache
is used.
Hello,
I've managed to load the sidebar, extend it and render it, all looks pretty awesome. I experienced some difficulty with using Sentinel inside SidebarExtenders to display some of the menus based on the permissions of the user. Unfortunately, when I try to access Sentinel it's always a empty object. I found that from Laravel 5.3 there is ะฐ change how classes are loaded and you can not access Auth (maybe Sentinel also) within __construct methods and while Laravel boots because actually there is still no real request. That's a problem because we load the sidebar using dependency injection inside the __construct method of our AdminController. So my questions are:
Thanks in advance.
How can i assign my own HTML tags in it?
How can i assign classes in existing menu tags like I want to assign open class to active li.
Couldn't find anything from the wiki.
Is there any ways to make single link active for multiple routes including one dynamic route with parameter ?
i.e: there isn't any menu item for edit link for a resource but I want to make the index or parent item active
I'm doing a project with laravel 5.1.12
I like adding a sidebar in the sample, but the build () function does not work in code.
SidebarViewCreator:
use Maatwebsite\Sidebar\Presentation\SidebarRenderer;
use Modules\Core\Sidebar\AdminSidebar;
class SidebarViewCreator
{
/**
* @var AdminSidebar
*/
protected $sidebar;
/**
* @param AdminSidebar $sidebar
* @param SidebarRenderer $renderer
*/
public function __construct(AdminSidebar $sidebar, SidebarRenderer $renderer)
{
$this->sidebar = $sidebar;
$this->renderer = $renderer;
}
public function create($view)
{
$view->sidebar = $this->renderer->render($this->sidebar);
}
}
AdminSidebar
use Maatwebsite\Sidebar\Menu;
use Maatwebsite\Sidebar\Sidebar;
class AdminSidebar implements Sidebar
{
/**
* @var Menu
*/
protected $menu;
/**
* @var RepositoryInterface
*/
protected $modules;
/**
* @var Container
*/
protected $container;
/**
* @param Menu $menu
* @param Container $container
*/
public function __construct(Menu $menu)
{
$this->menu = $menu;
}
/**
* Build your sidebar implementation here
*/
public function build()
{
$this->menu->group('settings', function (Group $group) {
$group->item('User Settings');
});
}
/**
* @return Menu
*/
public function getMenu()
{
return $this->menu;
}
}
provider :
use Maatwebsite\Sidebar\SidebarManager;
class ModuleProvider extends ServiceProvider
{
public function boot(SidebarManager $manager)
{
$manager->register('AdminSidebar::class);
}
}
Quick question for anyone who may have an idea on this..
How do I render the sidebar using the view composer?
I am using teepluss/theme as my theme manager in my laravel projects. In the config file, the following code allows me to use view composer:
php
$theme->partialComposer('sidebar-bar', function($view)
{
$view->with('sidebar', '');
});
However, I am unsure of how to load the sidebar in the above code? Anyone have any ideas?
Thanks
Package cant install on Laravel 8 because of the versions in composer.json
It seems important parts of the documentation is missing here:
https://github.com/Maatwebsite/Laravel-Sidebar/wiki/Building-the-Sidebar
How do I add menu's / groups / items ....?
Situation:
I've got 2 items:
$item->addItem('posts', function (SidebarItem $item) {
$item->weight = 0;
$item->append('admin.blog.post.create');
$item->route('admin.blog.post.index');
$item->icon = 'fa fa-copy';
$item->name = 'Posts';
$item->authorize(
$this->auth->hasAccess('blog.posts.index')
);
});
$item->addItem('categories', function (SidebarItem $item) {
$item->weight = 1;
$item->route('admin.blog.category.index');
$item->icon = 'fa fa-file-text';
$item->name = 'Categories';
$item->authorize(
$this->auth->hasAccess('blog.categories.index')
);
});
The plus gets appended to the categories
item, not posts
.
Since laravel 5.1, my groups and items are no more sorted by weight, am I alone with this issue ?
Is it possible to use this plugin as a navigation bar instead of a sidebar?
Hi, seems in that line 1 of item.blade.php
:
<li class="@if($item->getItemClass()){{ $item->getItemClass() }}@endif @if($active)active@endif @if($item->hasItems())treeview@endif clearfix">
Causes the following error:
Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)
Putting an extra space before the start of @endif
seems to solve the problem, so line 1 should be:
<li class="@if($item->getItemClass()){{ $item->getItemClass() }}@endif @if($active)active @endif @if($item->hasItems())treeview @endif clearfix">
Seems that the Blade's @foobar
directives must be "isolated" with a space before.
"A Laravel Sidebar bulder" should be "A Laravel Sidebar builder"
FatalErrorException in Attributable.php line 17: Call to a member function make() on null
Hi, am using this package with https://github.com/nWidart/laravel-modules . I want to use the default laravel 5.2* authentication yet i cannot get the user object which is always null
when using dependency injection or even Request::user()
or Auth::user()
See here:
`
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender {
public function __construct(Auth $auth){
$this->auth=$auth;
dd($this->auth);// null
}
public function extendWith(Menu $menu) {
$menu->group('Dashboard', function (Group $group) {
$group->item('Inventory', function (Item $item) {
$item->weight(11);
$item->icon('fa fa-barcode');
$item->item('Sent', function (Item $item) {
$item->icon('fa fa-share-square-o');
$item->route('messaging.sent');
});
$item->item('Contacts', function (Item $item) {
$item->icon('fa fa-volume-control-phone');
$item->route('messaging.contacts');
});
$item->item('Buy Airtime', function (Item $item) {
$item->icon('fa fa-money');
$item->route('messaging.topup');
});
});
});
return $menu;
}
}`
The sidebar builder takes approx. 300ms
to load the sidebar.
I have 12 menu items.
That is pretty much the same as the Laravel framework.
Maybe run it into a profiler or something, to find where there is a hog.
Hey, I noticed the composer.json
doesn't allow laravel/framework
10 as of yet. Is this something you need help with? I reckon it's mainly adding ^10.0
to laravel/framework
in composer.json
:)
I'm getting LOG.warning: implements the Serializable interface using laravel 9 but I think it's more due to the PHP 8.1.2 version I'm currently using.
"Warning.
As of PHP 8.1.0, a class that implements Serializable without also implementing __serialize() and __unserialize() will generate a deprecation warning."
My solution is to implement __serialize() and __unserialize() , so as not to have that warning.
Hello there, i'm trying to run composer update, however, i keep getting this error:
`In Application.php line 690:
Class 'Maatwebsite\Sidebar\SidebarServiceProvi
der' not found`
This persists after i install this package
Edit: fixed this by installing several other required packages.
The menu no longer sorts by weight, or at least I can't get it to. Is this by design in the revised version as I can't seem to find anywhere in the source code that it checks the weight attribute?
Thanks for this great package. I'm wondering if there will be a release soon, so we can avoid to have dev-master in composer.json ?
Hello! ๐
I see I was missing the ResolveSidebars
middleware after setting the cache option to static
and the StaticCacheResolver
wasn't called.
After having added the middleware, and for testing purposes changed the StaticCacheResolver
to use the files cache disk, I'm getting:
Call to a member function make() on null (View: /Users/nicolaswidart/Sites/Asguard/Platform/Themes/Adminlte/views/layouts/master.blade.php) (View: /Users/nicolaswidart/Sites/Asguard/Platform/Themes/Adminlte/views/layouts/master.blade.php)
--
I'm not sure why it shows the view as location as there's isn't a make
in there. The sidebar is sent to the view using a view creator
$view->sidebar = $this->renderer->render($this->sidebar);
Did I miss something for the static cache option to work?
Thanks!
Edit: What might also be something nice to have is to cache the views, reducing the number of partials loaded. The package is currently loading ~17 partials for the sidebar alone.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.