Пример #1
0
 public function UpdateAction($id)
 {
     //Since we don't have laravel's input class registered, we'll just use what I started with.
     $body = $this->detectRequestBody();
     $image = json_decode(stream_get_contents($body), true);
     $thisimg = Image::findOrFail($id);
     //set each thing on image to correct value
     foreach ($thisimg->getFillable() as $key) {
         if (isset($image[$key])) {
             $thisimg->{$key} = $image[$key];
         }
     }
     //var_dump($thisimg);
     //and save it
     $thisimg->save();
     //return the json object
     return $thisimg->toJSON();
 }