PHP code example of daison / admin-laravel

1. Go to this page and download the library: Download daison/admin-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daison / admin-laravel example snippets


    php artisan config:publish daison/admin-laravel
    php artisan view:publish daison/admin-laravel
    php artisan asset:publish daison/admin-laravel --path="vendor/daison/admin-laravel/src/assets"

    php artisan migrate --package="daison/admin-laravel"

    php artisan migrate:publish daison/admin-laravel

    php artisan tinker
    > $user = new User;
    > $user->email = "[email protected]";
    > $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();
  

  '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',
  ],
  

  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.
    }
  }