<commit_before><?php namespace GeneaLabs\LaravelGovernor\Http\Controllers;

use GeneaLabs\LaravelGovernor\Action;
use GeneaLabs\LaravelGovernor\Entity;
use GeneaLabs\LaravelGovernor\Http\Requests\CreateRoleRequest;
use GeneaLabs\LaravelGovernor\Http\Requests\UpdateRoleRequest;
use GeneaLabs\LaravelGovernor\Ownership;
use GeneaLabs\LaravelGovernor\Permission;
use GeneaLabs\LaravelGovernor\Role;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;

/**
 * Class RolesController
 * @package GeneaLabs\LaravelGovernor\Controllers
 */
class RolesController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * @return mixed
     */
    public function index()
    {
        $this->authorize('view', (new Role()));
        $roles = Role::orderBy('name')->get();

        return view('genealabs-laravel-governor::roles.index', compact('roles'));
    }

    /**
     * @return mixed
     */
    public function create()
    {
        $role = new Role();
        $this->authorize('create', $role);

        return view('genealabs-laravel-governor::roles.create', compact('role'));
    }

    /**
     * @return mixed
     */
    public function store(CreateRoleRequest $request)
    {
        Role::create($request->all());

        return redirect()->route('genealabs.laravel-governor.roles.index');
    }

    /**
     * @param $name
     * @return mixed
     */
    public function edit($name)
    {
        $role = Role::with('permissions')->find($name);
        $this->authorize($role);
        $entities = Entity::all();
        $actions = Action::all();
        $ownerships = Ownership::all();
        $permissionMatrix = [];

        foreach ($entities as $entity) {
            foreach ($actions as $action) {<commit_msg>Exclude _token from being saved with new role<commit_after><?php namespace GeneaLabs\LaravelGovernor\Http\Controllers;

use GeneaLabs\LaravelGovernor\Action;
use GeneaLabs\LaravelGovernor\Entity;
use GeneaLabs\LaravelGovernor\Http\Requests\CreateRoleRequest;
use GeneaLabs\LaravelGovernor\Http\Requests\UpdateRoleRequest;
use GeneaLabs\LaravelGovernor\Ownership;
use GeneaLabs\LaravelGovernor\Permission;
use GeneaLabs\LaravelGovernor\Role;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;

/**
 * Class RolesController
 * @package GeneaLabs\LaravelGovernor\Controllers
 */
class RolesController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    /**
     * @return mixed
     */
    public function index()
    {
        $this->authorize('view', (new Role()));
        $roles = Role::orderBy('name')->get();

        return view('genealabs-laravel-governor::roles.index', compact('roles'));
    }

    /**
     * @return mixed
     */
    public function create()
    {
        $role = new Role();
        $this->authorize('create', $role);

        return view('genealabs-laravel-governor::roles.create', compact('role'));
    }

    /**
     * @return mixed
     */
    public function store(CreateRoleRequest $request)
    {
        Role::create($request->except(['_token']));

        return redirect()->route('genealabs.laravel-governor.roles.index');
    }

    /**
     * @param $name
     * @return mixed
     */
    public function edit($name)
    {
        $role = Role::with('permissions')->find($name);
        $this->authorize($role);
        $entities = Entity::all();
        $actions = Action::all();
        $ownerships = Ownership::all();
        $permissionMatrix = [];

        foreach ($entities as $entity) {
            foreach ($actions as $action) {
{'fraction_non_alphanumeric': 0.1449986372308531, 'fraction_numerical': 0.0, 'mean_word_length': 2.989130434782609, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3734965', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1115, 'n_words': 193}