Skip to content

Commit 59d6653

Browse files
authored
Merge pull request #2 from PHP-Open-Source-Saver/feature/publish-migrations
PublishMigrations
2 parents 2552b65 + 91d188d commit 59d6653

File tree

2 files changed

+91
-78
lines changed

2 files changed

+91
-78
lines changed

README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
1-
21
# Kodeine/Laravel-ACL
32

4-
[![Laravel](https://img.shields.io/badge/Laravel-~9.0-green.svg?style=flat-square)](http://laravel.com)
3+
[![Laravel](https://img.shields.io/badge/Laravel-~7.0-green.svg?style=flat-square)](http://laravel.com)
54
[![Source](http://img.shields.io/badge/source-kodeine/laravel--acl-blue.svg?style=flat-square)](https://github.com/kodeine/laravel-acl/)
65
[![Build Status](https://img.shields.io/travis/kodeine/laravel-acl/master?style=flat-square)](https://travis-ci.org/kodeine/laravel-acl)
76
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://tldrlegal.com/license/mit-license)
87
[![Total Downloads](https://img.shields.io/packagist/dt/kodeine/laravel-acl.svg?style=flat-square)](https://packagist.org/packages/kodeine/laravel-acl)
98

10-
11-
Laravel ACL adds role based permissions to built in Auth System of Laravel 9.0+. ACL middleware protects routes and even crud controller methods.
9+
Laravel ACL adds role based permissions to built in Auth System of Laravel 6.0+. ACL middleware protects routes and even
10+
crud controller methods.
1211

1312
# Table of Contents
13+
1414
* [Requirements](#requirements)
1515
* [Getting Started](#getting-started)
1616
* [Documentation](#documentation)
1717
* [Roadmap](#roadmap)
1818
* [Change Logs](#change-logs)
1919
* [Contribution Guidelines](#contribution-guidelines)
2020

21-
2221
# <a name="requirements"></a>Requirements
2322

24-
* Version 2.x of this package requires PHP 7.2+ and Laravel 6.0+
23+
* Version 2.x of this package requires PHP 7.2+ and Laravel 6.0+
2524
* Version 1.x requires PHP 5.6+ and Laravel 5.0+
2625

2726
# <a name="getting-started"></a>Getting Started
2827

29-
Install the package using composer
28+
Install the package using composer
3029

3130
```
3231
composer require kodeine/laravel-acl
@@ -38,7 +37,7 @@ If you need to support Laravel 5.x, make sure to install version 1.x
3837
composer require kodeine/laravel-acl "^1.0"
3938
```
4039

41-
2. If you are using Laravel before version 5.4, manually register the service provider in your config/app.php file
40+
2. If you are using Laravel before version 5.4, manually register the service provider in your config/app.php file
4241

4342
```php
4443
'providers' => [
@@ -49,7 +48,7 @@ composer require kodeine/laravel-acl "^1.0"
4948
],
5049
```
5150

52-
3. Publish the package configuartion files and add your own models to the list of ACL models"
51+
3. Publish the package configuartion files, migrations and add your own models to the list of ACL models"
5352

5453
```
5554
$ php artisan vendor:publish --provider="Kodeine\Acl\AclServiceProvider"
@@ -80,7 +79,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
8079

8180
6. Run the migrations to generate your roles and permissions tables
8281

83-
Please note that if you are upgrading to 6.0 from a previous version, the default column type for the id on the users table has changed. On certain databases foreign keys can only be defined with matching column types. As such, you will need to change the id column on your users table to bigInteger in to user this package.
82+
Please note that if you are upgrading to 6.0 from a previous version, the default column type for the id on the users
83+
table has changed. On certain databases foreign keys can only be defined with matching column types. As such, you will
84+
need to change the id column on your users table to bigInteger in to user this package.
8485

8586
```
8687
php artisan migrate
@@ -101,34 +102,44 @@ Here's the TODO list for the next release.
101102
# <a name="change-logs"></a>Change Logs
102103

103104
**September 14 2019**
105+
104106
* [x] Updated the readme to reflect new major release
105107

106108
**September 13, 2019**
109+
107110
* [x] Added support for Laravel 6
108111

109112
*September 22, 2016**
113+
110114
* [x] Added unit tests
111115

112116
*September 20, 2016**
117+
113118
* [x] Added support for Laravel 5.3
114119

115120
*September 19, 2016*
121+
116122
* [x] Added cache support to Roles and Permissions.
117123

118124
*June 14, 2015*
125+
119126
* [x] Added backward compatibility to l5.0 for lists() method.
120127
* [x] Added [Blade Template Extensions](https://github.com/kodeine/laravel-acl/wiki/Blade-Extensions).
121128

122129
*March 28, 2015*
123-
* [x] Added Role Scope to get all users having a specific role. e.g `User::role('admin')->get();` will list all users having `admin` role.
130+
131+
* [x] Added Role Scope to get all users having a specific role. e.g `User::role('admin')->get();` will list all users
132+
having `admin` role.
124133

125134
*March 7, 2015*
126-
* [x] `is()` and `can()` methods now support comma for `AND` and pipe as `OR` operator. Or pass an operator as a second param. [more information](https://github.com/kodeine/laravel-acl/wiki/Validate-Permissions-and-Roles)
127-
* [x] You can bind multiple permissions together so they inherit ones permission. [more information](https://github.com/kodeine/laravel-acl/wiki/Permissions-Inheritance)
135+
136+
* [x] `is()` and `can()` methods now support comma for `AND` and pipe as `OR` operator. Or pass an operator as a second
137+
param. [more information](https://github.com/kodeine/laravel-acl/wiki/Validate-Permissions-and-Roles)
138+
* [x] You can bind multiple permissions together so they inherit ones
139+
permission. [more information](https://github.com/kodeine/laravel-acl/wiki/Permissions-Inheritance)
128140

129141
# <a name="contribution-guidelines"></a>Contribution Guidelines
130142

131143
Support follows PSR-2 PHP coding standards, and semantic versioning.
132144

133-
Please report any issue you find in the issues page.
134-
Pull requests are welcome.
145+
Please report any issue you find in the issues page. Pull requests are welcome.

src/Kodeine/Acl/AclServiceProvider.php

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,72 @@
22

33
namespace Kodeine\Acl;
44

5-
use Blade;
5+
use Illuminate\Support\Facades\Blade;
66
use Illuminate\Support\ServiceProvider;
77

88
class AclServiceProvider extends ServiceProvider
99
{
10-
/**
11-
* Indicates if loading of the provider is deferred.
12-
*
13-
* @var bool
14-
*/
15-
protected $defer = false;
16-
17-
/**
18-
* Bootstrap any application services.
19-
*
20-
* @return void
21-
*/
22-
public function boot()
23-
{
24-
$this->publishConfig();
25-
$this->loadMigrationsFrom(__DIR__ . '/../../migrations');
26-
$this->registerBladeDirectives();
27-
}
28-
29-
/**
30-
* Register any application services.
31-
*
32-
* @return void
33-
*/
34-
public function register()
35-
{
36-
$this->mergeConfigFrom(
37-
__DIR__ . '/../../config/acl.php', 'acl'
38-
);
39-
}
40-
41-
/**
42-
* Publish the config file to the application config directory
43-
*/
44-
public function publishConfig()
45-
{
46-
$this->publishes([
47-
__DIR__ . '/../../config/acl.php' => config_path('acl.php'),
48-
], 'config');
49-
}
50-
51-
public function registerBladeDirectives()
52-
{
53-
// role
54-
Blade::directive('role', function ($expression) {
55-
return "<?php if (Auth::check() && Auth::user()->hasRole({$expression})): ?>";
56-
});
57-
58-
Blade::directive('endrole', function () {
59-
return "<?php endif; ?>";
60-
});
61-
62-
// permission
63-
Blade::directive('permission', function ($expression) {
64-
return "<?php if (Auth::check() && Auth::user()->hasPermission({$expression})): ?>";
65-
});
66-
67-
Blade::directive('endpermission', function () {
68-
return "<?php endif; ?>";
69-
});
70-
}
71-
}
10+
/**
11+
* Indicates if loading of the provider is deferred.
12+
*
13+
* @var bool
14+
*/
15+
protected $defer = false;
16+
17+
/**
18+
* Bootstrap any application services.
19+
*
20+
* @return void
21+
*/
22+
public function boot()
23+
{
24+
$this->publishes(
25+
[
26+
__DIR__ . '/../../config/acl.php' => config_path('acl.php')
27+
],
28+
'config'
29+
);
30+
31+
$this->publishes(
32+
[
33+
__DIR__ . '/../../migrations/' => base_path('/database/migrations')
34+
],
35+
'migrations'
36+
);
37+
38+
$this->registerBladeDirectives();
39+
}
40+
41+
/**
42+
* Register any application services.
43+
*
44+
* @return void
45+
*/
46+
public function register()
47+
{
48+
$this->mergeConfigFrom(
49+
__DIR__ . '/../../config/acl.php', 'acl'
50+
);
51+
}
52+
53+
public function registerBladeDirectives()
54+
{
55+
// role
56+
Blade::directive('role', function ($expression) {
57+
return "<?php if (\Illuminate\Support\Facades\Auth::check() && Auth::user()->hasRole($expression)): ?>";
58+
});
59+
60+
Blade::directive('endrole', function () {
61+
return "<?php endif; ?>";
62+
});
63+
64+
// permission
65+
Blade::directive('permission', function ($expression) {
66+
return "<?php if (\Illuminate\Support\Facades\Auth::check() && Auth::user()->hasPermission($expression)): ?>";
67+
});
68+
69+
Blade::directive('endpermission', function () {
70+
return "<?php endif; ?>";
71+
});
72+
}
73+
}

0 commit comments

Comments
 (0)