app/Http/Controllers/RoleController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        Gate::authorize('haveaccess','role.create'); 
        $request->validate([
            'name'          => 'required|max:50|unique:roles,name',
            'slug'          => 'required|max:50|unique:roles,slug',
            'full-access'   => 'required|in:yes,no'
        ]);
        $role = Role::create($request->all());
        Validacion 
        if ($request->get('permission')) {
            return $request->all();
            $role->permissions()->sync($request->get('permission'));
        }
        return redirect()->route('role.index')
            ->with('status_success','Role saved successfully'); 
    }
public function store ( Request $ request ) { Gate :: authorize ( 'haveaccess' , 'role.create' ) ; $ request -> validate ( [ 'name' => 'required|max:50|unique:roles,name' , 'slug' => 'required|max:50|unique:roles,slug' , 'full-access' => 'required|in:yes,no' ] ) ; $ role = Role :: create ( $ request -> all ( ) ) ; $ role -> permissions ( ) -> sync ( $ request -> get ( 'permission' ) ) ; return redirect ( ) -> route ( 'role.index' ) -> with ( 'status_success' , 'Role saved successfully' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//aplique para el store y create // //Validacion  //if ($request->get('permission')) { //return $request->all(); //}