daison12006013 / admin-laravel by daison12006013

Ready made admin for your laravel website.
153
8
3
Package Data
Maintainer Username: daison12006013
Maintainer Contact: daison12006013@gmail.com (Daison Carino)
Package Create Date: 2015-01-27
Package Last Update: 2016-11-02
Language: JavaScript
License: MIT
Last Refreshed: 2024-04-19 15:02:48
Package Statistics
Total Downloads: 153
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 8
Total Watchers: 3
Total Forks: 0
Total Open Issues: 0

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

What I am looking for?

Laravel Admin

I'm still keep on updating this admin package, when you are using the dev-master you will see some sample routes and navigation links, those are my examples to test all the functionality of this package. Each release has a branch and you need to switch for the said branch you used for specific README file.

Anyhow, I'm using this design http://www.blacktie.co/demo/dashgumfree/ as my basis, so try to review the code, later on I'll be importing other admin templates that you can easily configure. Thumbs Up!

Start Up

Include this to your composer, if you want the most updated branch, use dev-master

  	"require": {
  		"daison/admin-laravel": "1.2.*"
  	}

Or if you have an existing Users table then use publish

    php artisan migrate:publish daison/admin-laravel

Pre-Testing

Go to your browser localhost:8080/admin You can now access the admin login page

Go to your command line, and lets create an account to test this admin panel

  php artisan tinker
  > $user = new User;
  > $user->email = "email@gmail.com";
  > $user->password = Hash::make('abcd');
  > $user->save();
  > $role = new Role;
  > $role->name = 'superuser';
  > $role->save();
  > $user_role = new UserHasRole;
  > $user_role->user_id = $user->id;
  > $user_role->role_id = $role->id;
  > $user_role->save();

Go back to the page, and log your recently created account.

Tadda! Now you can see the navigation bar, the site name, and even the logout button, let's move to configuration.

Configuration

Remember we used this command php artisan config:publish daison/admin-laravel Go to /app/config/packages/daison/admin-laravel/ folder you can see these files

####Navigation Lets create our sample navigation,

    [name] => [
      'name' => 'Navigation Name',
      'icon' => 'fa fa-home fa-fv',
      'url'  => '/admin/sample',
      'items'=> [
          [name] => [
              'name' => 'Second Level Nav Name',
              'icon  => '',
              'url'  => '/admin/sample/1',
          ],
          [name] => [
              'name' => 'Second Level Nav Name',
              'icon  => '',
              'url'  => '/admin/sample/2',
          ],
      ],
    ],

After creating these links with [items], refresh your page and see changes. You can even use 'roles' => ['superuser'] to limit the view access.

####Routes Based from our navigation links, we need to create a route to assign the controller to work with. You can also use the original routes file from /app/config/routes.php, but I suggest to use this approach to separate your original routes from admin routes.

'admin_sample_get' => [
  'process' => 'get',
  'url'     => '/admin/sample/',
  'uses'    => 'SampleController@showSample',
],
'admin_sample_post' => [
  'process' => 'post',
  'url'     => '/admin/sample/',
  'uses'    => 'SampleController@saveSample',
],
'admin_sample_rest_get' => [
  'process' => 'get',
  'url'     => '/admin/inventory/{id}/edit',
  'uses'    => 'InventoryController@showEditItem',
],
'admin_sample_rest_post' => [
  'process' => 'post',
  'url'     => '/admin/inventory/{id}/edit',
  'uses'    => 'InventoryController@updateItem',
],

Now create your SampleController / InventoryController and it's up to you to handle the responses. You can even assign 'roles' => ['superuser'] to restrict each request, you can also provide 'is_auth' => true to redirect guest to the login page.

####Still using Main Routes So you still want to use the main app/routes.php, however you want to use the roles management to your routes. Go to your controller __construct and do the constructor injection.

  use Daison\AdminLaravel\AdminLaravel as Admin;
  
  class MyController
  {
    private $admin;
    public function __construct(Admin $admin)
    {
      $this->admin = $admin;
    }
    
    public function showProfile()
    {
      if ($this->admin->hasAnAccess(['superuser','agent']) == false) {
        // It means the Authenticated user doesn't have roles
        // Redirect the user, show the access not allowed page... and so on..
      }
    }
    
    public function saveProfile()
    {
      // same thing as the showProfile() method.
    }
  }

I am still updating this README.