app/Http/Controllers/Admin/ReceivedPaymentsController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Order  $order
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Order $receivedpayment)
    {
        $validator = Validator::make($request->all(), [
            'left_hours'        => ['required', 'string'],
            'status_id'         => ['required', 'int'],
        ]);
        if ($validator->fails())
        {
            $request->session()->flash('error', $validator->messages()->first());
            return redirect()->route('admin.receivedpayments.edit', $receivedpayment);
        }
        $data = $request->all();
        if ($request->input('action') == 'update')
        {
            $receivedpayment->left_hours = $data['left_hours'];
            if ($receivedpayment->save()) {
                $request->session()->flash('success', 'You have modified orders!');
            }
            $orderhistory = OrderHistory::create([
                'order_id'          => $receivedpayment->id,
                'order_status_id'   => $data['status_id'],
                'notify'            => '0',
                'comment'           => "Remaining Hours Update From ". $receivedpayment->left_hours . ' To ' . $data['left_hours']
            ]);
            return redirect()->route('admin.receivedpayments.edit', $receivedpayment);
        }
        else {
            $orderhistory = OrderHistory::create([
                'order_id'          => $receivedpayment->id,
                'status_id'          => $data['status_id'],
                'notify'            => '0',
                'comment'           => $data['comment']
            ]);
            $request->session()->flash('success', 'You have modified order histories!');
            return redirect()->route('admin.receivedpayments.edit', $receivedpayment);
        }    
    }
public function update ( Request $ request , Order $ receivedpayment ) { $ validator = Validator :: make ( $ request -> all ( ) , [ 'left_hours' => [ 'required' , 'string' ] , 'status_id' => [ 'required' , 'int' ] , ] ) ; if ( $ validator -> fails ( ) ) { $ request -> session ( ) -> flash ( 'error' , $ validator -> messages ( ) -> first ( ) ) ; return redirect ( ) -> route ( 'admin.receivedpayments.edit' , $ receivedpayment ) ; } $ data = $ request -> all ( ) ; if ( $ request -> input ( 'action' ) == 'update' ) { $ receivedpayment -> left_hours = $ data [ 'left_hours' ] ; if ( $ receivedpayment -> save ( ) ) { $ request -> session ( ) -> flash ( 'success' , 'You have modified orders!' ) ; } $ orderhistory = OrderHistory :: create ( [ 'order_id' => $ receivedpayment -> id , 'order_status_id' => $ data [ 'status_id' ] , 'notify' => '0' , 'comment' => " Remaining Hours Update From  " . $ receivedpayment -> left_hours . ' To ' . $ data [ 'left_hours' ] ] ) ; return redirect ( ) -> route ( 'admin.receivedpayments.edit' , $ receivedpayment ) ; } else { $ orderhistory = OrderHistory :: create ( [ 'order_id' => $ receivedpayment -> id , 'status_id' => $ data [ 'status_id' ] , 'notify' => '0' , 'comment' => $ data [ 'comment' ] ] ) ; $ request -> session ( ) -> flash ( 'success' , 'You have modified order histories!' ) ; return redirect ( ) -> route ( 'admin.receivedpayments.edit' , $ receivedpayment ) ; } }
Update the specified resource in storage.
Update the specified resource in storage .