https://github.com/stereoflo/users-admin
https://github.com/stereoflo/users-admin
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/stereoflo/users-admin
- Owner: StereoFlo
- Created: 2017-10-09T12:51:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T09:14:31.000Z (about 7 years ago)
- Last Synced: 2025-01-08T02:50:05.661Z (over 1 year ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel Admin Panel
An admin panel for managing users, roles, permissions & crud.
### Requirements
Laravel >=5.1
PHP >= 5.5.9
## Installation
For Laravel >= 5.5 you need to follow these steps
---
1. Run
```
composer require stereoflo/users-admin
```
2. Install the admin package.
```
php artisan users-admin:install
```
3. Make sure your user model's has a ```HasRoles``` trait **app/User.php**.
```php
class User extends Authenticatable
{
use Notifiable, HasRoles;
...
```
4. You can generate CRUD easily through generator tool now.
For Laravel < 5.5 you need to follow these steps
---
1. Run
```
composer require stereoflo/users-admin
```
2. Add service provider to **config/app.php** file.
```php
'providers' => [
...
Stereoflo\UsersAdmin\UsersAdminServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
],
```
3. Add **Collective/Html** aliases to **config/app.php** file.
```php
'aliases' => [
...
'Form' => Collective\Html\FormFacade::class,
'HTML' => Collective\Html\HtmlFacade::class,
],
```
4. Run ```composer dump-autoload```
5. Install the admin package.
```
php artisan users-admin:install
```
6. Make sure your user model's has a ```HasRoles``` trait **app/User.php**.
```php
class User extends Authenticatable
{
use Notifiable, HasRoles;
...
```
7. You can generate CRUD easily through generator tool now.
## Usage
1. Create some roles.
2. Create some permissions.
3. Give permission(s) to a role.
4. Create user(s) with role.
5. For checking authenticated user's role see below:
```php
// Add roles middleware in app/Http/Kernel.php
protected $routeMiddleware = [
...
'roles' => \App\Http\Middleware\CheckRole::class,
];
```
```php
// Check role anywhere
if(Auth::check() && Auth::user()->hasRole('admin')) {
// Do admin stuff here
} else {
// Do nothing
}
// Check role in route middleware
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth', 'roles'], 'roles' => 'admin'], function () {
Route::get('/', ['uses' => 'AdminController@index']);
});
```
6. For checking permissions see below:
```php
if($user->can('permission-name')) {
// Do something
}
```
Learn more about ACL from [here](https://laravel.com/docs/5.3/authorization)
## Screenshots






## Author
[Sohel Amin](http://www.sohelamin.com) :email: [Hire Me](mailto:sohelamincse@gmail.com)