app/Http/Controllers/Admin/RoleController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Role  $role
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $this->validate(request(), [
            'role_title' => 'required|unique:roles,role_title,'.$id,
            'role_arr' => 'required',
        ]);
        $ip = $request->ip();
        $allowed_menus= Adminmenu::whereIn('id', $request->get('role_arr'))->get();
        foreach($allowed_menus as $val){
            $permissions[$val->slug]=  true;
        }
        $permission=implode(",",$request->get('role_arr'));
        $role=   Role::find($id);
        $role->role_title=$request->get('role_title');
        $role->permission=$permission;
        $role->permissions=json_encode($permissions);
        $role->last_modified_by=auth()->user()->id;
        $role->modified_ip=$ip;
        $date=date_create($request->get('date'));
        $format = date_format($date,"Y-m-d");
        $role->updated_at = strtotime($format);
        $role->save();
        return redirect()->back()->with('success', 'Role has been updated successfully.');
    }
public function update ( Request $ request , $ id ) { $ this -> validate ( request ( ) , [ 'role_title' => 'required|unique:roles,role_title,' . $ id , 'role_arr' => 'required' , ] ) ; $ ip = $ request -> ip ( ) ; $ allowed_menus = Adminmenu :: whereIn ( 'id' , $ request -> get ( 'role_arr' ) ) -> get ( ) ; foreach ( $ allowed_menus as $ val ) { $ permissions [ $ val -> slug ] = true ; } $ permission = implode ( " , " , $ request -> get ( 'role_arr' ) ) ; $ role = Role :: find ( $ id ) ; $ role -> role_title = $ request -> get ( 'role_title' ) ; $ role -> permission = $ permission ; $ role -> permissions = json_encode ( $ permissions ) ; $ role -> last_modified_by = auth ( ) -> user ( ) -> id ; $ role -> modified_ip = $ ip ; $ date = date_create ( $ request -> get ( 'date' ) ) ; $ format = date_format ( $ date , " Y-m-d " ) ; $ role -> updated_at = strtotime ( $ format ) ; $ role -> save ( ) ; return redirect ( ) -> back ( ) -> with ( 'success' , 'Role has been updated successfully.' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .