public function update(PageRequest $request, Page $pages)
 {
     foreach ($request->all()['data']['attributes'] as $key => $value) {
         if (isset($pages->{$key})) {
             $pages->{$key} = $value;
         }
     }
     // fetch location
     $pages->save();
     $resource = new Item($pages, new PageTransformer(), 'pages');
     return $this->fractal()->createData($resource)->toJson();
 }
Esempio n. 2
0
 public function testPatchPages()
 {
     $pageObject = factory(Page::class)->create();
     $pageData = ['data' => ['type' => 'pages', 'attributes' => $pageObject->toArray()]];
     $pageData['data']['attributes']['display'] = 'Updated Page Display';
     $pageData = json_encode($pageData);
     $response = $this->callPatch(self::API_URL . $pageObject->id, $pageData);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
     $this->assertNotNull($page = json_decode($response->getContent())->data);
     $this->assertNotEmpty($page->id);
     // test to make sure the form was created
     $updatedPage = Page::findOrFail($page->id);
     $this->assertEquals('Updated Page Display', $updatedPage->display);
 }