ScoreLog.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\admin\controller\user;
  3. use Throwable;
  4. use app\admin\model\User;
  5. use app\admin\model\UserScoreLog;
  6. use app\common\controller\Backend;
  7. class ScoreLog extends Backend
  8. {
  9. /**
  10. * @var object
  11. * @phpstan-var UserScoreLog
  12. */
  13. protected object $model;
  14. protected array $withJoinTable = ['user'];
  15. // 排除字段
  16. protected string|array $preExcludeFields = ['create_time'];
  17. protected string|array $quickSearchField = ['user.username', 'user.nickname'];
  18. public function initialize(): void
  19. {
  20. parent::initialize();
  21. $this->model = new UserScoreLog();
  22. }
  23. /**
  24. * 添加
  25. * @param int $userId
  26. * @throws Throwable
  27. */
  28. public function add(int $userId = 0): void
  29. {
  30. if ($this->request->isPost()) {
  31. parent::add();
  32. }
  33. $user = User::where('id', $userId)->find();
  34. if (!$user) {
  35. $this->error(__("The user can't find it"));
  36. }
  37. $this->success('', [
  38. 'user' => $user
  39. ]);
  40. }
  41. }