Esempio n. 1
0
 /**
  * Update the block.
  *
  * @param Request $request
  * @param Model   $block
  *
  * @return json
  */
 public function update(BlockUserApiRequest $request, Block $block)
 {
     try {
         $attributes = $request->all();
         $block->update($attributes);
         $block = $block->presenter();
         $block['code'] = 2005;
         return response()->json($block)->setStatusCode(201, 'UPDATE_SUCCESS');
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 4005])->setStatusCode(400, 'UPDATE_ERROR');
     }
 }
Esempio n. 2
0
 /**
  * Update the block.
  *
  * @param Request $request
  * @param Model   $block
  *
  * @return Response
  */
 public function update(BlockAdminRequest $request, Block $block)
 {
     try {
         $attributes = $request->all();
         $block->update($attributes);
         return response()->json(['message' => trans('messages.success.updated', ['Module' => trans('block::block.name')]), 'code' => 204, 'redirect' => trans_url('/admin/block/block/' . $block->getRouteKey())], 201);
     } catch (Exception $e) {
         return response()->json(['message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/block/block/' . $block->getRouteKey())], 400);
     }
 }