MCPcopy Create free account
hub / github.com/CoderOpen/waimai / PublicController

Class PublicController

app/Http/Controllers/Api/ChiHe/PublicController.php:17–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15use Tymon\JWTAuth\Facades\JWTAuth;
16
17class PublicController extends BaseController
18{
19 function project(Request $request)
20 {
21 //return $this->success(['age' => 1]);
22 $projects = Project::where([
23 'status' => 1
24 ]);
25 $platform = $request->get('platform');
26 if ($platform == 'h5' || ($platform == 'qq')) {
27 $projects = $projects->orderBy('h5_sort', 'DESC');
28 } else {
29 $projects = $projects->orderBy('sort', 'DESC');
30 }
31 $projects = $projects->orderBy('created_at', 'DESC')->get()->toArray();
32 if ($platform == 'h5' || ($platform == 'qq')) {
33 foreach ($projects as $k => $v) {
34 if (empty($v['url'])) {
35 unset($projects[$k]);
36 }
37 }
38
39 }
40 return $this->success($projects);
41 }
42
43
44 /**
45 * 发送订阅消息
46 */
47 function sendMsg()
48 {
49 $userId = 'ocBpY4zNqTzD5JfTEsVLSHQVJSyY';
50 $data = [
51 'template_id' => 'kXBmBC98SYth6HltqOVc-3_Y2EncSybE2-0TMvyCXDk', // 所需下发的订阅模板id
52 'touser' => $userId, // 接收者(用户)的 openid
53 'page' => 'index/index', // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
54 'data' => [ // 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
55 'thing2' => [
56 'value' => '快来领优惠券啦',
57 ],
58 'thing4' => [
59 'value' => '炒鸡棒棒哒',
60 ],
61 ],
62 ];
63 $config = 'chi_he';
64 $app = \EasyWeChat::miniProgram($config); // 小程序
65 $res = $app->subscribe_message->send($data);
66 return $this->success($res);
67
68 }
69
70
71 /**
72 * @return \Illuminate\Http\JsonResponse
73 *
74 * 第三方登录

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected