App\Repositories\Eloquent\PermissionRepositoryEloquent::create PHP Method

create() public method

public create ( array $input ) : boolean
$input array
return boolean
    public function create(array $input)
    {
        $permission = new Permission();
        $permission->name = $input['name'];
        $permission->display_name = $input['display_name'];
        $permission->description = $input['description'];
        if ($permission->save()) {
            //For each role, load role, collect perms, add perm to perms, flush perms, read perms
            //if (isset($input['permission_roles']) && count($input['permission_roles']) > 0) {
            //    foreach ($input['permission_roles'] as $role_id) {
            //        //Get the role
            //        $role = $this->roles->find($role_id);
            //        //Get the roles permissions into an array
            //        $role_permissions = $role->permissions->lists('id')->all();
            //        if (count($role_permissions) >= 1) {
            //            //Role has permissions, gather them first
            //            //Add this new permission id to the role
            //            array_push($role_permissions, $permission->id);
            //            //For some reason the lists() casts as a string, convert all to int
            //            $role_permissions_temp = array();
            //            foreach ($role_permissions as $rp) {
            //                array_push($role_permissions_temp, (int) $rp);
            //            }
            //            $role_permissions = $role_permissions_temp;
            //            //Sync the permissions to the role
            //            $role->permissions()->sync($role_permissions);
            //        } else {
            //            //Role has no permissions, add the 1
            //            $role->permissions()->sync([$permission->id]);
            //        }
            //    }
            //}
            return true;
        }
        throw new GeneralException('There was a problem creating this permission. Please try again.');
    }
PermissionRepositoryEloquent