BaseController.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Controllers\QuickApp;
  3. use App\Modules\User\Services\QappUserService;
  4. use Illuminate\Routing\Controller;
  5. /**
  6. * @property $user_info 用户基本信息
  7. * @property $uid
  8. * @property $phone 手机号
  9. * @property $distribution_channel_id 渠道号ID
  10. * @property $send_order_id 派单ID
  11. */
  12. class BaseController extends Controller
  13. {
  14. private $field = [];
  15. public function __get($name)
  16. {
  17. if (!isset($this->field[$name])) {
  18. // QappUserService::setGolableUserStatic(env('QUICKAPP_TEST_UID',162261523));
  19. $qapp_user = QappUserService::getGolableUserStatic();
  20. if ($name == 'user_info') {
  21. $this->field[$name] = $qapp_user->user;
  22. }
  23. if ($name == 'uid') {
  24. $this->field[$name] = $qapp_user->uid;
  25. }
  26. if ($name == 'phone') {
  27. $this->field[$name] = $qapp_user->phone;
  28. }
  29. if ($name == 'distribution_channel_id') {
  30. $this->field[$name] = $qapp_user->user->distribution_channel_id;
  31. }
  32. if ($name == 'send_order_id') {
  33. $this->field[$name] = $qapp_user->send_order_id;
  34. }
  35. }
  36. return $this->field[$name];
  37. }
  38. }