<?php
 namespace App\Modules\Base; use App\Modules\PrizePool\PrizePoolPayDrawStatus; use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\View; use TechOnline\Laravel\Dao\ModelUtil; use TechOnline\Utils\StrUtil; trait ActivityBaseTrait { protected $activity = false; protected function settingSetUp() { if (false === $this->activity) { $this->activity = ModelUtil::get('module_' . StrUtil::uncamelize(self::MODULE) . '_activity', ['alias' => $this->alias]); } if (empty($this->activity)) { header('Location: /'); exit(); } $memberUser = Session::get('_memberUser'); $this->memberUserId = $memberUser['id']; $this->memberUser = ModelUtil::getWithCache('member_user', ['id' => $this->memberUserId]); View::share('_activity', $this->activity); View::share('_memberUser', $this->memberUser); View::share('_base', '/m/' . StrUtil::uncamelize(self::MODULE) . '_' . $this->activity['alias']); } protected function getPrepareResultHtml() { if ($this->activity['payDrawEnable']) { $payDraw = ModelUtil::get('module_prize_pool_pay_draw', [ 'memberUserId' => $this->memberUserId, 'userId' => $this->userId(), 'activityType' => self::MODULE, 'activityId' => $this->activity['id'], 'status' => PrizePoolPayDrawStatus::NOT_USED, ]); if (empty($payDraw)) { return View::make('res::activity.payDraw', [ 'activity' => $this->activity, ])->render(); } } return ''; } protected function _view($view, $viewData = []) { $mobileView = 'res::' . self::MODULE . '.' . $this->activity['template'] . '.mobile.' . $view; return view($mobileView, $viewData); } public function _viewRender($view, $viewData) { $mobileView = 'res::' . self::MODULE . '.' . $this->activity['template'] . '.mobile.' . $view; return View::make($mobileView, $viewData)->render(); } }