Skip to content

Commit

Permalink
Merge pull request #69 from httpoz/feature/upgrade-to-laravel-6
Browse files Browse the repository at this point in the history
Add support for Laravel 6
  • Loading branch information
httpoz authored Nov 1, 2019
2 parents dd4081c + d749ace commit 97c4e5d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ language: php
dist: trusty

php:
- 7.1.3
- 7.2

matrix:
fast_finish: true
allow_failures:
- php: 7.1.3
- php: 7.2

before_script:
- travis_retry composer self-update
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
}],
"minimum-stability": "dev",
"require": {
"php": ">=7.1.3",
"illuminate/support": "~5.0",
"illuminate/cache": "~5.0"
"php": "^7.2",
"illuminate/support": "~6.0",
"illuminate/cache": "~6.0"
},
"require-dev": {
"orchestra/database": "~3.8.0",
"orchestra/testbench": "~3.8.0",
"phpunit/phpunit": "~7.0"
"orchestra/database": "^4.0",
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "~8.0"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 4 additions & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
*/

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use Illuminate\Support\Str;

$factory->define( \HttpOz\Roles\Tests\Stubs\User::class, function ( Faker\Generator $faker ) {
static $password;

return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt( 'secret' ),
'remember_token' => str_random( 10 ),
'remember_token' => Str::random( 10 ),
];
} );

Expand Down
9 changes: 5 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Roles for Laravel 5.3 to 5.8
# Roles for Laravel 5 / 6
Powerful package for handling roles in Laravel

[![Build Status](https://travis-ci.org/httpoz/roles.svg)](https://travis-ci.org/httpoz/roles)
Expand All @@ -15,10 +15,11 @@ Powerful package for handling roles in Laravel
| 5.5.* | [Roles 3.0.x](https://github.com/httpoz/roles/tree/3.0) |
| 5.6.* | [Roles 3.1.x](https://github.com/httpoz/roles/tree/v3.1.0) |
| 5.7.* | [Roles 3.2.x](https://github.com/httpoz/roles/tree/3.2.0) |
| 5.8.* | Roles 3.3.x
| 5.8.* | [Roles 3.3.x](https://github.com/httpoz/roles/tree/3.3.0) |
| 6.x | Roles 4.x

#### History
This project was largely inspired by Roman's [romanbican/roles](https://github.com/romanbican/roles/) Laravel package. However at the time Laravel 5.3 was released his package was not actively maintained. I have ommitted permissions in this package in favour of Laravel's [Authorization](https://laravel.com/docs/5.3/authorization). I intend to keep this package as simple and minimal as is possible.
This project was largely inspired by Roman's [romanbican/roles](https://github.com/romanbican/roles/) Laravel package. However at the time Laravel 5.3 was released his package was not actively maintained. I have ommitted permissions in this package in favour of Laravel's [Authorization](https://laravel.com/docs/6.x/authorization). I intend to keep this package as simple and minimal as is possible.

- [Installation](#installation)
- [Composer](#composer)
Expand All @@ -43,7 +44,7 @@ This package is very easy to set up. There are only couple of steps.
### Composer
Add the package to your project via composer.
```bash
composer require httpoz/roles:~v3.3.0
composer require httpoz/roles:^v4.0
```

### Config File And Migrations
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/HasRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ private function getArrayFrom( $argument ) {
* @return mixed
*/
public function __call( $method, $parameters ) {
if ( starts_with( $method, 'is' ) ) {
return $this->isRole( snake_case( substr( $method, 2 ), config( 'roles.separator' ) ) );
if ( Str::startsWith( $method, 'is' ) ) {
return $this->isRole( Str::snake( substr( $method, 2 ), config( 'roles.separator' ) ) );
}

return parent::__call( $method, $parameters );
Expand Down
6 changes: 4 additions & 2 deletions src/Traits/Sluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace HttpOz\Roles\Traits;

use Illuminate\Support\Str;

trait Sluggable
{
/**
Expand All @@ -13,12 +15,12 @@ trait Sluggable

public function setSlugAttribute($value)
{
$this->attributes['slug'] = str_slug($value, config('roles.separator'));
$this->attributes['slug'] = Str::slug($value, config('roles.separator'));
}

public function setGroupAttribute($value)
{
$this->attributes['group'] = str_slug($value, config('roles.separator'));
$this->attributes['group'] = Str::slug($value, config('roles.separator'));
}

}

0 comments on commit 97c4e5d

Please sign in to comment.