Backpack for Laravel

Backpack for Laravel

A collection of Laravel packages to build a custom admin panel.

Documentation    Support

Backpack/Base kickstarts your admin panel building by:

  • pulling in the AdminLTE HTML theme, based on Bootstrap 3;
  • overwriting the default Laravel views for authentication with new ones with AdminLTE design;
  • integrating prologue/alerts and and pnotify for showing notification bubbles upon error/success/warning/info;
  • providing pretty error pages for most common errors;
  • providing a horizontal menu and a side menu you can customize;

Triggering Notification Bubbles in PHP

We use prologue/alerts to trigger notifications. Check out its documentation for the entire syntax. Basic examples:

<?php

public function foo() 
{
  \Alert::info('This is a blue bubble.');
  \Alert::warning('This is a yellow/orange bubble.');
  \Alert::error('This is a red bubble.');
  \Alert::success('This is a green bubble.');
  \Alert::success('<strong>Got it</strong><br>This is an HTML message.');

  
  // the layout will make sure to show your notifications
  return view('some_view');
}

public function bar()
{
  \Alert::success('You have successfully logged in')->flash();
 
  // please note the above flash() method; this will store your notification in a session variable, so that you can redirect to another page, but the notification will still be shown (on the page you redirect to)
  return Redirect::to('some-url');
}

Triggering Notification Bubbles in JavaScript

We use PNotify to show notifications from JavaScript, on the same page. Check out its page for more detailed use. Basic example:

new PNotify({
  title: "Operation successful",
  text: "You have deleted the internet.",
  type: "success"
});

// available types: success, info, warning, error
// PLEASE NOTE it's "error" here, not "danger"

Helpers

You can use these helpers anywhere in your app (models, views, controllers, requests, etc), except the config files, since the config files are loaded before the helpers.

Helper
Details

backpack_url($path)

Use this helper instead of url() to generate paths with the admin prefix prepended.

backpack_authentication_column()

Returns the username column. The Laravel and Backpack default is email.

backpack_users_have_email()

Tests that the email column exists on the users table and returns true/false.

backpack_avatar($user)

Receives a user object and returns a path to an avatar image, according to the preferences in the config file (gravatar, placeholder or custom).

backpack_middleware()

Returns the key for the admin middleware. Default is admin.

backpack_guard_name()

Returns the guard used for Backpack authentication.

backpack_auth()

Returns the Auth facade, using the current Backpack guard. Basically a shorthand for \Auth::guard(backpack_guard_name()).

backpack_user()

Returns the current Backpack user, if logged in. Basically a shorthand for \Auth::guard(backpack_guard_name())->user()

Features