app/Http/Controllers/InformController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
        $rules = array(
            'file' => 'required',
            'code' => 'required',
        );
        $user = Auth::user();
        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) return response()->json(array('result' => false, 'message' => 'invalid input field.'));
        $booking = Booking::where('code', $request->input('code'))->first();
        $booking->picture = url('') . '/img/upload/'.$user->id.'/' . $request->input('file');
        $booking->payment = 1;
        if ($booking->save()) {
            return response()->json(array('result' => true, 'message' => 'save success', 'data' => $booking));
        }
        return response()->json(array('result' => false, 'message' => 'save fail.'));
    }
public function update ( Request $ request , $ id ) { $ rules = array ( 'file' => 'required' , 'code' => 'required' , ) ; $ user = Auth :: user ( ) ; $ validator = Validator :: make ( $ request -> all ( ) , $ rules ) ; if ( $ validator -> fails ( ) ) return response ( ) -> json ( array ( 'result' => false , 'message' => 'invalid input field.' ) ) ; $ booking = Booking :: where ( 'code' , $ request -> input ( 'code' ) ) -> first ( ) ; $ booking -> picture = url ( '' ) . '/img/upload/' . $ user -> id . '/' . $ request -> input ( 'file' ) ; $ booking -> payment = 1 ; if ( $ booking -> save ( ) ) { return response ( ) -> json ( array ( 'result' => true , 'message' => 'save success' , 'data' => $ booking ) ) ; } return response ( ) -> json ( array ( 'result' => false , 'message' => 'save fail.' ) ) ; }
Update the specified resource in storage.
Update the specified resource in storage .