Table.php 817 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\api\model\plus\table;
  3. use app\common\model\plus\table\Table as TableModel;
  4. use app\common\model\plus\table\Record as RecordModel;
  5. /**
  6. * 表单模型
  7. */
  8. class Table extends TableModel
  9. {
  10. /**
  11. * 签到
  12. */
  13. public function add($user, $data)
  14. {
  15. $this->startTrans();
  16. try {
  17. $data['content'] = $data['tableData'];
  18. $data['user_id'] = $user['user_id'];
  19. $data['app_id'] = self::$app_id;
  20. (new RecordModel())->save($data);
  21. $this->where('table_id', '=', $data['table_id'])->inc('total_count')->update();
  22. $this->commit();
  23. return true;
  24. } catch (\Exception $e) {
  25. $this->error = $e->getMessage();
  26. $this->rollback();
  27. return false;
  28. }
  29. }
  30. }