<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;

class PermissionController extends Controller
{
    //

    public function allPermission() {
        $allPermission = Permission::all();
    }

    public function createPermission(Request $request){

        Permission::create(['name' => $request->name]);

        $notification = array(
            'message' => 'Permission added successfully',
            'alert-type' => 'success',
        );

        return redirect()->route('permission.add')->with($notification);
        /*$roleadmin = Role::create(['name' => 'Admin']);
        $rolesaccosmanager = Role::create(['name' => 'Saccos Manager']);

        Permission::create(['name' => 'create_hisa']);
        Permission::create(['name' => 'edit_hisa']);
        Permission::create(['name' => 'update_hisa']);
        Permission::create(['name' => 'delete_hisa']);

        $roleadmin->givePermissionTo('create_hisa');
        $roleadmin->givePermissionTo('edit_hisa');
        $roleadmin->givePermissionTo('update_hisa');

        $rolesaccosmanager->givePermissionTo('create_hisa');
        $rolesaccosmanager->givePermissionTo('edit_hisa');
        $rolesaccosmanager->givePermissionTo('update_hisa');
        $rolesaccosmanager->givePermissionTo('delete_hisa');
*/
    }

    public function addPermission() {
        return view('admin.user_permission.userpermission_add');
    }
}
