app/Http/Controllers/Admin/DefaultWagesController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\DefaultWage  $defaultWage
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, DefaultWage $defaultwage)
    {
        if (Gate::denies('manage-payments'))
        {
            return redirect()->route('admin.defaultwages.index');
        }
        $validator = Validator::make($request->all(), [
            'wage_usa'          => ['required', 'string'],
            'wage_canada'       => ['required', 'string'],
            'wage_alberta'      => ['required', 'string'],
            'invoice_usa'       => ['nullable', 'string'],
            'invoice_canada'    => ['nullable', 'string'],
            'invoice_alberta'   => ['nullable', 'string'],
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('admin.defaultwages.index');
        }
        $data = $request->all();
        foreach($data as $key => $value)
        {
            if (isset($defaultwage[$key]))
            {
                $defaultwage[$key] = $value;
            }
        }
        if (!$defaultwage -> save())
        {
            $request->session()->flash('error', "There is an error modifying Base Invoice Rates!");
            return redirect()->route('admin.defaultwages.index');
        }
        $request->session()->flash('success', "You have successfully modified Base Invoice Rates!");
        return view('admin.defaultwages.index') -> with('defaultwage', $defaultwage);
    }
public function update ( Request $ request , DefaultWage $ defaultwage ) { if ( Gate :: denies ( 'manage-payments' ) ) { return redirect ( ) -> route ( 'admin.defaultwages.index' ) ; } $ validator = Validator :: make ( $ request -> all ( ) , [ 'wage_usa' => [ 'required' , 'string' ] , 'wage_canada' => [ 'required' , 'string' ] , 'wage_alberta' => [ 'required' , 'string' ] , 'invoice_usa' => [ 'nullable' , 'string' ] , 'invoice_canada' => [ 'nullable' , 'string' ] , 'invoice_alberta' => [ 'nullable' , 'string' ] , ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'admin.defaultwages.index' ) ; } $ data = $ request -> all ( ) ; foreach ( $ data as $ key => $ value ) { if ( isset ( $ defaultwage [ $ key ] ) ) { $ defaultwage [ $ key ] = $ value ; } } if ( ! $ defaultwage -> save ( ) ) { $ request -> session ( ) -> flash ( 'error' , " There is an error modifying Base Invoice Rates! " ) ; return redirect ( ) -> route ( 'admin.defaultwages.index' ) ; } $ request -> session ( ) -> flash ( 'success' , " You have successfully modified Base Invoice Rates! " ) ; return view ( 'admin.defaultwages.index' ) -> with ( 'defaultwage' , $ defaultwage ) ; }
Update the specified resource in storage.
Update the specified resource in storage .