Skip to content

Commit

Permalink
Merge pull request #363 from avored/dev
Browse files Browse the repository at this point in the history
dev to master
  • Loading branch information
indpurvesh authored Aug 9, 2019
2 parents fd833d3 + 78c34c4 commit 8fcb4bc
Show file tree
Hide file tree
Showing 13 changed files with 7,029 additions and 14,568 deletions.
20 changes: 13 additions & 7 deletions app/Http/Composers/NavComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

namespace App\Http\Composers;

use AvoRed\Framework\Database\Contracts\CategoryModelInterface;
use AvoRed\Framework\Database\Contracts\MenuGroupModelInterface;
use Illuminate\View\View;
use Illuminate\Support\Facades\Auth;

class NavComposer
{
/**
* @var \AvoRed\Framework\Database\Repository\CategoryRepository
* @var \AvoRed\Framework\Database\Repository\MenuGroupRepository
*/
protected $categoryRepository;
protected $menuGroupRepository;

/**
* home controller construct
*/
public function __construct(
CategoryModelInterface $categoryRepository
MenuGroupModelInterface $menuGroupRepository
) {
$this->categoryRepository = $categoryRepository;
$this->menuGroupRepository = $menuGroupRepository;
}

/**
Expand All @@ -27,7 +28,12 @@ public function __construct(
*/
public function compose(View $view)
{
$categories = $this->categoryRepository->all();
$view->with('categories', $categories);
if (Auth::check()) {
$menus = $this->menuGroupRepository->getTreeByIdentifier('main-auth-menu');
} else {
$menus = $this->menuGroupRepository->getTreeByIdentifier('main-menu');
}

$view->with('menus', $menus);
}
}
29 changes: 28 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use App\Http\Composers\NavComposer;
use AvoRed\Framework\Support\Facades\Menu;
use AvoRed\Framework\Menu\MenuItem;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -15,7 +17,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
//
//
}

/**
Expand All @@ -26,5 +28,30 @@ public function register()
public function boot()
{
View::composer('partials.nav', NavComposer::class);
Menu::make('login', function (MenuItem $menu) {
$menu->label('Login')
->type(MenuItem::FRONT)
->route('login');
});
Menu::make('register', function (MenuItem $menu) {
$menu->label('Register')
->type(MenuItem::FRONT)
->route('register');
});
Menu::make('logout', function (MenuItem $menu) {
$menu->label('Logout')
->type(MenuItem::FRONT)
->route('logout');
});
Menu::make('account.dashboard', function (MenuItem $menu) {
$menu->label('My Account')
->type(MenuItem::FRONT)
->route('account.dashboard');
});
Menu::make('account.order.index', function (MenuItem $menu) {
$menu->label('My Orders')
->type(MenuItem::FRONT)
->route('account.order.index');
});
}
}
7 changes: 7 additions & 0 deletions config/avored.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
'model' => [
'user' => App\User::class
],

'routes' => [
'category' => [
'param' => 'slug',
'name' => 'category.show'
]
],

'filesystems' => [
'disks' => [
Expand Down
Loading

0 comments on commit 8fcb4bc

Please sign in to comment.