public function assignPermission($permission)
    {
        return $this->mapArray($permission, function ($permission) {

            $permissionId = $this->parsePermissionId($permission);

            if ( ! $this->permissions->keyBy('id')->has($permissionId) ) {
                $this->permissions()->attach($permissionId);

                return $permission;
            }

            return false;
        });
    }
public function assignPermission($permission)
    {
        return $this->mapArray($permission, function ($permission) {

            $permissionId = $this->parsePermissionId($permission);

            if ( ! $this->permissions->keyBy('id')->has($permissionId) ) {
                $this->permissions()->attach($permissionId);

                return $permission;
            }

            return false;
        });
    }
public function assignPermission ( $ permission ) { return $ this -> mapArray ( $ permission , function ( $ permission ) { $ permissionId = $ this -> parsePermissionId ( $ permission ) ; if ( ! $ this -> permissions -> keyBy ( 'id' ) -> has ( $ permissionId ) ) { $ this -> permissions ( ) -> attach ( $ permissionId ) ; return $ permission ; } return false ; } ) ; }
Assigns the given permission to the user.

@param  collection|object|array|string|int $permission
@return bool
Assigns the given permission to the user .