kduma-oss / lv-permissions Goto Github PK
View Code? Open in Web Editor NEWSimple (really?) package to provide Roles and Permissions to Laravel 5
License: MIT License
Simple (really?) package to provide Roles and Permissions to Laravel 5
License: MIT License
in PermissionsServiceProvider.php, line 47
Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.
$this->app->singleton('permissions.adderhelper', function()
{
return new PermissionsAdderHelper();
});
//
// $this->commands('command.config.env');
}
/**
* Get the services provided by the provider.
*
Posted from SensioLabsInsight
in Helpers/PermissionsAdderHelper.php, line 106
Method names should be declared in
camelCase
. You should rename this class to comply with PSR-1.
}
/**
* @param $thing
*/
protected function _getIDListHelper($thing, $role=false)
{
if (is_object($thing)) {
return $thing->id;
} elseif (is_int($thing)) {
return $thing;
Posted from SensioLabsInsight
in Helpers/PermissionsHelper.php, line 31
This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.
function denyPermissions($permission, $user=null){
$can = self::can($permission, $user);
if(!$can){
abort(401);
exit;
}
return true;
}
}
Posted from SensioLabsInsight
in Helpers/PermissionsAdderHelper.php, line 82
Method names should be declared in
camelCase
. You should rename this class to comply with PSR-1.
/**
* @param $roles
* @param $permissions
* @return array
*/
protected function _getIDList($roles, $permissions)
{
$roles_id_list = [];
if (is_array($roles)) {
foreach ($roles as $role) {
$roles_id_list[] = $this->_getIDListHelper($role, true);
Posted from SensioLabsInsight
Laravel: 5.2
Declaration of KDuma\Permissions\Permissions::can() should be compatible with Illuminate\Foundation\Auth\User::can($ability, $arguments = Array)
in Helpers/PermissionsAdderHelper.php, line 28
Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.
function createRole($str, $name){
$role = Role::firstOrNew(['str_id' => $str]);
$role->name = $name;
$role->save();
return $role;
// $this->roles[$str] = $name;
}
function deleteRole($str){
Role::where('str_id', $str)->delete();
return true;
Posted from SensioLabsInsight
Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.
return $this->belongsToMany(config('permissions.models.Permission'))->withTimestamps();
}
// public function members()
// {
// return $this->hasMany('\App\Member');
// }
}
Posted from SensioLabsInsight
in Migrations/0000_00_00_000005_create_and_assign_roles_and_permissions.php, line 3
The class
Illuminate\Database\Schema\Blueprint
is declared but never used. You should remove theuse
statement.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAndAssignRolesAndPermissions extends Migration {
/**
Posted from SensioLabsInsight
in Migrations/0000_00_00_000006_create_administrator_account.php, line 4
The class
Illuminate\Database\Schema\Blueprint
is declared but never used. You should remove theuse
statement.
<?php
use App\User;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use KDuma\Permissions\Models\Role;
class CreateAdministratorAccount extends Migration {
Posted from SensioLabsInsight
in Helpers/PermissionsAdderHelper.php, line 34
Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.
}
function deleteRole($str){
Role::where('str_id', $str)->delete();
return true;
// unset($this->roles[$str]);
}
function createPermission($str, $name){
$permission = Permission::firstOrNew(['str_id' => $str]);
$permission->name = $name;
Posted from SensioLabsInsight
in Helpers/PermissionsAdderHelper.php, line 43
Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.
$permission = Permission::firstOrNew(['str_id' => $str]);
$permission->name = $name;
$permission->save();
return $permission;
// $this->permissions[$str] = $name;
// unset($this->permissions[$str]);
}
function deletePermission($str){
Permission::where('str_id', $str)->delete();
return true;
}
Posted from SensioLabsInsight
With booleans, only strict comparison (with
===
operator) should be used to lower bug risks and to improve performances.
{
return $this->belongsToMany(config('permissions.models.Role'))->withTimestamps();
}
protected function fetchPermissions(){
if($this->permissions_fetched == false) {
$cache_time = config('permissions.cache_time', 60);
$user = $this;
$getCallback = function() use ($user)
{
Posted from SensioLabsInsight
Hi,
$this->middleware('permission:permiss1:permiss2');
Dont Work.
Please help me!
in Helpers/PermissionsAdderHelper.php, line 42
Commented out code reduces readability and lowers the code confidence for other developers. If it's common usage for debug, it should not be committed. Using a version control system, such code can be safely removed.
function createPermission($str, $name){
$permission = Permission::firstOrNew(['str_id' => $str]);
$permission->name = $name;
$permission->save();
return $permission;
// $this->permissions[$str] = $name;
// unset($this->permissions[$str]);
}
function deletePermission($str){
Permission::where('str_id', $str)->delete();
return true;
Posted from SensioLabsInsight
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.