Cartalyst LLC.
Menus by Cartalyst
8
74
0
7
1

This package requires a valid subscription. Subscribe for access.

Preface

Introduction

A Platform 9 extension to manage menus across your application.

Have a read through the Installation Guide.

Features

  • create, update, delete menus.
  • assign menu name & slug.
  • enabled/disable.
  • create, update, delete menu links.
  • sort menu links using nested sets model.
  • set link name & slug.
  • set link type. static | page
  • set URI.
  • enable/disable link.
  • set link target. same window | new window | parent window | top frame
  • set https. inherit | yes | no
  • select link parent.
  • set link class.
  • set link Regular Expression.
  • set Visibility. Show Always | Logged in | Logged out | Admin Only
  • restrict to roles.
  • blade call @nav('slug', 'depth', 'cssClass', 'beforeUri', 'view')
  • blade call @dropdown('slug', 'depth', 'selected').

Examples

The $menus variable used below is a reference to the MenuRepository.

$menus = app('platform.menus');
Retrieve all menus
$allMenus = $menus->findAll();
Dynamically create a new menu.
$menus->create([
    'name' => 'Foo',
    'slug' => 'foo',
]);

Setup

Installation

The best and easiest way to install the Menus extension is with Composer.

Preparation

Open your composer.json file and add the following to the require array:

"platform/menus": "^8.0"

Add the following lines after the require array on your composer.json file:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.cartalyst.com"
    }
]

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to install the extension through Platform's admin.

Usage

In this section we'll show how you can manage your application's menus.

Repository

IoC Binding

The menu repository is bound to platform.menus and can be resolved out of the IoC Container using that offset.

$menus = app('platform.menus');

Methods

The repository contains several methods that are used throughout the extension, most common methods are listed below.

For an exhaustive list of available methods, checkout the MenuRepositoryInterface

  • findAll();

Returns a collection of all menus.

  • findAllRoot();

Returns a collection of all root menus.

  • find($id);

Returns a menu object based on the given id.

  • findBySlug($slug);

Returns a menu object based on the given slug.

  • create(array $data);

Creates a new menu.

  • update($id, array $data);

Updates an existing menu.

  • delete($id);

Deletes a menu.

  • enable($id);

Enables a menu.

  • disable($id);

Disables a menu.

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...