Exemplo n.º 1
0
 /**
  * 设备信息更新
  * Update the specified resource in storage.
  *
  * @param  Request $request
  * @param  int $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $device = Device::current();
     if ($device->id != $id) {
         App::abort(403);
     }
     $data = $request::only(['alias', 'network_type']);
     $data = array_filter($data, 'strlen');
     $validator = Validator::make($data, Device::update_rules($device->user_id), Device::messages());
     if ($validator->fails()) {
         return Response::errors($validator->errors(), 400);
     }
     $device->fill($data);
     $device->save();
     return Response::json($device);
 }