app/Http/Controllers/API/LoopbackAPIController.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)
{
$input = $request->all();
$validator = Validator::make($input, [
    'name' => 'required',
]);
if($validator->fails()){
return $this->sendError('Validation Error.', $validator->errors());
}
$post = Loopback::find($id);
if (is_null($post)) {
return $this->sendError('Post not found.');
}
$post->name = $input['name'];
$post->save();
return $this->sendResponse($post->toArray(), 'Post updated successfully.');
}
public function update ( Request $ request , $ id ) { $ input = $ request -> all ( ) ; $ validator = Validator :: make ( $ input , [ 'name' => 'required' , ] ) ; if ( $ validator -> fails ( ) ) { return $ this -> sendError ( 'Validation Error.' , $ validator -> errors ( ) ) ; } $ post = Loopback :: find ( $ id ) ; if ( is_null ( $ post ) ) { return $ this -> sendError ( 'Post not found.' ) ; } $ post -> name = $ input [ 'name' ] ; $ post -> save ( ) ; return $ this -> sendResponse ( $ post -> toArray ( ) , 'Post updated successfully.' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .