app/Http/Controllers/SampleController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Sample_data  $sample_data
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Sample_data $sample_data)
    {
        $rules = array(
            'first_name' => 'required',
            'last_name' => 'required'
        );
        $error = Validator::make($request->all(), $rules);
        if($error->fails())
        {
            return response()->json(['errors' => $error->errors()->all()]);
        }
        $form_data = array(
            'first_name' => $request->first_name,
            'last_name' => $request->last_name
        );
        Sample_data::whereId($request->hidden_id)->update($form_data);
        return response()->json(['success' => 'Data updated successfully']);
    }
public function update ( Request $ request , Sample_data $ sample_data ) { $ rules = array ( 'first_name' => 'required' , 'last_name' => 'required' ) ; $ error = Validator :: make ( $ request -> all ( ) , $ rules ) ; if ( $ error -> fails ( ) ) { return response ( ) -> json ( [ 'errors' => $ error -> errors ( ) -> all ( ) ] ) ; } $ form_data = array ( 'first_name' => $ request -> first_name , 'last_name' => $ request -> last_name ) ; Sample_data :: whereId ( $ request -> hidden_id ) -> update ( $ form_data ) ; return response ( ) -> json ( [ 'success' => 'Data updated successfully' ] ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//