コード例 #1
0
ファイル: MpService.php プロジェクト: hachi-zzq/dajiayao
 /**
  * @param WeixinMp $wxmp 要修改的实体
  * @param Mp $mp 微信实体
  * @return bool
  */
 public function update(WeixinMp $wxmp, Mp $mp)
 {
     foreach ($mp as $k => $attr) {
         $wxmp->{$k} = $attr;
     }
     return $wxmp->save();
 }
コード例 #2
0
ファイル: AppController.php プロジェクト: hachi-zzq/dajiayao
 public function saveOrUpdateMp($app_id)
 {
     $input = Input::only('name', 'appid', 'appsecret', 'comment', 'mp_id');
     $app = $this->appService->getAppById($app_id);
     if (!$app) {
         \App::abort(404, '没有该应用');
     }
     if ($app->type != App::TYPE_WEIXIN) {
         return redirect()->back()->with('error_tips', '该应用类型不是微信')->withInput();
     }
     $name = $input['name'];
     $appId = $input['appid'];
     $appSecret = $input['appsecret'];
     $comment = $input['comment'];
     $mpId = $input['mp_id'];
     if (!($name and $appId and $appSecret and $mpId)) {
         return redirect()->back()->with('error_tips', '提交数据不完整')->withInput();
     }
     $mp = $this->mpService->getMpByAppId($app_id);
     if (!$mp) {
         $mp = new WeixinMp();
         $mp->app_id = $app_id;
     }
     $mp->name = $name;
     $mp->appid = $appId;
     $mp->appsecret = $appSecret;
     $mp->comment = $comment;
     $mp->app_id = $app_id;
     $mp->mp_id = $mpId;
     $mp->save();
     return redirect()->back()->with("success_tips", "操作成功!");
 }