/** * @param Device $device, 数据库实体 * @param DeviceIdentifier $deviceIdentifier ,自己构建实体 * @return bool */ public function update(Device $device, DeviceIdentifier $deviceIdentifier) { foreach ($deviceIdentifier as $k => $v) { $device->{$k} = $v; } return $device->save(); }
/** * 增加SN * @author Hanxiang */ public function addPost() { $input = Input::only('count'); if ((int) $input['count'] <= 0) { return redirect('/admin/devices')->with('result', false)->with('msg', "操作失败"); } for ($i = 1; $i <= $input['count']; $i++) { $sn = SNMaker::getSN(); $d = Device::where('sn', $sn)->first(); if ($d) { $i--; continue; } $device = new Device(); $device->model_id = 0; $device->manufacturer_sn = ''; $device->sn = $sn; $device->wx_device_id = 0; $device->uuid = ''; $device->major = 0; $device->minor = 0; $device->status = 0; $device->save(); } return redirect('/admin/devices'); }