├── .env.example ├── .gitattributes ├── .gitignore ├── README.md ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── RegisterController.php │ │ │ └── ResetPasswordController.php │ │ └── Controller.php │ ├── Kernel.php │ └── Middleware │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php └── User.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── database.php ├── filesystems.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ └── 2014_10_12_100000_create_password_resets_table.php └── seeds │ └── DatabaseSeeder.php ├── modules └── WechatPlatform │ ├── .gitignore │ ├── .php_cs │ ├── .travis.yml │ ├── README.md │ ├── composer.json │ ├── migrations │ ├── 2018_03_09_100235_create_authorizers_table.php │ ├── 2018_03_09_125705_create_oauth2_tokens_table.php │ ├── 2018_03_20_258931_add_type_and_mini_info_to_authorizers_table.php │ ├── 2018_08_06_660235_create_testers_table.php │ ├── 2018_08_09_587324_create_code_publish_table.php │ ├── 2018_08_15_124568_create_theme_table.php │ ├── 2018_08_15_234764_create_theme_template_table.php │ └── 2018_08_15_347643_create_theme_items_table.php │ ├── resources │ └── views │ │ ├── customer │ │ └── index.blade.php │ │ ├── includes │ │ └── common.blade.php │ │ ├── mini │ │ ├── code │ │ │ ├── index.blade.php │ │ │ ├── log.blade.php │ │ │ ├── model.blade.php │ │ │ └── script.blade.php │ │ ├── code_template │ │ │ ├── draft_list.blade.php │ │ │ └── template_list.blade.php │ │ ├── domain │ │ │ ├── index.blade.php │ │ │ └── script.blade.php │ │ ├── layouts │ │ │ └── bootstrap_modal.blade.php │ │ ├── tester │ │ │ └── index.blade.php │ │ └── theme │ │ │ ├── bars.blade.php │ │ │ ├── bars_create.blade.php │ │ │ ├── bars_edit.blade.php │ │ │ ├── create.blade.php │ │ │ ├── edit.blade.php │ │ │ ├── index.blade.php │ │ │ ├── items.blade.php │ │ │ └── script.blade.php │ │ ├── platform │ │ └── auth.blade.php │ │ └── wechat │ │ └── index.blade.php │ ├── scrutinizer.yml │ └── src │ ├── Console │ └── InstallCommand.php │ ├── Http │ ├── Controllers │ │ ├── Admin │ │ │ ├── CodeController.php │ │ │ ├── CodeTemplateController.php │ │ │ ├── CustomerController.php │ │ │ ├── DomainController.php │ │ │ ├── MiniProgramController.php │ │ │ ├── TesterController.php │ │ │ ├── ThemeController.php │ │ │ ├── UploadController.php │ │ │ └── WechatController.php │ │ ├── AuthorizerController.php │ │ ├── BroadcastController.php │ │ ├── CardController.php │ │ ├── Controller.php │ │ ├── CouponController.php │ │ ├── DataController.php │ │ ├── FansController.php │ │ ├── FansGroupController.php │ │ ├── JsController.php │ │ ├── MediasController.php │ │ ├── MenuController.php │ │ ├── MiniProgram │ │ │ ├── AppCodeController.php │ │ │ ├── BaseController.php │ │ │ ├── CodeController.php │ │ │ ├── DomainController.php │ │ │ ├── StaffController.php │ │ │ ├── TemplateMessageController.php │ │ │ └── TesterController.php │ │ ├── NoticeController.php │ │ ├── NotifyController.php │ │ ├── OAuthController.php │ │ ├── PlatformController.php │ │ ├── QRCodeController.php │ │ ├── ShortenController.php │ │ └── StaffController.php │ └── Middleware │ │ ├── ClientVerify.php │ │ └── ParameterVerify.php │ ├── Models │ ├── Authorizer.php │ ├── Clients.php │ ├── CodePublish.php │ ├── Oauth2Token.php │ ├── Testers.php │ ├── Theme.php │ ├── ThemeItems.php │ └── ThemeTemplate.php │ ├── Providers │ ├── RouteServiceProvider.php │ └── WechatPlatformServiceProvider.php │ ├── Repositories │ ├── AuthorizerRepository.php │ ├── ClientsRepository.php │ ├── CodePublishRepository.php │ ├── OAuthTokenRepository.php │ ├── TesterRepository.php │ ├── ThemeItemsRepository.php │ ├── ThemeRepository.php │ └── ThemeTemplateRepository.php │ ├── Seeds │ └── WechatPlatFormBackendTablesSeeder.php │ ├── Services │ ├── CodeService.php │ ├── CodeTemplateService.php │ ├── DomainService.php │ ├── MessageService.php │ ├── OAuthService.php │ ├── PlatformService.php │ └── TemplateMessageService.php │ ├── WechatPlatFormBackend.php │ ├── config.php │ ├── helpers.php │ ├── mini_program_errcode.php │ └── routes │ ├── admin.php │ ├── api.php │ └── web.php ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── css │ └── app.css ├── favicon.ico ├── index.php ├── js │ └── app.js ├── robots.txt └── web.config ├── resources ├── assets │ ├── js │ │ ├── app.js │ │ ├── bootstrap.js │ │ └── components │ │ │ └── ExampleComponent.vue │ └── sass │ │ ├── _variables.scss │ │ └── app.scss ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ └── welcome.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ └── ExampleTest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── webpack.mix.js /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_LOG_LEVEL=debug 6 | APP_URL=http://localhost 7 | 8 | DB_CONNECTION=mysql 9 | DB_HOST=127.0.0.1 10 | DB_PORT=3306 11 | DB_DATABASE=homestead 12 | DB_USERNAME=homestead 13 | DB_PASSWORD=secret 14 | 15 | BROADCAST_DRIVER=log 16 | CACHE_DRIVER=file 17 | SESSION_DRIVER=file 18 | SESSION_LIFETIME=120 19 | QUEUE_DRIVER=sync 20 | 21 | REDIS_HOST=127.0.0.1 22 | REDIS_PASSWORD=null 23 | REDIS_PORT=6379 24 | 25 | MAIL_DRIVER=smtp 26 | MAIL_HOST=smtp.mailtrap.io 27 | MAIL_PORT=2525 28 | MAIL_USERNAME=null 29 | MAIL_PASSWORD=null 30 | MAIL_ENCRYPTION=null 31 | 32 | PUSHER_APP_ID= 33 | PUSHER_APP_KEY= 34 | PUSHER_APP_SECRET= 35 | PUSHER_APP_CLUSTER=mt1 36 | 37 | 38 | WECHAT_OPEN_PLATFORM_APPID= 39 | WECHAT_OPEN_PLATFORM_SECRET= 40 | WECHAT_OPEN_PLATFORM_TOKEN= 41 | WECHAT_OPEN_PLATFORM_AES_KEY= 42 | 43 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /public/vendor 5 | /resources 6 | /storage/*.key 7 | /vendor 8 | /.idea 9 | /.vagrant 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | .env 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iBrand Wechat Platform open source project 2 | 3 | iBrand Wechat Platform 是一个免费开源的微信第三方平台,基于 Laravel 5.5 和 Easywechat 进行开发。 4 | 5 | ## 特性 6 | 7 | 主要实现功能: 8 | 9 | 1. 微信第三方管理后台,实现对微信公众号和微信小程序,授权的统一管理。(搭建自己的微信第三方授权平台)。 10 | 11 | 2. 提供常用微信公众号和小程序开发相关的接口。 12 | 13 | 3. 后台包括微信公众号管理和小程序管理,实现一键提交审核,发布微信小程序,自定义小程序模板等功能。 14 | 15 | > 最初使用 Easywechat 3.x 版本进行开发时,并不包含第三方平台,所以才有此项目 16 | 17 | ## 文档 18 | 19 | - [使用说明 & API](https://www.ibrand.cc/docs/wechat/v1/index) 20 | - [微信公众平台技术文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1445241432) 21 | - [微信第三方平台](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419318292&token=&lang=zh_CN) 22 | 23 | ## 体验 24 | 25 | //TODO:: 26 | 27 | ## 贡献源码 28 | 29 | 该项目正在持续迭代更新中,如果你想参与到本项目中来,请提交 Pull Request ! 30 | 31 | 如果你发现任何问题或者需求,请[提交ISSUE](https://github.com/ibrandcc/laravel-wechat-platform/issues) 32 | 33 | ## 开源系列 34 | 35 | [Laravel 社交电商](https://github.com/ibrandcc/ecommerce-open-api) · [社交电商微信小程序](https://github.com/ibrandcc/miniprogram-ecommerce-open-source) · [微信第三方平台](https://github.com/ibrandcc/laravel-wechat-platform) 36 | 37 | ## 社交账号 38 | 39 | [Laravel-China](https://laravel-china.org/ibrand) · [掘金](https://juejin.im/user/5aab2cfa518825556534407a/posts) · [segmentfault](https://segmentfault.com/u/ibrand) 40 | 41 | ## 讨论交流 42 | 43 | ![iBrand联系我们](https://iyoyo.oss-cn-hangzhou.aliyuncs.com/post/qrcodenew.jpg) 44 | 45 | ## 果酱云社区 46 | 47 |

48 | 49 | 点击跳转 50 | 51 |

52 | 53 | 54 | 55 | - 全网真正免费的IT课程平台 56 | 57 | - 专注于综合IT技术的在线课程,致力于打造优质、高效的IT在线教育平台 58 | 59 | - 课程方向包含Python、Java、前端、大数据、数据分析、人工智能等热门IT课程 60 | 61 | - 300+免费课程任你选择 62 | 63 | 64 | 65 |

66 | 67 | 点击跳转 68 | 69 |

-------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | 31 | /** 32 | * Register the commands for the application. 33 | * 34 | * @return void 35 | */ 36 | protected function commands() 37 | { 38 | $this->load(__DIR__.'/Commands'); 39 | 40 | require base_path('routes/console.php'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 40 | } 41 | 42 | /** 43 | * Get a validator for an incoming registration request. 44 | * 45 | * @param array $data 46 | * @return \Illuminate\Contracts\Validation\Validator 47 | */ 48 | protected function validator(array $data) 49 | { 50 | return Validator::make($data, [ 51 | 'name' => 'required|string|max:255', 52 | 'email' => 'required|string|email|max:255|unique:users', 53 | 'password' => 'required|string|min:6|confirmed', 54 | ]); 55 | } 56 | 57 | /** 58 | * Create a new user instance after a valid registration. 59 | * 60 | * @param array $data 61 | * @return \App\User 62 | */ 63 | protected function create(array $data) 64 | { 65 | return User::create([ 66 | 'name' => $data['name'], 67 | 'email' => $data['email'], 68 | 'password' => bcrypt($data['password']), 69 | ]); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | ], 39 | 40 | 'api' => [ 41 | 'throttle:60,1', 42 | 'bindings', 43 | ], 44 | ]; 45 | 46 | /** 47 | * The application's route middleware. 48 | * 49 | * These middleware may be assigned to groups or used individually. 50 | * 51 | * @var array 52 | */ 53 | protected $routeMiddleware = [ 54 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 58 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 59 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 60 | 'client' => \iBrand\Wechat\Platform\Http\Middleware\ClientVerify::class, 61 | 'parameter' => \iBrand\Wechat\Platform\Http\Middleware\ParameterVerify::class, 62 | ]; 63 | } 64 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 'FORWARDED', 24 | Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', 25 | Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', 26 | Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', 27 | Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', 28 | ]; 29 | } 30 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any events for your application. 23 | * 24 | * @return void 25 | */ 26 | public function boot() 27 | { 28 | parent::boot(); 29 | 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "name": "ibrand/laravel-wechat-platform", 4 | "description": "iBrand's Laravel wechat platform open source", 5 | "keywords": ["wechat", "laravel","platfrom"], 6 | "license": "MIT", 7 | "type": "project", 8 | "require": { 9 | "php": ">=7.0.0", 10 | "fideloper/proxy": "~3.3", 11 | 12 | "ibrand/setting": "^1.0", 13 | "laravel/framework": "5.5.*", 14 | "laravel/tinker": "~1.0", 15 | "wikimedia/composer-merge-plugin": "^1.4", 16 | "laravel/passport": "^4.0", 17 | "prettus/l5-repository": "^2.6", 18 | "overtrue/laravel-wechat": "~4.0", 19 | "ibrand/backend": "~3.0" 20 | }, 21 | "require-dev": { 22 | "filp/whoops": "~2.0", 23 | "fzaninotto/faker": "~1.4", 24 | "mockery/mockery": "~1.0", 25 | "phpunit/phpunit": "~6.0", 26 | "symfony/thanks": "^1.0" 27 | }, 28 | "autoload": { 29 | "classmap": [ 30 | "database/seeds", 31 | "database/factories" 32 | ], 33 | "psr-4": { 34 | "App\\": "app/" 35 | } 36 | }, 37 | "autoload-dev": { 38 | "psr-4": { 39 | "Tests\\": "tests/" 40 | } 41 | }, 42 | "extra": { 43 | "laravel": { 44 | "dont-discover": [ 45 | ] 46 | }, 47 | "merge-plugin": { 48 | "include": [ 49 | "modules/*/composer.json" 50 | ], 51 | "recurse": true, 52 | "replace": false, 53 | "ignore-duplicates": true, 54 | 55 | "merge-dev": true, 56 | "merge-extra": false, 57 | "merge-extra-deep": false, 58 | "merge-scripts": false 59 | } 60 | }, 61 | "scripts": { 62 | "post-root-package-install": [ 63 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 64 | ], 65 | "post-create-project-cmd": [ 66 | "@php artisan key:generate" 67 | ], 68 | "post-autoload-dump": [ 69 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 70 | "@php artisan package:discover" 71 | ] 72 | }, 73 | "config": { 74 | "preferred-install": "dist", 75 | "sort-packages": true, 76 | "optimize-autoloader": true 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | 49 | 'clients' => [ 50 | 'driver' => 'passport', 51 | 'provider' => 'clients', 52 | ], 53 | ], 54 | 55 | /* 56 | |-------------------------------------------------------------------------- 57 | | User Providers 58 | |-------------------------------------------------------------------------- 59 | | 60 | | All authentication drivers have a user provider. This defines how the 61 | | users are actually retrieved out of your database or other storage 62 | | mechanisms used by this application to persist your user's data. 63 | | 64 | | If you have multiple user tables or models you may configure multiple 65 | | sources which represent each model / table. These sources may then 66 | | be assigned to any extra authentication guards you have defined. 67 | | 68 | | Supported: "database", "eloquent" 69 | | 70 | */ 71 | 72 | 'providers' => [ 73 | 'users' => [ 74 | 'driver' => 'eloquent', 75 | 'model' => App\User::class, 76 | ], 77 | 78 | 'clients' => [ 79 | 'driver' => 'eloquent', 80 | 'model' =>iBrand\Wechat\Platform\Models\Clients::class, 81 | ], 82 | 83 | // 'users' => [ 84 | // 'driver' => 'database', 85 | // 'table' => 'users', 86 | // ], 87 | ], 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Resetting Passwords 92 | |-------------------------------------------------------------------------- 93 | | 94 | | You may specify multiple password reset configurations if you have more 95 | | than one user table or model in the application and you want to have 96 | | separate password reset settings based on the specific user types. 97 | | 98 | | The expire time is the number of minutes that the reset token should be 99 | | considered valid. This security feature keeps tokens short-lived so 100 | | they have less time to be guessed. You may change this as needed. 101 | | 102 | */ 103 | 104 | 'passwords' => [ 105 | 'users' => [ 106 | 'provider' => 'users', 107 | 'table' => 'password_resets', 108 | 'expire' => 60, 109 | ], 110 | ], 111 | 112 | 113 | 114 | ]; 115 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'encrypted' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | */ 30 | 31 | 'stores' => [ 32 | 33 | 'apc' => [ 34 | 'driver' => 'apc', 35 | ], 36 | 37 | 'array' => [ 38 | 'driver' => 'array', 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => 'cache', 44 | 'connection' => null, 45 | ], 46 | 47 | 'file' => [ 48 | 'driver' => 'file', 49 | 'path' => storage_path('framework/cache/data'), 50 | ], 51 | 52 | 'memcached' => [ 53 | 'driver' => 'memcached', 54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 55 | 'sasl' => [ 56 | env('MEMCACHED_USERNAME'), 57 | env('MEMCACHED_PASSWORD'), 58 | ], 59 | 'options' => [ 60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 61 | ], 62 | 'servers' => [ 63 | [ 64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 65 | 'port' => env('MEMCACHED_PORT', 11211), 66 | 'weight' => 100, 67 | ], 68 | ], 69 | ], 70 | 71 | 'redis' => [ 72 | 'driver' => 'redis', 73 | 'connection' => 'default', 74 | ], 75 | 76 | ], 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Cache Key Prefix 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When utilizing a RAM based store such as APC or Memcached, there might 84 | | be other applications utilizing the same cache. So, we'll specify a 85 | | value to get prefixed to all our keys so we can avoid collisions. 86 | | 87 | */ 88 | 89 | 'prefix' => env( 90 | 'CACHE_PREFIX', 91 | str_slug(env('APP_NAME', 'laravel'), '_').'_cache' 92 | ), 93 | 94 | ]; 95 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | ], 41 | 42 | 'mysql' => [ 43 | 'driver' => 'mysql', 44 | 'host' => env('DB_HOST', '127.0.0.1'), 45 | 'port' => env('DB_PORT', '3306'), 46 | 'database' => env('DB_DATABASE', 'forge'), 47 | 'username' => env('DB_USERNAME', 'forge'), 48 | 'password' => env('DB_PASSWORD', ''), 49 | 'unix_socket' => env('DB_SOCKET', ''), 50 | 'charset' => 'utf8mb4', 51 | 'collation' => 'utf8mb4_unicode_ci', 52 | 'prefix' => '', 53 | 'strict' => true, 54 | 'engine' => null, 55 | ], 56 | 57 | 'pgsql' => [ 58 | 'driver' => 'pgsql', 59 | 'host' => env('DB_HOST', '127.0.0.1'), 60 | 'port' => env('DB_PORT', '5432'), 61 | 'database' => env('DB_DATABASE', 'forge'), 62 | 'username' => env('DB_USERNAME', 'forge'), 63 | 'password' => env('DB_PASSWORD', ''), 64 | 'charset' => 'utf8', 65 | 'prefix' => '', 66 | 'schema' => 'public', 67 | 'sslmode' => 'prefer', 68 | ], 69 | 70 | 'sqlsrv' => [ 71 | 'driver' => 'sqlsrv', 72 | 'host' => env('DB_HOST', 'localhost'), 73 | 'port' => env('DB_PORT', '1433'), 74 | 'database' => env('DB_DATABASE', 'forge'), 75 | 'username' => env('DB_USERNAME', 'forge'), 76 | 'password' => env('DB_PASSWORD', ''), 77 | 'charset' => 'utf8', 78 | 'prefix' => '', 79 | ], 80 | 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Migration Repository Table 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This table keeps track of all the migrations that have already run for 89 | | your application. Using this information, we can determine which of 90 | | the migrations on disk haven't actually been run in the database. 91 | | 92 | */ 93 | 94 | 'migrations' => 'migrations', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Redis Databases 99 | |-------------------------------------------------------------------------- 100 | | 101 | | Redis is an open source, fast, and advanced key-value store that also 102 | | provides a richer set of commands than a typical key-value systems 103 | | such as APC or Memcached. Laravel makes it easy to dig right in. 104 | | 105 | */ 106 | 107 | 'redis' => [ 108 | 109 | 'client' => 'predis', 110 | 111 | 'default' => [ 112 | 'host' => env('REDIS_HOST', '127.0.0.1'), 113 | 'password' => env('REDIS_PASSWORD', null), 114 | 'port' => env('REDIS_PORT', 6379), 115 | 'database' => 0, 116 | ], 117 | 118 | ], 119 | 120 | ]; 121 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Cloud Filesystem Disk 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Many applications store files both locally and in the cloud. For this 24 | | reason, you may specify a default "cloud" driver here. This driver 25 | | will be bound as the Cloud disk implementation in the container. 26 | | 27 | */ 28 | 29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Filesystem Disks 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may configure as many filesystem "disks" as you wish, and you 37 | | may even configure multiple disks of the same driver. Defaults have 38 | | been setup for each driver as an example of the required options. 39 | | 40 | | Supported Drivers: "local", "ftp", "s3", "rackspace" 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'url' => env('APP_URL').'/storage', 55 | 'visibility' => 'public', 56 | ], 57 | 58 | 's3' => [ 59 | 'driver' => 's3', 60 | 'key' => env('AWS_ACCESS_KEY_ID'), 61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 62 | 'region' => env('AWS_DEFAULT_REGION'), 63 | 'bucket' => env('AWS_BUCKET'), 64 | ], 65 | 66 | ], 67 | 68 | ]; 69 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => env('SQS_KEY', 'your-public-key'), 54 | 'secret' => env('SQS_SECRET', 'your-secret-key'), 55 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 56 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 57 | 'region' => env('SQS_REGION', 'us-east-1'), 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'retry_after' => 90, 65 | ], 66 | 67 | ], 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Failed Queue Jobs 72 | |-------------------------------------------------------------------------- 73 | | 74 | | These options configure the behavior of failed queue job logging so you 75 | | can control which database and table are used to store the jobs that 76 | | have failed. You may change them to any database / table you wish. 77 | | 78 | */ 79 | 80 | 'failed' => [ 81 | 'database' => env('DB_CONNECTION', 'mysql'), 82 | 'table' => 'failed_jobs', 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker $faker) { 17 | return [ 18 | 'name' => $faker->name, 19 | 'email' => $faker->unique()->safeEmail, 20 | 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 21 | 'remember_token' => str_random(10), 22 | ]; 23 | }); 24 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->rememberToken(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('users'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /modules/WechatPlatform/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | composer.lock 3 | .php_cs.cache 4 | .idea -------------------------------------------------------------------------------- /modules/WechatPlatform/.php_cs: -------------------------------------------------------------------------------- 1 | 6 | 7 | For the full copyright and license information, please view the LICENSE 8 | file that was distributed with this source code. 9 | EOF; 10 | return PhpCsFixer\Config::create() 11 | ->setRiskyAllowed(true) 12 | ->setRules(array( 13 | '@Symfony' => true, 14 | 'header_comment' => array('header' => $header), 15 | 'array_syntax' => array('syntax' => 'short'), 16 | 'ordered_imports' => true, 17 | 'no_useless_else' => true, 18 | 'no_useless_return' => true, 19 | 'php_unit_construct' => true, 20 | 'php_unit_strict' => true, 21 | )) 22 | ->setFinder( 23 | PhpCsFixer\Finder::create() 24 | ->exclude('vendor') 25 | ->in(__DIR__) 26 | ) 27 | ; -------------------------------------------------------------------------------- /modules/WechatPlatform/.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | # using major version aliases 5 | 6 | # aliased to a recent 7.x version 7 | - 7.0 8 | # aliased to a recent 7.x version 9 | - 7.1 10 | # aliased to a recent 7.x version 11 | - 7.2 12 | 13 | 14 | before_script: 15 | - composer self-update 16 | - composer install --prefer-source --no-interaction --dev 17 | -------------------------------------------------------------------------------- /modules/WechatPlatform/README.md: -------------------------------------------------------------------------------- 1 | ## 微信第三方平台 2 | 3 | 1. 基于 [overtrue/wechat](https://github.com/overtrue/wechat) 进行扩展开发 4 | 2. [微信第三方平台概述](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419318292&token=&lang=zh_CN) 5 | 6 | -------------------------------------------------------------------------------- /modules/WechatPlatform/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iBrand/Wechat/Platform", 3 | "type": "library", 4 | "description": "iBrand Wechat Platform ", 5 | "keywords": [ 6 | "iBrand", 7 | "Wechat Platform" 8 | ], 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "iBrand Wechat Platform", 13 | "email": "tangwei@element.vip" 14 | } 15 | ], 16 | "require": { 17 | "php": ">=7.0.0", 18 | "laravel/passport": "^4.0", 19 | "prettus/l5-repository": "^2.6", 20 | "overtrue/laravel-wechat": "~4.0" 21 | }, 22 | 23 | "autoload": { 24 | 25 | "files": [ 26 | "src/helpers.php" 27 | ], 28 | 29 | "psr-4": { 30 | "iBrand\\Wechat\\Platform\\": "src/" 31 | } 32 | }, 33 | "minimum-stability": "dev", 34 | "prefer-stable": true 35 | } 36 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_03_09_100235_create_authorizers_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateAuthorizersTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('authorizers', function (Blueprint $table) { 24 | $table->increments('id'); 25 | $table->string('appid', 100)->unique()->comment('AppId'); 26 | $table->integer('service_type_info')->nullable()->comment('授权方公众号类型,0代表订阅号,1代表由历史老帐号升级后的订阅号,2代表服务号'); 27 | $table->integer('verify_type_info')->nullable()->comment('授权方认证类型'); 28 | $table->string('refresh_token', 500)->nullable()->comment('刷新凭据'); 29 | $table->text('func_info')->nullable()->comment('授权接口'); 30 | $table->integer('client_id')->nullable()->default(0); 31 | $table->string('nick_name')->nullable(); 32 | $table->string('head_img')->nullable(); 33 | $table->string('user_name')->nullable(); 34 | $table->string('principal_name')->nullable(); 35 | $table->string('qrcode_url')->nullable(); 36 | $table->string('call_back_url')->nullable()->comment('公众号回调'); 37 | $table->timestamps(); 38 | }); 39 | } 40 | 41 | /** 42 | * Reverse the migrations. 43 | */ 44 | public function down() 45 | { 46 | Schema::drop('authorizers'); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_03_09_125705_create_oauth2_tokens_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateOauth2TokensTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('oauth2_tokens', function (Blueprint $table) { 24 | $table->increments('id'); 25 | $table->string('appid', 100)->comment('AppId'); 26 | $table->string('openid', 500)->comment('用户唯一标识'); 27 | $table->string('access_token', 500)->nullable()->comment('调用凭据'); 28 | $table->string('refresh_token', 500)->nullable()->comment('刷新凭据'); 29 | $table->string('scope', 500)->nullable()->comment('用户授权的作用域'); 30 | $table->integer('expires_in')->nullable()->comment('access_token接口调用凭证超时时间'); 31 | $table->timestamps(); 32 | }); 33 | } 34 | 35 | /** 36 | * Reverse the migrations. 37 | */ 38 | public function down() 39 | { 40 | Schema::drop('oauth2_tokens'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_03_20_258931_add_type_and_mini_info_to_authorizers_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class AddTypeAndMIniInfoToAuthorizersTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::table('authorizers', function (Blueprint $table) { 24 | $table->tinyInteger('type')->default(1)->comment('1微信公众号2微信小程序'); 25 | $table->text('mini_info')->nullable()->comment('小程序授权接口'); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | */ 32 | public function down() 33 | { 34 | Schema::table('authorizers', function (Blueprint $table) { 35 | $table->dropColumn(['type', 'mini_info']); 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_08_06_660235_create_testers_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateTestersTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('testers', function (Blueprint $table) { 24 | $table->increments('id'); 25 | 26 | $table->string('appid')->comment('appid'); 27 | 28 | $table->string('wechatid')->comment('体验者微信号'); 29 | 30 | $table->timestamps(); 31 | }); 32 | } 33 | 34 | /** 35 | * Reverse the migrations. 36 | */ 37 | public function down() 38 | { 39 | Schema::drop('testers'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_08_09_587324_create_code_publish_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateCodePublishTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('code_publish', function (Blueprint $table) { 24 | $table->increments('id'); 25 | 26 | $table->string('appid')->comment('appid'); 27 | 28 | $table->string('auditid')->comment('审核编号'); 29 | 30 | $table->integer('status')->default(2)->comment('状态'); //审核状态,其中0为审核成功,1为审核失败,2为审核中 3已发布 4撤回审核 31 | 32 | $table->text('template')->comment('模板内容json格式'); 33 | 34 | $table->text('theme')->nullable(); 35 | 36 | $table->text('bars')->nullable(); 37 | 38 | $table->text('ext_json')->nullable(); 39 | 40 | $table->text('note')->nullable(); 41 | 42 | $table->text('reason')->nullable(); //当status=1,审核被拒绝时,返回的拒绝原因 43 | 44 | $table->timestamp('audit_time')->nullable(); //提交审核时间 45 | 46 | $table->timestamp('withdraw_audit_time')->nullable(); //撤回审核时间 47 | 48 | $table->timestamp('audit_success_time')->nullable(); //审核成功时间 49 | 50 | $table->timestamp('release_time')->nullable(); //发布时间 51 | 52 | $table->timestamps(); 53 | }); 54 | } 55 | 56 | /** 57 | * Reverse the migrations. 58 | */ 59 | public function down() 60 | { 61 | Schema::drop('code_publish'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_08_15_124568_create_theme_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateThemeTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('theme', function (Blueprint $table) { 24 | 25 | $table->increments('id'); 26 | 27 | $table->string('name')->comment('主题组名称'); 28 | 29 | $table->timestamps(); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | */ 36 | public function down() 37 | { 38 | Schema::drop('theme'); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_08_15_234764_create_theme_template_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateThemeTemplateTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('theme_template', function (Blueprint $table) { 24 | 25 | $table->increments('id'); 26 | 27 | $table->string('theme_id')->comment('主题组ID'); 28 | 29 | $table->string('template_id')->comment('模板ID'); 30 | 31 | $table->timestamps(); 32 | }); 33 | } 34 | 35 | /** 36 | * Reverse the migrations. 37 | */ 38 | public function down() 39 | { 40 | Schema::drop('theme_template'); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /modules/WechatPlatform/migrations/2018_08_15_347643_create_theme_items_table.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Illuminate\Database\Migrations\Migration; 13 | use Illuminate\Database\Schema\Blueprint; 14 | use Illuminate\Support\Facades\Schema; 15 | 16 | class CreateThemeItemsTable extends Migration 17 | { 18 | /** 19 | * Run the migrations. 20 | */ 21 | public function up() 22 | { 23 | Schema::create('theme_items', function (Blueprint $table) { 24 | 25 | $table->increments('id'); 26 | 27 | $table->integer('type')->default(1)->comment('1配色主题2菜单主题'); 28 | 29 | $table->string('title')->comment('标题'); 30 | 31 | $table->integer('theme_id')->default(0)->comment('主题组ID'); 32 | 33 | $table->string('img')->nullable()->comment('封面图'); 34 | 35 | $table->integer('is_default')->default(0)->comment('默认主题'); 36 | 37 | $table->text('param')->nullable()->comment('自定义参数'); 38 | 39 | $table->timestamps(); 40 | }); 41 | } 42 | 43 | /** 44 | * Reverse the migrations. 45 | */ 46 | public function down() 47 | { 48 | Schema::drop('theme_items'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/includes/common.blade.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/code/log.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 8 |
9 |
10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | @if(count($lists)>0) 27 | @foreach ($lists as $item) 28 | 29 | 30 | 31 | 32 | 33 | 34 | template)?> 35 | 36 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 65 | 66 | 76 | 77 | 78 | @endforeach 79 | @endif 80 | 81 | 82 |
审核编号提交审核时间状态模板ID描述版本体验二维码备注
{{$item->auditid}}{{$item->audit_time}} 37 | @if($item->status==0) 38 | 审核成功 39 | @elseif($item->status==1) 40 | 审核失败 41 | @elseif($item->status==2) 42 | 待审核 43 | @elseif($item->status==3) 44 | 已发布 45 | 查看 47 | @elseif($item->status==4) 48 | 审核撤回 49 | @elseif($item->status==5) 50 | 取消发布 51 | @endif 52 | {{$template->template_id}}{{$template->user_desc}}{{$template->user_version}} 62 | 查看 64 | 67 | 68 | @if($item->reason) 69 | 备注:{{$item->note}} 70 | 审核失败原因:{{$item->reason}} 71 | @else 72 | {{$item->note}} 73 | @endif 74 | 75 |
83 | 84 | 85 | 86 | 87 | {!!$lists->appends(['limit'=>request('limit'),'appid'=>request('appid')])->render()!!} 88 | 89 | 90 | 91 | 92 | 93 |
94 |
95 |
96 | 97 |
98 |
99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/code/script.blade.php: -------------------------------------------------------------------------------- 1 | 81 | 82 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/code_template/draft_list.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 11 |
12 |
13 |
14 | @if(count($draft_list)>0) 15 | *每个小程序只保留最新一次的上传记录 16 |
17 |
18 | @endif 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | @if(count($draft_list)>0) 34 | @foreach ($draft_list as $item) 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 52 | 53 | 54 | @endforeach 55 | @endif 56 | 57 | 58 |
ID版本号描述来源小程序appid来源小程序上传开发者最近提交时间操作
{{$item['draft_id']}}{{$item['user_version']}}{{$item['user_desc']}}{{$item['source_miniprogram_appid']}}{{$item['source_miniprogram']}}{{$item['developer']}}{{date('Y-m-d H:i:s',$item['create_time'])}} 45 | 46 | 48 | 添加模板 49 | 50 | 51 |
59 | 60 |
61 |
62 |
63 | 64 |
65 |
66 | 67 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/domain/script.blade.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/layouts/bootstrap_modal.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 12 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/theme/bars_create.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 |
6 | 7 | 8 |
9 | 10 |
11 | 12 | 13 |
14 | 15 | 16 | 17 |
18 | 19 |
20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 |
30 | 31 | 32 | 33 |
34 | 35 |
36 | 37 |
38 | 39 | 40 | 41 |
42 | 43 |
44 | 45 |
46 |
47 | 48 |
49 |
50 | 51 |
52 | 53 | 54 |
55 | 56 |
57 |
58 | 59 | 60 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/theme/bars_edit.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 |
6 | 7 | 8 |
9 | 10 |
11 | 12 | 13 |
14 | 15 | 16 | 17 |
18 | 19 |
20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 |
30 | 31 | 32 | 33 |
34 | 35 |
36 | 37 |
38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 |
46 | 47 |
48 |
49 | 50 |
51 |
52 | 53 |
54 | 55 | 56 |
57 | 58 |
59 |
60 | 61 | 62 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/mini/theme/script.blade.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /modules/WechatPlatform/resources/views/platform/auth.blade.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /modules/WechatPlatform/scrutinizer.yml: -------------------------------------------------------------------------------- 1 | checks: 2 | php: 3 | code_rating: true 4 | duplication: true 5 | 6 | tools: 7 | # external_code_coverage: true 8 | php_mess_detector: true 9 | php_code_sniffer: true 10 | sensiolabs_security_checker: true 11 | # php_code_coverage: true 12 | php_pdepend: true 13 | php_loc: 14 | enabled: true 15 | excluded_dirs: [vendor, tests] 16 | filter: 17 | excluded_paths: 18 | - 'tests/*' 19 | 20 | build: 21 | dependencies: 22 | before: 23 | - composer install 24 | tests: 25 | override: 26 | - 27 | command: vendor/bin/phpunit --coverage-clover=my-coverage-file 28 | coverage: 29 | file: my-coverage-file 30 | format: clover -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Console/InstallCommand.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Console; 13 | 14 | use iBrand\Wechat\Platform\Seeds\WechatPlatFormBackendTablesSeeder; 15 | use Illuminate\Console\Command; 16 | 17 | class InstallCommand extends Command 18 | { 19 | protected $signature = 'ibrand-wechat-platform:install'; 20 | 21 | /** 22 | * The console command description. 23 | * 24 | * @var string 25 | */ 26 | protected $description = 'ibrand wechat platform install'; 27 | 28 | public function handle() 29 | { 30 | $this->call('db:seed', ['--class' => WechatPlatFormBackendTablesSeeder::class]); 31 | 32 | $this->call('migrate'); 33 | 34 | $this->info('ibrand wechat platform install successfully.'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/Admin/CustomerController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\Admin; 13 | 14 | use Encore\Admin\Facades\Admin as LaravelAdmin; 15 | use Encore\Admin\Layout\Content; 16 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 17 | use iBrand\Wechat\Platform\Models\Clients; 18 | use iBrand\Wechat\Platform\Repositories\ClientsRepository as AdminClientsRepository; 19 | use Laravel\Passport\ClientRepository; 20 | 21 | class CustomerController extends Controller 22 | { 23 | protected $clientRepository; 24 | 25 | protected $adminClientsRepository; 26 | 27 | public function __construct(ClientRepository $ClientRepository, AdminClientsRepository $adminClientsRepository) 28 | { 29 | $this->clientRepository = $ClientRepository; 30 | 31 | $this->adminClientsRepository = $adminClientsRepository; 32 | } 33 | 34 | /** 35 | * @return Content 36 | */ 37 | public function index() 38 | { 39 | $limit = request('limit') ? request('limit') : 20; 40 | 41 | $name = request('name'); 42 | 43 | $customers = $this->adminClientsRepository->getListsByname($name, $limit); 44 | 45 | return LaravelAdmin::content(function (Content $content) use ($customers) { 46 | $content->header('客户列表'); 47 | 48 | $content->breadcrumb( 49 | ['text' => '客户管理', 'url' => 'customers', 'no-pjax' => 1], 50 | ['text' => '客户列表', 'url' => '', 'no-pjax' => 1, 'left-menu-active' => '客户列表'] 51 | ); 52 | 53 | $content->body(view('wechat-platform::customer.index', compact('customers'))); 54 | }); 55 | } 56 | 57 | /** 58 | * @return \Illuminate\Http\JsonResponse 59 | */ 60 | public function store() 61 | { 62 | $name = request('name'); 63 | 64 | if (!$name || Clients::where('name', $name)->first()) { 65 | return $this->api([], false, 400, 'name已存在'); 66 | } 67 | 68 | if ($this->clientRepository->create(null, $name, 'http://localhost', $personalAccess = false, $password = true)) { 69 | return $this->api([], true); 70 | } 71 | 72 | return $this->api([], false); 73 | } 74 | 75 | /** 76 | * @param $id 77 | * 78 | * @return \Illuminate\Http\JsonResponse 79 | */ 80 | public function destroy($id) 81 | { 82 | $client = Clients::find($id); 83 | 84 | if ($client->wechat->count() || $client->mini->count()) { 85 | return $this->api([], false, 400, '有关联公众号或小程序删除失败'); 86 | } 87 | 88 | Clients::destroy($id); 89 | 90 | return $this->api([], true); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/Admin/DomainController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\Admin; 13 | 14 | use Encore\Admin\Facades\Admin as LaravelAdmin; 15 | use Encore\Admin\Layout\Content; 16 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 17 | use iBrand\Wechat\Platform\Services\PlatformService; 18 | 19 | /** 20 | * Class DomainController. 21 | */ 22 | class DomainController extends Controller 23 | { 24 | protected $platformService; 25 | 26 | protected $errcode; 27 | 28 | public function __construct( 29 | PlatformService $platformService 30 | ) { 31 | $this->platformService = $platformService; 32 | 33 | $this->errcode = config('mini_program_errcode'); 34 | } 35 | 36 | /** 37 | * @return Content 38 | */ 39 | public function index() 40 | { 41 | $appid = request('appid'); 42 | 43 | $requestdomain = settings('requestdomain') ? settings('requestdomain') : []; 44 | 45 | $wsrequestdomain = settings('wsrequestdomain') ? settings('wsrequestdomain') : []; 46 | 47 | $uploaddomain = settings('uploaddomain') ? settings('uploaddomain') : []; 48 | 49 | $downloaddomain = settings('downloaddomain') ? settings('downloaddomain') : []; 50 | 51 | return LaravelAdmin::content(function (Content $content) use ($requestdomain, $wsrequestdomain, $uploaddomain, $downloaddomain) { 52 | $content->header('服务器域名设置'); 53 | 54 | $content->breadcrumb( 55 | ['text' => '小程序管理', 'url' => 'wechat_platform/wechat?type=2', 'no-pjax' => 1], 56 | ['text' => '服务器域名', 'url' => '', 'no-pjax' => 1, 'left-menu-active' => '服务器域名'] 57 | ); 58 | 59 | $content->body(view('wechat-platform::mini.domain.index', compact('requestdomain', 'wsrequestdomain', 'uploaddomain', 'downloaddomain'))); 60 | }); 61 | } 62 | 63 | /** 64 | * @return \Illuminate\Http\JsonResponse 65 | */ 66 | public function store() 67 | { 68 | $data_new = []; 69 | 70 | $data = request()->except('_token'); 71 | 72 | foreach ($data as $k => $item) { 73 | if (is_array($item)) { 74 | foreach ($item as $ck => $citem) { 75 | if (null != $citem) { 76 | if ('wsrequestdomain' != $k) { 77 | $data_new[$k][$ck] = 'https://'.$citem; 78 | } else { 79 | $data_new[$k][$ck] = 'wss://'.$citem; 80 | } 81 | } 82 | } 83 | } 84 | } 85 | 86 | $data_new['wsrequestdomain'] = isset($data_new['wsrequestdomain']) ? $data_new['wsrequestdomain'] : ''; 87 | 88 | settings()->setSetting($data_new); 89 | 90 | return $this->api([], true); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/Admin/TesterController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\Admin; 13 | 14 | use Encore\Admin\Facades\Admin as LaravelAdmin; 15 | use Encore\Admin\Layout\Content; 16 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 17 | use iBrand\Wechat\Platform\Repositories\TesterRepository; 18 | use iBrand\Wechat\Platform\Services\PlatformService; 19 | 20 | /** 21 | * Class TesterController. 22 | */ 23 | class TesterController extends Controller 24 | { 25 | protected $platformService; 26 | 27 | protected $errcode; 28 | 29 | protected $testerRepository; 30 | 31 | public function __construct( 32 | PlatformService $platformService, TesterRepository $testerRepository 33 | ) { 34 | $this->platformService = $platformService; 35 | 36 | $this->errcode = config('mini_program_errcode'); 37 | 38 | $this->testerRepository = $testerRepository; 39 | } 40 | 41 | /** 42 | * @return Content 43 | */ 44 | public function getLists() 45 | { 46 | $lists = []; 47 | 48 | $appid = request('appid'); 49 | 50 | $lists = $this->testerRepository->getListByAppId($appid); 51 | 52 | return LaravelAdmin::content(function (Content $content) use ($lists, $appid) { 53 | $content->header('体验微信管理'); 54 | 55 | $content->description($appid); 56 | 57 | $content->breadcrumb( 58 | ['text' => '小程序管理', 'url' => 'wechat_platform/wechat?type=2', 'no-pjax' => 1], 59 | ['text' => '小程序列表', 'url' => 'wechat_platform/wechat?type=2', 'no-pjax' => 1], 60 | ['text' => '体验微信管理', 'url' => '', 'no-pjax' => 1, 'left-menu-active' => '小程序列表'] 61 | ); 62 | 63 | $content->body(view('wechat-platform::mini.tester.index', compact('lists'))); 64 | }); 65 | } 66 | 67 | /** 68 | * @return \Illuminate\Http\JsonResponse 69 | */ 70 | public function store() 71 | { 72 | $appid = request('appid'); 73 | 74 | $wechatid = request('wechatid'); 75 | 76 | $server = $this->platformService->getAccount($appid); 77 | 78 | if (null == $server) { 79 | return $this->api([], false, 400, '该小程序不存在'); 80 | } 81 | 82 | $info = $this->testerRepository->getTesterByWechatId($appid, $wechatid); 83 | 84 | if ($info) { 85 | return $this->api([], false, 400, '体验者已经存在'); 86 | } 87 | 88 | $res = $server->tester->bind($wechatid); 89 | 90 | if ((isset($res['errcode']) and 85004 == $res['errcode']) || 0 == $res['errcode']) { 91 | $this->testerRepository->ensureTester($appid, $wechatid); 92 | 93 | return $this->api([], true); 94 | } 95 | 96 | return $this->admin_wechat_api($res); 97 | } 98 | 99 | /** 100 | * @param $id 101 | * 102 | * @return \Illuminate\Http\JsonResponse 103 | */ 104 | public function delete($id) 105 | { 106 | $appid = request('appid'); 107 | 108 | $server = $this->platformService->getAccount($appid); 109 | 110 | if (null == $server) { 111 | return $this->api([], false, 400, '该小程序不存在'); 112 | } 113 | 114 | $res = $server->tester->unbind($id); 115 | 116 | if (isset($res['errcode']) and 0 == $res['errcode']) { 117 | $this->testerRepository->deleteWhere(['appid' => $appid, 'wechatid' => $id]); 118 | 119 | return $this->api([], true); 120 | } 121 | 122 | return $this->admin_wechat_api($res); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/Admin/UploadController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\Admin; 13 | 14 | use Illuminate\Http\Request; 15 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 16 | use iBrand\Wechat\Platform\Repositories\ThemeItemsRepository; 17 | use Illuminate\Support\Facades\Storage; 18 | 19 | /** 20 | * Class UploadController. 21 | */ 22 | class UploadController extends Controller 23 | { 24 | protected $themeItemsRepository; 25 | 26 | public function __construct( 27 | 28 | ThemeItemsRepository $themeItemsRepository 29 | ) 30 | { 31 | $this->themeItemsRepository = $themeItemsRepository; 32 | 33 | } 34 | 35 | /** 36 | * @param Request $request 37 | * @return \Illuminate\Http\JsonResponse 38 | */ 39 | public function index(Request $request) 40 | { 41 | 42 | 43 | $file = $request->file('file'); 44 | 45 | if ($file) { 46 | 47 | $kuoname = $file->getClientOriginalExtension(); 48 | 49 | $path = $file->getRealPath(); 50 | 51 | $filename = 'public' . '/' . uniqid() . '.' . $kuoname; 52 | 53 | $bool = Storage::disk('local')->put($filename, file_get_contents($path)); 54 | 55 | $url = get_host() . Storage::url($filename); 56 | 57 | return $this->api($url, true, 200, ''); 58 | } 59 | 60 | return $this->api([], false, 400, ''); 61 | 62 | 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/Admin/WechatController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\Admin; 13 | 14 | use Encore\Admin\Facades\Admin as LaravelAdmin; 15 | use Encore\Admin\Layout\Content; 16 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 17 | use iBrand\Wechat\Platform\Models\Authorizer; 18 | use iBrand\Wechat\Platform\Models\Clients; 19 | use iBrand\Wechat\Platform\Repositories\AuthorizerRepository; 20 | use iBrand\Wechat\Platform\Services\CodeTemplateService; 21 | 22 | /** 23 | * Class WechatController. 24 | */ 25 | class WechatController extends Controller 26 | { 27 | protected $authorizerRepository; 28 | 29 | protected $codeTemplateService; 30 | 31 | public function __construct(AuthorizerRepository $authorizerRepository, CodeTemplateService $codeTemplateService) 32 | { 33 | $this->authorizerRepository = $authorizerRepository; 34 | 35 | $this->codeTemplateService = $codeTemplateService; 36 | } 37 | 38 | /** 39 | * @return Content 40 | */ 41 | public function index() 42 | { 43 | $template_list = []; 44 | 45 | $customers = Clients::all(); 46 | 47 | $type = request('type'); 48 | 49 | if (2 == $type) { 50 | $template_list_arr = $this->codeTemplateService->getCodeTemplateList(); 51 | 52 | if (isset($template_list_arr['template_list'])) { 53 | $template_list = $template_list_arr['template_list']; 54 | } 55 | } 56 | 57 | $limit = request('limit') ? request('limit') : 20; 58 | 59 | $lists = $this->authorizerRepository->getAuthorizerList(request('type'), request('client_id'), request('appid'), $limit); 60 | 61 | $name = 1 == $type ? '公众号' : '小程序'; 62 | 63 | return LaravelAdmin::content(function (Content $content) use ($lists, $customers, $name, $type, $template_list) { 64 | $content->header($name.'管理'); 65 | 66 | $content->breadcrumb( 67 | ['text' => $name.'管理', 'url' => 'wechat?type='.$type, 'no-pjax' => 1], 68 | ['text' => $name.'列表', 'url' => '', 'no-pjax' => 1, 'left-menu-active' => $name.'列表'] 69 | ); 70 | 71 | $content->body(view('wechat-platform::wechat.index', compact('lists', 'customers', 'name', 'type', 'template_list'))); 72 | }); 73 | } 74 | 75 | /** 76 | * @param $id 77 | * 78 | * @return \Illuminate\Http\JsonResponse 79 | */ 80 | public function destroy($id) 81 | { 82 | if ($info = Authorizer::find($id)) { 83 | $info->client_id = 0; 84 | $info->save(); 85 | 86 | return $this->api([], true); 87 | } 88 | 89 | return $this->api([], false, 400, '删除失败'); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/AuthorizerController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Repositories\AuthorizerRepository; 15 | 16 | class AuthorizerController extends Controller 17 | { 18 | protected $repository; 19 | 20 | public function __construct( 21 | AuthorizerRepository $repository) 22 | { 23 | $this->repository = $repository; 24 | } 25 | 26 | public function index() 27 | { 28 | $type = request('type') ? request('type') : 1; 29 | $call_back_url = request('call_back_url'); 30 | if ($clientId = request('client_id') and auth('clients')->user()->id == $clientId) { 31 | $res = $this->repository->getAuthorizersByClient($clientId, $type); 32 | if (count($res) > 0 && !empty($call_back_url)) { 33 | $this->repository->updateCallBackUrl($clientId, $call_back_url); 34 | } 35 | 36 | return $this->repository->getAuthorizersByClient($clientId, $type); 37 | } 38 | 39 | return null; 40 | } 41 | 42 | /** 43 | * @return int 44 | */ 45 | public function update() 46 | { 47 | if (request('client_id') and request('app_id') and auth('clients')->user()->id == request('client_id')) { 48 | return $this->repository->updateDel(request('client_id'), request('app_id')); 49 | } 50 | 51 | return 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/BroadcastController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\PlatformService; 15 | 16 | /** 17 | * 群发消息. 18 | * Class BroadcastController. 19 | */ 20 | class BroadcastController extends Controller 21 | { 22 | protected $platform; 23 | 24 | public function __construct( 25 | PlatformService $platformService 26 | ) { 27 | $this->platform = $platformService; 28 | } 29 | 30 | /** 31 | * 群发. 32 | * 33 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 34 | * 35 | * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException 36 | */ 37 | public function send() 38 | { 39 | // 参数 40 | $appid = request('appid'); 41 | 42 | $data = request()->json()->all(); 43 | // 授权 44 | $server = $this->platform->authorizeAPI($appid); 45 | 46 | $open_id = null; 47 | 48 | if (isset($data['open_id']) and count($data['open_id']) > 0) { 49 | $open_id = $data['open_id']; 50 | } 51 | 52 | //调用接口 53 | switch ($data['type']) { 54 | case 'news': 55 | $result = $server->broadcasting->sendNews($data['media_id'], $open_id); 56 | break; 57 | case 'image': 58 | 59 | $result = $server->broadcasting->sendImage($data['media_id'], $open_id); 60 | break; 61 | case 'video': 62 | 63 | $result = $server->broadcasting->sendVideo($data['media_id'], $open_id); 64 | break; 65 | 66 | case 'voice': 67 | $result = $server->broadcasting->sendVoice($data['media_id'], $open_id); 68 | break; 69 | 70 | case 'text': 71 | $result = $server->broadcasting->sendText($data['text'], $open_id); 72 | break; 73 | case 'card_id': 74 | $result = $server->broadcasting->sendCard($data['card_id'], $open_id); 75 | break; 76 | } 77 | // 返回JSON 78 | 79 | return $result; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use Illuminate\Foundation\Auth\Access\AuthorizesRequests; 15 | use Illuminate\Foundation\Bus\DispatchesJobs; 16 | use Illuminate\Foundation\Validation\ValidatesRequests; 17 | use Illuminate\Routing\Controller as BaseController; 18 | 19 | class Controller extends BaseController 20 | { 21 | use AuthorizesRequests, DispatchesJobs, ValidatesRequests; 22 | 23 | public function admin_wechat_api($res, $data = []) 24 | { 25 | if (isset($res['errcode']) and isset($res['errmsg']) and 0 != $res['errcode']) { 26 | $errcode = config('mini_program_errcode'); 27 | 28 | $message = isset($errcode[$res['errcode']]) ? $errcode[$res['errcode']] : 'errcode:'.$res['errcode'].'errmsg:'.$res['errmsg']; 29 | 30 | return $this->api($data, false, 400, $message); 31 | } 32 | 33 | return $this->api($data, true); 34 | } 35 | 36 | public function api($data = [], $status = true, $code = 200, $message = '') 37 | { 38 | return response()->json( 39 | ['status' => $status, 'code' => $code, 'message' => $message, 'data' => $data]); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/DataController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\PlatformService; 15 | 16 | /** 17 | * Class DataController. 18 | */ 19 | class DataController extends Controller 20 | { 21 | protected $platform; 22 | 23 | public function __construct( 24 | PlatformService $platformService 25 | ) { 26 | $this->platform = $platformService; 27 | } 28 | 29 | /** 30 | * 获取数据. 31 | * 32 | * @param $str 33 | * 34 | * @return mixed 35 | * 36 | * @throws \Exception 37 | */ 38 | public function DataCube($str) 39 | { 40 | // 参数 41 | $appid = request('appid'); 42 | 43 | // 授权 44 | $server = $this->platform->authorizeAPI($appid); 45 | 46 | // 调用接口 47 | $form = request('form'); 48 | 49 | $to = request('to'); 50 | 51 | $result = $server->data_cube->$str($form, $to); 52 | 53 | // 返回JSON 54 | return $result; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/JsController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\PlatformService; 15 | 16 | /** 17 | * JSSDK. 18 | * Class JsController. 19 | */ 20 | class JsController extends Controller 21 | { 22 | protected $platform; 23 | 24 | public function __construct( 25 | PlatformService $platformService 26 | ) { 27 | $this->platform = $platformService; 28 | } 29 | 30 | /** 31 | * @return array|null 32 | * 33 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 34 | * @throws \Psr\SimpleCache\InvalidArgumentException 35 | */ 36 | public function ticket() 37 | { 38 | // 参数 39 | $appid = request('appid'); 40 | 41 | // 授权 42 | $server = $this->platform->authorizeAPI($appid); 43 | 44 | //调用接口 45 | $result = $server->jssdk->getTicket(); 46 | 47 | //返回json 48 | return $result; 49 | } 50 | 51 | /** 52 | * @return mixed 53 | * 54 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 55 | * @throws \Psr\SimpleCache\InvalidArgumentException 56 | */ 57 | public function config() 58 | { 59 | // 参数 60 | $appid = request('appid'); 61 | // 授权 62 | $server = $this->platform->authorizeAPI($appid); 63 | //调用接口 64 | if (empty(request('url'))) { 65 | $result = $server->jssdk; 66 | } else { 67 | $result = $server->jssdk->setUrl(request('url')); 68 | } 69 | if ($method = request('method') and is_array($method)) { 70 | return json_decode($result->buildConfig($method), true); 71 | } 72 | 73 | return json_decode($result->buildConfig([]), true); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/MenuController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\PlatformService; 15 | 16 | /** 17 | * 菜单. 18 | * Class MenuController. 19 | */ 20 | class MenuController extends Controller 21 | { 22 | protected $platform; 23 | 24 | public function __construct( 25 | PlatformService $platformService 26 | ) { 27 | $this->platform = $platformService; 28 | } 29 | 30 | /** 31 | * 查询已设置菜单. 32 | * 33 | * @return mixed 34 | * 35 | * @throws \Exception 36 | */ 37 | public function getAll() 38 | { 39 | // 参数 40 | $appid = request('appid'); 41 | 42 | // 授权 43 | $server = $this->platform->authorizeAPI($appid); 44 | 45 | // 调用接口 46 | $result = $server->menu->list(); 47 | 48 | // 返回JSON 49 | return $result; 50 | } 51 | 52 | /** 53 | * 获取当前菜单. 54 | * 55 | * @return mixed 56 | * 57 | * @throws \Exception 58 | */ 59 | public function getCurrent() 60 | { 61 | // 参数 62 | $appid = request('appid'); 63 | 64 | // 授权 65 | $server = $this->platform->authorizeAPI($appid); 66 | 67 | // 调用接口 68 | $result = $server->menu->current(); 69 | 70 | // 返回JSON 71 | return $result; 72 | } 73 | 74 | /** 75 | * 添加菜单(包括个性化菜单). 76 | * 77 | * @return mixed 78 | * 79 | * @throws \Exception 80 | */ 81 | public function store() 82 | { 83 | // 参数 84 | $appid = request('appid'); 85 | 86 | $data = request()->json()->all(); 87 | 88 | // 授权 89 | $server = $this->platform->authorizeAPI($appid); 90 | 91 | // 调用接口 92 | if (isset($data['matchRule']) && !empty($data['matchRule'])) { 93 | $result = $server->menu->create($data['buttons'], $data['matchRule']); 94 | } else { 95 | $result = $server->menu->create($data['buttons']); 96 | } 97 | 98 | // 返回JSON 99 | return $result; 100 | } 101 | 102 | /** 103 | * 删除菜单. 104 | * 105 | * @return mixed 106 | * 107 | * @throws \Exception 108 | */ 109 | public function delMenu() 110 | { 111 | // 参数 112 | $appid = request('appid'); 113 | 114 | $data = request()->json()->all(); 115 | 116 | // 授权 117 | $server = $this->platform->authorizeAPI($appid); 118 | 119 | // 调用接口 120 | if (isset($data['menuid']) and !empty($data['menuid'])) { 121 | $result = $server->menu->delete($data['menuid']); 122 | } else { 123 | $result = $server->menu->delete(); 124 | } 125 | // 返回JSON 126 | return $result; 127 | } 128 | 129 | /** 130 | * 测试个性化菜单. 131 | *$userId 可以是粉丝的 OpenID,也可以是粉丝的微信号。 132 | * 133 | * @return mixed 134 | * 135 | * @throws \Exception 136 | */ 137 | public function match() 138 | { 139 | // 参数 140 | $appid = request('appid'); 141 | 142 | $data = request()->json()->all(); 143 | 144 | // 授权 145 | $server = $this->platform->authorizeAPI($appid); 146 | 147 | // 调用接口 148 | $result = $server->menu->match($data['userid']); 149 | // 返回JSON 150 | return $result; 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/MiniProgram/AppCodeController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\MiniProgram; 13 | 14 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 15 | use iBrand\Wechat\Platform\Services\PlatformService; 16 | 17 | /** 18 | * 获取小程序码 19 | * Class AppCodeController. 20 | */ 21 | class AppCodeController extends Controller 22 | { 23 | protected $platform; 24 | 25 | public function __construct( 26 | PlatformService $platformService 27 | ) 28 | { 29 | $this->platform = $platformService; 30 | } 31 | 32 | /** 33 | * 永久有效适用于需要的码数量较少的业务场景. 34 | * 35 | * @return \EasyWeChat\Kernel\Http\StreamResponse 36 | * 37 | * @throws \Exception 38 | */ 39 | public function get() 40 | { 41 | // 参数 42 | $appid = request('appid'); 43 | 44 | $data = request()->json()->all(); 45 | 46 | // 授权 47 | $server = $this->platform->miniProgramAPI($appid); 48 | 49 | // 调用接口 50 | $result = $server->app_code->get($data['path'], $data['optional']); 51 | 52 | // 返回JSON 53 | return $result; 54 | } 55 | 56 | /** 57 | * 小程序码适用于需要的码数量极多,或仅临时使用的业务场景. 58 | * 59 | * @return \EasyWeChat\Kernel\Http\StreamResponse 60 | * 61 | * @throws \Exception 62 | */ 63 | public function getUnlimit() 64 | { 65 | // 参数 66 | $appid = request('appid'); 67 | 68 | $data = request()->json()->all(); 69 | 70 | // 授权 71 | $server = $this->platform->miniProgramAPI($appid); 72 | 73 | // 调用接口 74 | $result = $server->app_code->getUnlimit($data['scene'], $data['optional']); 75 | 76 | // 返回JSON 77 | return $result; 78 | } 79 | 80 | /** 81 | * 获取小程序二维码 82 | * 83 | * @return \EasyWeChat\Kernel\Http\StreamResponse 84 | * 85 | * @throws \Exception 86 | */ 87 | public function getQrCode() 88 | { 89 | // 参数 90 | $appid = request('appid'); 91 | 92 | $data = request()->json()->all(); 93 | 94 | $width = isset($data['width']) ? $data['width'] : null; 95 | 96 | // 授权 97 | $server = $this->platform->miniProgramAPI($appid); 98 | 99 | // 调用接口 100 | $result = $server->app_code->getQrCode($data['path'], $width); 101 | 102 | // 返回JSON 103 | return $result; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/MiniProgram/BaseController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\MiniProgram; 13 | 14 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 15 | use iBrand\Wechat\Platform\Services\PlatformService; 16 | 17 | /** 18 | * 基础功能接口 19 | * Class BaseController. 20 | */ 21 | class BaseController extends Controller 22 | { 23 | protected $platform; 24 | 25 | public function __construct( 26 | PlatformService $platformService 27 | ) 28 | { 29 | $this->platform = $platformService; 30 | } 31 | 32 | /** 33 | *根据jsCode获取用户session 信息. 34 | * 35 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 36 | * 37 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 38 | */ 39 | public function session() 40 | { 41 | // 参数 42 | $appid = request('appid'); 43 | 44 | $data = request()->json()->all(); 45 | 46 | // 授权 47 | $server = $this->platform->miniProgramAPI($appid); 48 | 49 | // 调用接口 50 | $result = $server->auth->session($data['code']); 51 | 52 | // 返回JSON 53 | return $result; 54 | } 55 | 56 | /** 57 | * 数据统计与分析. 58 | * 59 | * @param $str 60 | * 61 | * @return mixed 62 | * 63 | * @throws \Exception 64 | */ 65 | public function DataCube($str) 66 | { 67 | // 参数 68 | $appid = request('appid'); 69 | 70 | // 授权 71 | $server = $server = $this->platform->miniProgramAPI($appid); 72 | 73 | // 调用接口 74 | $form = request('form'); 75 | 76 | $to = request('to'); 77 | 78 | $result = $server->data_cube->$str($form, $to); 79 | 80 | // 返回JSON 81 | return $result; 82 | } 83 | 84 | 85 | /** 86 | * 微信小程序消息解密 87 | * @return array 88 | * @throws \EasyWeChat\Kernel\Exceptions\DecryptException 89 | */ 90 | public function decryptedData() 91 | { 92 | // 参数 93 | $appid = request('appid'); 94 | 95 | $data = request()->json()->all(); 96 | 97 | // 授权 98 | $server = $this->platform->miniProgramAPI($appid); 99 | 100 | $result = $server->encryptor->decryptData($data['session'], $data['iv'], $data['encryptData']); 101 | 102 | // 返回JSON 103 | return $result; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/MiniProgram/DomainController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\MiniProgram; 13 | 14 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 15 | use iBrand\Wechat\Platform\Services\PlatformService; 16 | 17 | /** 18 | * 修改服务器地址 19 | * Class DomainController. 20 | */ 21 | class DomainController extends Controller 22 | { 23 | protected $platform; 24 | 25 | public function __construct( 26 | PlatformService $platformService 27 | ) { 28 | $this->platform = $platformService; 29 | } 30 | 31 | /** 32 | * 设置小程序服务器域名. 33 | * 34 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 35 | * 36 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 37 | */ 38 | public function modify() 39 | { 40 | // 参数 41 | $appid = request('appid'); 42 | 43 | $data = request()->json()->all(); 44 | 45 | // 授权 46 | $server = $this->platform->miniProgramAPI($appid); 47 | 48 | // 调用接口 49 | $result = $server->domain->modify($data); 50 | 51 | // 返回JSON 52 | return $result; 53 | } 54 | 55 | /** 56 | * 设置小程序业务域名(仅供第三方代小程序调用). 57 | * 58 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 59 | * 60 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 61 | */ 62 | public function setWebviewDomain() 63 | { 64 | // 参数 65 | $appid = request('appid'); 66 | 67 | $action = 'add'; 68 | 69 | $data = request()->json()->all(); 70 | 71 | if (isset($data['action'])) { 72 | $action = $data['action']; 73 | unset($data['action']); 74 | } 75 | 76 | $data = request()->json()->all(); 77 | 78 | // 授权 79 | $server = $this->platform->miniProgramAPI($appid); 80 | 81 | // 调用接口 82 | $result = $server->domain->setWebviewDomain($data, $action); 83 | 84 | // 返回JSON 85 | return $result; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/MiniProgram/TesterController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers\MiniProgram; 13 | 14 | use iBrand\Wechat\Platform\Http\Controllers\Controller; 15 | use iBrand\Wechat\Platform\Services\PlatformService; 16 | 17 | /** 18 | * 体验成员管理 19 | * Class TesterController. 20 | */ 21 | class TesterController extends Controller 22 | { 23 | protected $platform; 24 | 25 | public function __construct( 26 | PlatformService $platformService 27 | ) { 28 | $this->platform = $platformService; 29 | } 30 | 31 | /** 32 | * 获取体验者列表. 33 | * 34 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 35 | * 36 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 37 | */ 38 | public function list() 39 | { 40 | // 参数 41 | $appid = request('appid'); 42 | 43 | $data = request()->json()->all(); 44 | 45 | // 授权 46 | $server = $this->platform->miniProgramAPI($appid); 47 | 48 | // 调用接口 49 | $result = $server->tester->list(); 50 | 51 | // 返回JSON 52 | return $result; 53 | } 54 | 55 | /** 56 | * 绑定微信用户为小程序体验者. 57 | * 58 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 59 | * 60 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 61 | */ 62 | public function bind() 63 | { 64 | // 参数 65 | $appid = request('appid'); 66 | 67 | $data = request()->json()->all(); 68 | 69 | // 授权 70 | $server = $this->platform->miniProgramAPI($appid); 71 | 72 | // 调用接口 73 | $result = $server->tester->bind($data['wechatid']); 74 | 75 | // 返回JSON 76 | return $result; 77 | } 78 | 79 | /** 80 | * 解除绑定小程序的体验者. 81 | * 82 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 83 | * 84 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 85 | */ 86 | public function unbind() 87 | { 88 | // 参数 89 | $appid = request('appid'); 90 | 91 | $data = request()->json()->all(); 92 | 93 | // 授权 94 | $server = $this->platform->miniProgramAPI($appid); 95 | 96 | // 调用接口 97 | $result = $server->tester->unbind($data['wechatid']); 98 | 99 | // 返回JSON 100 | return $result; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/NotifyController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Repositories\AuthorizerRepository; 15 | use iBrand\Wechat\Platform\Services\MessageService; 16 | use iBrand\Wechat\Platform\Services\PlatformService; 17 | 18 | /** 19 | * Class NotifyController. 20 | */ 21 | class NotifyController extends Controller 22 | { 23 | protected $platformService; 24 | 25 | protected $messageService; 26 | 27 | protected $authorizerRepository; 28 | 29 | public function __construct( 30 | PlatformService $platformService, MessageService $messageService, AuthorizerRepository $authorizerRepository 31 | ) { 32 | $this->platformService = $platformService; 33 | $this->messageService = $messageService; 34 | $this->authorizerRepository = $authorizerRepository; 35 | } 36 | 37 | /** 38 | * 授权事件接收URL. 39 | * 40 | * @param PlatformService $component 41 | * 42 | * @return string 43 | */ 44 | public function notifyPlatform() 45 | { 46 | return $this->platformService->authEventProcess(); 47 | } 48 | 49 | /** 50 | * 公众号消息与事件接收URL. 51 | * 52 | * @param $appid 53 | * 54 | * @return \Symfony\Component\HttpFoundation\Response 55 | */ 56 | public function notifyAccount($appid) 57 | { 58 | 59 | if($appid=='wx570bc396a51b8ff8'){ 60 | 61 | return $this->messageService->FullNetworkReleaseReceiver($appid); 62 | } 63 | 64 | $authorizer = $this->authorizerRepository->getAuthorizer($appid); 65 | 66 | if (isset($authorizer->type) and 2 == $authorizer->type) { 67 | return $this->messageService->miniProgramProcess($appid); 68 | } 69 | 70 | return $this->messageService->accountEventProcess($appid); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/OAuthController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\OAuthService; 15 | use iBrand\Wechat\Platform\Services\PlatformService; 16 | use Illuminate\Support\Facades\Redirect; 17 | 18 | /** 19 | * Class OAuthController. 20 | */ 21 | class OAuthController extends Controller 22 | { 23 | const OAUTH_REDIRECT = 'oauth.redirect'; 24 | 25 | const API_USERINFO = 'https://api.weixin.qq.com/sns/userinfo'; 26 | 27 | protected $OAuthService; 28 | 29 | protected $platformService; 30 | 31 | public function __construct( 32 | PlatformService $platformService, OAuthService $OAuthService 33 | ) { 34 | $this->platformService = $platformService; 35 | $this->OAuthService = $OAuthService; 36 | } 37 | 38 | /** 39 | * 第三方登录. 40 | * 41 | * @return \Symfony\Component\HttpFoundation\RedirectResponse 42 | * 43 | * @throws \Exception 44 | */ 45 | public function oauth() 46 | { 47 | // 参数 48 | $appid = request('appid'); 49 | 50 | $scope = !empty(request('scope')) ? request('scope') : 'snsapi_userinfo'; 51 | 52 | $server = $this->platformService->authorizeAPI($appid); 53 | 54 | // 记录回调地址 55 | session([self::OAUTH_REDIRECT => request('redirect')]); 56 | 57 | return $response = $server->oauth->scopes(["$scope"])->redirect(); 58 | } 59 | 60 | /** 61 | * 第三方登录回调. 62 | * 63 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View 64 | * 65 | * @throws \Exception 66 | */ 67 | public function result() 68 | { 69 | $request = request()->all(); 70 | 71 | if (!isset($request['appid']) || !isset($request['code']) || !isset($request['state'])) { 72 | return view('welcome'); 73 | } 74 | 75 | $server = $this->platformService->authorizeAPI($request['appid']); 76 | 77 | $user = $server->oauth->user(); 78 | 79 | $this->OAuthService->saveAuthorization($user, $request['appid']); 80 | 81 | // 回调返回openid 82 | $url = session(self::OAUTH_REDIRECT).'?openid='.$user->id; 83 | 84 | return Redirect::to($url); 85 | } 86 | 87 | /** 88 | * 获取用户信息. 89 | * 90 | * @return mixed|null 91 | * 92 | * @throws \Exception 93 | */ 94 | public function userinfo() 95 | { 96 | $appid = request('appid'); 97 | 98 | $openid = request('openid'); 99 | 100 | $server = $this->platformService->authorizeAPI($appid); 101 | 102 | return $this->OAuthService->getUserInfo($appid, $openid); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/PlatformController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Models\Clients; 15 | use iBrand\Wechat\Platform\Services\PlatformService; 16 | 17 | /** 18 | * Class PlatformController. 19 | */ 20 | class PlatformController extends Controller 21 | { 22 | protected $platformService; 23 | 24 | public function __construct( 25 | PlatformService $platformService 26 | ) { 27 | $this->platformService = $platformService; 28 | } 29 | 30 | /** 31 | * 微信公众号授权页. 32 | * 33 | * @return mixed 34 | */ 35 | public function auth() 36 | { 37 | $clientId = request('client_id'); 38 | 39 | //$redirectUrl = request('redirect_url'); 40 | 41 | $authCode = request('authCode'); 42 | 43 | $callback = route('component.auth.result', ['client_id' => $clientId]); 44 | 45 | $url = $this->platformService->authRedirectUrl($callback); 46 | 47 | if (!strstr($url, 'auth_type')) { 48 | $url .= '&auth_type=1'; 49 | } 50 | 51 | return view('wechat-platform::platform.auth', ['redirect_url' => $url]); 52 | } 53 | 54 | /** 55 | * 小程序授权页. 56 | * 57 | * @return mixed 58 | */ 59 | public function authMini() 60 | { 61 | $clientId = request('client_id'); 62 | 63 | $authCode = request('authCode'); 64 | 65 | $callback = route('component.auth.result', ['client_id' => $clientId]); 66 | 67 | $url = $this->platformService->authRedirectUrl($callback); 68 | 69 | if (!strstr($url, 'auth_type')) { 70 | $url .= '&auth_type=2'; 71 | } 72 | 73 | return view('wechat-platform::platform.auth', ['redirect_url' => $url]); 74 | } 75 | 76 | /** 77 | * 保存授权信息. 78 | * 79 | * @return string 80 | * 81 | * @internal param Request $request 82 | */ 83 | public function authResult() 84 | { 85 | $auth_code = request('auth_code'); 86 | $authorizer = $this->platformService->saveAuthorization($auth_code); 87 | if ($clientId = request('client_id')) { 88 | $authorizer->client_id = $clientId; 89 | $authorizer->save(); 90 | } 91 | 92 | return '授权成功!'; 93 | } 94 | 95 | /** 96 | * getToken. 97 | * 98 | * @return \Illuminate\Http\JsonResponse 99 | */ 100 | public function getToken() 101 | { 102 | $clientId = request('client_id'); 103 | 104 | $client_secret = request('client_secret'); 105 | 106 | $client = Clients::where('id', $clientId)->where('secret', $client_secret)->first(); 107 | 108 | if (!$client) { 109 | return response() 110 | ->json(['token_type' => 'Bearer', 'access_token' => '']); 111 | } 112 | 113 | $token = $client->createToken($client->secret)->accessToken; 114 | 115 | return response() 116 | ->json(['token_type' => 'Bearer', 'access_token' => $token, 'expires_in' => 864000]); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/QRCodeController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\PlatformService; 15 | 16 | /** 17 | * 二维码 18 | * Class QRCodeController. 19 | */ 20 | class QRCodeController extends Controller 21 | { 22 | protected $platform; 23 | 24 | public function __construct( 25 | PlatformService $platformService 26 | ) { 27 | $this->platform = $platformService; 28 | } 29 | 30 | /** 31 | * 创建临时二维码 32 | * 33 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 34 | * 35 | * @throws \Exception 36 | */ 37 | public function storeTemporary() 38 | { 39 | // 参数 40 | $appid = request('appid'); 41 | 42 | $data = request()->json()->all(); 43 | 44 | $expireSeconds = !isset($data['expire_seconds']) || empty($data['expire_seconds']) ? null : $data['expire_seconds']; 45 | 46 | // 授权 47 | $server = $this->platform->authorizeAPI($appid); 48 | 49 | // 调用接口 50 | $result = $server->qrcode->temporary($data['scene_id'], $expireSeconds); 51 | 52 | if (isset($result['ticket']) and !empty($result['ticket'])) { 53 | $res = $server->qrcode->url($result['ticket']); 54 | 55 | $result['qr_code_url'] = $res; 56 | 57 | return $result; 58 | } 59 | // 返回JSON 60 | return $result; 61 | } 62 | 63 | /** 64 | * 创建永久二维码 65 | * 66 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 67 | * 68 | * @throws \Exception 69 | */ 70 | public function storeForever() 71 | { 72 | // 参数 73 | $appid = request('appid'); 74 | 75 | $data = request()->json()->all(); 76 | 77 | // 授权 78 | $server = $this->platform->authorizeAPI($appid); 79 | 80 | // 调用接口 81 | $result = $server->qrcode->forever($data['scene_id']); 82 | 83 | if (isset($result['ticket']) and !empty($result['ticket'])) { 84 | $res = $server->qrcode->url($result['ticket']); 85 | 86 | $result['qr_code_url'] = $res; 87 | 88 | return $result; 89 | } 90 | 91 | // 返回JSON 92 | return $result; 93 | } 94 | 95 | /** 96 | * 获取二维码网址 97 | * 98 | * @return string 99 | * 100 | * @throws \Exception 101 | */ 102 | public function getUrl() 103 | { 104 | // 参数 105 | $appid = request('appid'); 106 | 107 | $data = request()->json()->all(); 108 | // 授权 109 | $server = $this->platform->authorizeAPI($appid); 110 | 111 | // 调用接口 112 | $result = $server->qrcode->url($data['ticket']); 113 | 114 | // 返回JSON 115 | return $result; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Controllers/ShortenController.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Controllers; 13 | 14 | use iBrand\Wechat\Platform\Services\PlatformService; 15 | 16 | /** 17 | * 长链接转短链接 18 | * Class ShortenController. 19 | */ 20 | class ShortenController extends Controller 21 | { 22 | protected $platform; 23 | 24 | public function __construct( 25 | PlatformService $platformService 26 | ) { 27 | $this->platform = $platformService; 28 | } 29 | 30 | /** 31 | * 长链接转短链接. 32 | * 33 | * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string 34 | * 35 | * @throws \Exception 36 | */ 37 | public function shorten() 38 | { 39 | // 参数 40 | $appid = request('appid'); 41 | 42 | $data = request()->json()->all(); 43 | 44 | // 授权 45 | $server = $this->platform->authorizeAPI($appid); 46 | 47 | // 调用接口 48 | $result = $server->url->shorten($data['url']); 49 | 50 | // 返回JSON 51 | return $result; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Middleware/ClientVerify.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Middleware; 13 | 14 | use Closure; 15 | use Exception; 16 | 17 | /** 18 | * Class ClientVerify. 19 | */ 20 | class ClientVerify 21 | { 22 | public function handle($request, Closure $next) 23 | { 24 | if (!auth('clients')->user()) { 25 | throw new Exception('Unauthorised', 3); 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Http/Middleware/ParameterVerify.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Http\Middleware; 13 | 14 | use Closure; 15 | use Exception; 16 | 17 | /** 18 | * 验证调用api的参数是否完整 19 | * Class ParameterVerify. 20 | */ 21 | class ParameterVerify 22 | { 23 | public function handle($request, Closure $next) 24 | { 25 | if (null == request('appid')) { 26 | throw new Exception('Required parameter missing', 2); 27 | } 28 | 29 | return $next($request); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/Authorizer.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class Authorizer extends Model 17 | { 18 | protected $table = 'authorizers'; 19 | 20 | protected $guarded = ['id']; 21 | } 22 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/Clients.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Foundation\Auth\User as Authenticatable; 15 | use Illuminate\Notifications\Notifiable; 16 | use Laravel\Passport\HasApiTokens; 17 | 18 | class Clients extends Authenticatable 19 | { 20 | use HasApiTokens,Notifiable; 21 | protected $table = 'oauth_clients'; 22 | protected $guarded = ['id']; 23 | 24 | public function wechat() 25 | { 26 | return $this->hasMany(Authorizer::class, 'client_id')->where('type', 1); 27 | } 28 | 29 | public function mini() 30 | { 31 | return $this->hasMany(Authorizer::class, 'client_id')->where('type', 2); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/CodePublish.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class CodePublish extends Model 17 | { 18 | const SUCCESS_STATUS = 0; //审核成功 19 | 20 | const ERROR_STATUS = 1; //审核失败 21 | 22 | const AUDIT_STATUS = 2; //待审核 23 | 24 | const PUBLISH_STATUS = 3; //已发布 25 | 26 | const WITHDRW_STATUS = 4; //审核撤回 27 | 28 | protected $table = 'code_publish'; 29 | 30 | protected $guarded = ['id']; 31 | } 32 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/Oauth2Token.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class Oauth2Token extends Model 17 | { 18 | protected $table = 'oauth2_tokens'; 19 | protected $guarded = ['id']; 20 | } 21 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/Testers.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class Testers extends Model 17 | { 18 | protected $table = 'testers'; 19 | 20 | protected $guarded = ['id']; 21 | } 22 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/Theme.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class Theme extends Model 17 | { 18 | protected $table = 'theme'; 19 | 20 | protected $guarded = ['id']; 21 | 22 | public function items(){ 23 | 24 | return $this->hasMany(ThemeItems::class,'theme_id')->where('type',1); 25 | } 26 | 27 | public function bars(){ 28 | 29 | return $this->hasMany(ThemeItems::class,'theme_id')->where('type',2); 30 | } 31 | 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/ThemeItems.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class ThemeItems extends Model 17 | { 18 | protected $table = 'theme_items'; 19 | 20 | protected $guarded = ['id']; 21 | } 22 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Models/ThemeTemplate.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Models; 13 | 14 | use Illuminate\Database\Eloquent\Model; 15 | 16 | class ThemeTemplate extends Model 17 | { 18 | protected $table = 'theme_template'; 19 | 20 | protected $guarded = ['id']; 21 | 22 | public function theme(){ 23 | 24 | return $this->belongsTo(Theme::class,'theme_id'); 25 | } 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Providers; 13 | 14 | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; 15 | use Illuminate\Support\Facades\Route; 16 | 17 | class RouteServiceProvider extends ServiceProvider 18 | { 19 | /** 20 | * This namespace is applied to your controller routes. 21 | * 22 | * In addition, it is set as the URL generator's root namespace. 23 | * 24 | * @var string 25 | */ 26 | protected $namespace = 'iBrand\Wechat\Platform\Http\Controllers'; 27 | 28 | /** 29 | * Define your route model bindings, pattern filters, etc. 30 | */ 31 | public function boot() 32 | { 33 | parent::boot(); 34 | } 35 | 36 | /** 37 | * Define the routes for the application. 38 | */ 39 | public function map() 40 | { 41 | $this->mapApiRoutes(); 42 | 43 | $this->mapWebRoutes(); 44 | 45 | $this->mapAdminRoutes(); 46 | } 47 | 48 | /** 49 | * Define the "web" routes for the application. 50 | * 51 | * These routes all receive session state, CSRF protection, etc. 52 | */ 53 | protected function mapWebRoutes() 54 | { 55 | Route::group([ 56 | 'middleware' => 'web', 57 | 'namespace' => $this->namespace, 58 | ], function ($router) { 59 | require __DIR__.'/../routes/web.php'; 60 | }); 61 | } 62 | 63 | /** 64 | * Define the "api" routes for the application. 65 | * 66 | * These routes are typically stateless. 67 | */ 68 | protected function mapApiRoutes() 69 | { 70 | Route::group([ 71 | 'middleware' => 'api', 72 | 'namespace' => $this->namespace, 73 | 'prefix' => 'api', 74 | ], function ($router) { 75 | require __DIR__.'/../routes/api.php'; 76 | }); 77 | } 78 | 79 | /** 80 | * Define the "admin" routes for the application. 81 | * 82 | * These routes are typically stateless. 83 | */ 84 | protected function mapAdminRoutes() 85 | { 86 | $attributes = [ 87 | 'prefix' => config('admin.route.prefix'), 88 | 'namespace' => $this->namespace.'\Admin', 89 | 'middleware' => config('admin.route.middleware'), 90 | ]; 91 | Route::group($attributes, function ($router) { 92 | require __DIR__.'/../routes/admin.php'; 93 | }); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Providers/WechatPlatformServiceProvider.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Providers; 13 | 14 | use iBrand\Wechat\Platform\WechatPlatFormBackend; 15 | use Illuminate\Support\ServiceProvider; 16 | use iBrand\Wechat\Platform\Console\InstallCommand; 17 | 18 | class WechatPlatformServiceProvider extends ServiceProvider 19 | { 20 | 21 | /** 22 | * @var array 23 | */ 24 | protected $commands = [ 25 | InstallCommand::class 26 | ]; 27 | 28 | /** 29 | * Bootstrap any application services. 30 | */ 31 | public function boot() 32 | { 33 | WechatPlatFormBackend::boot(); 34 | 35 | $this->loadViewsFrom(__DIR__.'/../../resources/views', 'wechat-platform'); 36 | 37 | if ($this->app->runningInConsole()) { 38 | // $this->publishes([ 39 | // __DIR__ . '/../../resources/assets' => public_path('assets'), 40 | // ], 'wechat-platform-assets'); 41 | 42 | $this->publishes([ 43 | __DIR__.'/../config.php' => config_path('wechat-platform.php'), 44 | ]); 45 | 46 | $this->publishes([ 47 | __DIR__.'/../mini_program_errcode.php' => config_path('mini_program_errcode.php'), 48 | ]); 49 | 50 | return $this->loadMigrationsFrom(__DIR__.'/../../migrations'); 51 | } 52 | } 53 | 54 | /** 55 | * Register any application services. 56 | */ 57 | public function register() 58 | { 59 | $this->mergeConfigFrom( 60 | __DIR__.'/../config.php', 'wechat-platform' 61 | ); 62 | $this->commands($this->commands); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/AuthorizerRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\Authorizer; 15 | use Prettus\Repository\Eloquent\BaseRepository; 16 | 17 | /** 18 | * Class AuthorizerRepository. 19 | */ 20 | class AuthorizerRepository extends BaseRepository 21 | { 22 | public function model() 23 | { 24 | return Authorizer::class; 25 | } 26 | 27 | /** 28 | * 获取APP授权. 29 | * 30 | * @param $appid 31 | * 32 | * @return Authorizer 33 | */ 34 | public function getAuthorizer($appid) 35 | { 36 | $authorizer = $this->model->where('appid', $appid)->first(); 37 | 38 | return $authorizer; 39 | } 40 | 41 | /** 42 | * 获取APP授权, 不存在则创建一个. 43 | * 44 | * @param $appid 45 | * 46 | * @return mixed 47 | */ 48 | public function ensureAuthorizer($appid) 49 | { 50 | $authorizer = $this->model->firstOrNew(['appid' => $appid]); 51 | 52 | return $authorizer; 53 | } 54 | 55 | /** 56 | * @param $clientId 57 | * @param int $type 58 | * 59 | * @return mixed 60 | */ 61 | public function getAuthorizersByClient($clientId, $type = 1) 62 | { 63 | return $this->model->where('client_id', $clientId)->where('type', $type)->get(); 64 | } 65 | 66 | /** 67 | * @param $clientId 68 | * @param $url 69 | * 70 | * @return mixed 71 | */ 72 | public function updateCallBackUrl($clientId, $url) 73 | { 74 | return $this->model->where('client_id', $clientId)->update(['call_back_url' => $url]); 75 | } 76 | 77 | /** 78 | * @param $clientId 79 | * @param $app_id 80 | * 81 | * @return mixed 82 | */ 83 | public function updateDel($clientId, $app_id) 84 | { 85 | return $this->model->where(['client_id' => $clientId, 'appid' => $app_id])->update(['client_id' => 0]); 86 | } 87 | 88 | /** 89 | * @param $appId 90 | * 91 | * @return string 92 | */ 93 | public function getCallBackUrl($appId) 94 | { 95 | $res = $this->model->where('appid', $appId)->first(['call_back_url'])->toArray(); 96 | 97 | return isset($res['call_back_url']) ? $res['call_back_url'] : ''; 98 | } 99 | 100 | /** 101 | * @param $app_id 102 | */ 103 | public function getAuthorizationByAppID($app_id) 104 | { 105 | $authorizer = $this->model->where(['appid' => $app_id])->first(); 106 | if ($authorizer and $authorizer->client_id) { 107 | return $authorizer; 108 | } 109 | 110 | return null; 111 | } 112 | 113 | public function getAuthorizerList($type, $client_id = null, $appid = null, $limit = 20) 114 | { 115 | $query = $this->model->where('type', $type)->where('client_id', '<>', 0); 116 | 117 | if (null != $client_id) { 118 | $query = $query->where('client_id', $client_id); 119 | } 120 | 121 | if (null != $appid) { 122 | $query = $query->where('appid', '<>', null)->where('appid', 'like', '%'.$appid.'%'); 123 | } 124 | 125 | return $query->orderBy('created_at', 'desc')->paginate($limit); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/ClientsRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\Clients; 15 | use Prettus\Repository\Eloquent\BaseRepository; 16 | 17 | /** 18 | * Class ClientsRepository. 19 | */ 20 | class ClientsRepository extends BaseRepository 21 | { 22 | public function model() 23 | { 24 | return Clients::class; 25 | } 26 | 27 | /** 28 | * @param $name 29 | * @param int $limit 30 | * 31 | * @return mixed 32 | */ 33 | public function getListsByname($name, $limit = 20) 34 | { 35 | $query = $this->model; 36 | 37 | if ($name) { 38 | $query = $query->where('name', 'like', '%'.$name.'%'); 39 | } 40 | 41 | return $query->orderBy('created_at', 'desc')->paginate($limit); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/CodePublishRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use Carbon\Carbon; 15 | use iBrand\Wechat\Platform\Models\CodePublish; 16 | use Prettus\Repository\Eloquent\BaseRepository; 17 | 18 | /** 19 | * Class CodePublishRepository. 20 | */ 21 | class CodePublishRepository extends BaseRepository 22 | { 23 | public function model() 24 | { 25 | return CodePublish::class; 26 | } 27 | 28 | /** 29 | * @param $appid 30 | * 31 | * @return mixed 32 | */ 33 | public function getAuditByAppID($appid) 34 | { 35 | return $this->model->where('appid', $appid) 36 | ->orderBy('audit_time', 'desc')->first(); 37 | } 38 | 39 | /** 40 | * @param $data 41 | * 42 | * @return mixed 43 | */ 44 | public function getItemOrCreate($data) 45 | { 46 | $item = $this->model->where('appid', $data['appid']) 47 | ->where('auditid', $data['auditid'])->first(); 48 | 49 | if ($item) { 50 | return $item; 51 | } 52 | 53 | return $this->model->create($data); 54 | } 55 | 56 | /** 57 | * @param $appid 58 | * @param null $auditid 59 | * @param int $limit 60 | * 61 | * @return mixed 62 | */ 63 | public function getListsByAppID($appid, $auditid = null, $limit = 20) 64 | { 65 | $query = $this->model->where('appid', $appid); 66 | 67 | if ($auditid) { 68 | $query->where('auditid', $auditid); 69 | } 70 | 71 | return $query->orderBy('audit_time', 'desc')->paginate($limit); 72 | } 73 | 74 | /** 75 | * @param $audit 76 | * @param $res_status 77 | * @param string $res_reason 78 | * 79 | * @return mixed 80 | */ 81 | public function renew($audit, $res_status, $res_reason = '') 82 | { 83 | if (isset($audit->status) and $res_status != $audit->status and 2 == $audit->status) { 84 | $item = $this->model->find($audit->id); 85 | 86 | $item->reason = $res_reason; 87 | 88 | $item->status = $res_status; 89 | 90 | if (0 == $res_status) { 91 | $item->audit_success_time = date('Y-m-d H:s:i', Carbon::now()->timestamp); 92 | } 93 | 94 | $item->save(); 95 | 96 | return $item; 97 | } 98 | 99 | return $audit; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/OAuthTokenRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\Oauth2Token; 15 | 16 | /** 17 | * OAuthToken 仓库. 18 | * Class OAuthTokenRepository. 19 | */ 20 | class OAuthTokenRepository 21 | { 22 | /** 23 | * 获取授权TOKEN. 24 | * 25 | * @param $appid 26 | * @param $openid 27 | * 28 | * @return mixed 29 | */ 30 | public function getToken($appid, $openid) 31 | { 32 | $oauth_token = Oauth2Token::where('appid', $appid) 33 | ->where('openid', $openid) 34 | ->first(); 35 | 36 | return $oauth_token; 37 | } 38 | 39 | /** 40 | * 获取APP授权, 不存在则创建一个. 41 | * 42 | * @param $appid 43 | * @param $openid 44 | * 45 | * @return mixed 46 | */ 47 | public function ensureToken($appid, $openid) 48 | { 49 | return Oauth2Token::firstOrNew(['appid' => $appid, 'openid' => $openid]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/TesterRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\Testers; 15 | use Prettus\Repository\Eloquent\BaseRepository; 16 | 17 | /** 18 | * Class TesterRepository. 19 | */ 20 | class TesterRepository extends BaseRepository 21 | { 22 | public function model() 23 | { 24 | return Testers::class; 25 | } 26 | 27 | /** 28 | * @param $appid 29 | * 30 | * @return mixed 31 | */ 32 | public function getListByAppId($appid) 33 | { 34 | return $this->model->where('appid', $appid)->get(); 35 | } 36 | 37 | /** 38 | * @param $appid 39 | * @param $wechatid 40 | * 41 | * @return mixed 42 | */ 43 | public function getTesterByWechatId($appid, $wechatid) 44 | { 45 | return $this->model->where('appid', $appid)->where('wechatid', $wechatid)->first(); 46 | } 47 | 48 | /** 49 | * @param $appid 50 | * @param $wechatid 51 | * 52 | * @return mixed 53 | */ 54 | public function ensureTester($appid, $wechatid) 55 | { 56 | $tester = $this->model->where('wechatid', $wechatid)->where('appid', $appid)->first(); 57 | 58 | if (!$tester) { 59 | $tester = $this->model->create(['wechatid' => $wechatid, 'appid' => $appid]); 60 | } 61 | 62 | return $tester; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/ThemeItemsRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\ThemeItems; 15 | use Prettus\Repository\Eloquent\BaseRepository; 16 | 17 | /** 18 | * Class ThemeTemplateRepository. 19 | */ 20 | class ThemeItemsRepository extends BaseRepository 21 | { 22 | 23 | public function model() 24 | { 25 | return ThemeItems::class; 26 | } 27 | 28 | /** 29 | * @param $theme_id 30 | * @param int $limit 31 | * @return mixed 32 | */ 33 | 34 | public function getAll($theme_id,$type=1, $limit = 20) 35 | { 36 | return $this->model 37 | ->where('theme_id',$theme_id) 38 | ->where('type', $type) 39 | ->where('theme_id', '<>', 0)->orderBy('created_at', 'desc')->paginate($limit); 40 | } 41 | 42 | /** 43 | * @param $id 44 | * @param $theme_id 45 | * @return mixed 46 | */ 47 | public function setDefaultTheme($id, $theme_id,$type=1) 48 | { 49 | $default = $this->model->where('is_default', 1)->where('theme_id', $theme_id)->where('type', $type)->first(); 50 | 51 | if ($default) { 52 | 53 | $default->is_default = 0; 54 | 55 | $default->save(); 56 | } 57 | 58 | $item = $this->model->find($id); 59 | 60 | $item->is_default = 1; 61 | 62 | return $item->save(); 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/ThemeRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\Theme; 15 | use Prettus\Repository\Eloquent\BaseRepository; 16 | 17 | /** 18 | * Class ThemeTemplateRepository. 19 | */ 20 | class ThemeRepository extends BaseRepository 21 | { 22 | 23 | public function model() 24 | { 25 | return Theme::class; 26 | } 27 | 28 | /** 29 | * @param int $limit 30 | * @return mixed 31 | */ 32 | public function getAll($limit = 20) 33 | { 34 | return $this->model->orderBy('updated_at', 'desc')->paginate($limit); 35 | } 36 | 37 | /** 38 | * @return mixed 39 | */ 40 | public function getlists() 41 | { 42 | 43 | return $this->model->orderBy('created_at', 'desc')->get(); 44 | } 45 | 46 | /** 47 | * @param $id 48 | * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Model[]|null 49 | */ 50 | public function getThemeInfoBy($id) 51 | { 52 | 53 | return $this->model->with('items')->with('bars')->find($id); 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Repositories/ThemeTemplateRepository.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Repositories; 13 | 14 | use iBrand\Wechat\Platform\Models\ThemeTemplate; 15 | use Prettus\Repository\Eloquent\BaseRepository; 16 | 17 | /** 18 | * Class ThemeTemplateRepository. 19 | */ 20 | class ThemeTemplateRepository extends BaseRepository 21 | { 22 | 23 | public function model() 24 | { 25 | return ThemeTemplate::class; 26 | } 27 | 28 | 29 | /** 30 | * @param $template_id 31 | * @return mixed 32 | */ 33 | public function getThemeItemByTemplateID($template_id) 34 | { 35 | 36 | return $this->model 37 | ->where('template_id', $template_id) 38 | ->with('theme') 39 | ->with('theme.items') 40 | ->with('theme.bars') 41 | ->first(); 42 | } 43 | 44 | /** 45 | * @param $template_id 46 | * @return mixed 47 | */ 48 | public function getThemefirstByTemplateID($template_id) 49 | { 50 | return $this->model->where('template_id', $template_id)->first(); 51 | } 52 | 53 | 54 | /** 55 | * @param $template_id 56 | * @param $theme_id 57 | * @return mixed 58 | */ 59 | public function operateThemeTemplate($template_id, $theme_id) 60 | { 61 | 62 | $theme_template = $this->model->where('template_id', $template_id)->first(); 63 | 64 | if ($theme_template) { 65 | 66 | $theme_template->theme_id = $theme_id; 67 | 68 | return $theme_template->save(); 69 | } 70 | 71 | return $this->model->create(['template_id' => $template_id, 'theme_id' => $theme_id]); 72 | 73 | } 74 | 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Services/CodeService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Services; 13 | 14 | use iBrand\Wechat\Platform\Repositories\CodePublishRepository; 15 | 16 | class CodeService 17 | { 18 | protected $platformService; 19 | 20 | protected $codePublishRepository; 21 | 22 | public function __construct( 23 | PlatformService $platformService, 24 | 25 | CodePublishRepository $codePublishRepository 26 | ) { 27 | $this->platformService = $platformService; 28 | 29 | $this->codePublishRepository = $codePublishRepository; 30 | } 31 | 32 | /** 33 | * @param $appid 34 | * 35 | * @return array 36 | */ 37 | public function getCategory($appid) 38 | { 39 | $server = $this->platformService->getAccount($appid); 40 | 41 | if (null == $server) { 42 | return []; 43 | } 44 | 45 | $res = $server->code->getCategory(); 46 | 47 | return isset($res['category_list']) ? $res['category_list'] : []; 48 | } 49 | 50 | /** 51 | * @param $appid 52 | * 53 | * @return array|string 54 | */ 55 | public function getPage($appid) 56 | { 57 | $server = $this->platformService->getAccount($appid); 58 | 59 | if (null == $server) { 60 | return []; 61 | } 62 | 63 | $res = $server->code->getPage(); 64 | 65 | return isset($res['page_list'][0]) ? $res['page_list'][0] : ''; 66 | } 67 | 68 | /** 69 | * @param $appid 70 | * 71 | * @return array|null 72 | */ 73 | public function getLatestAuditStatus($appid) 74 | { 75 | $server = $this->platformService->getAccount($appid); 76 | 77 | if (null == $server) { 78 | return []; 79 | } 80 | 81 | $res = $server->code->getLatestAuditStatus(); 82 | 83 | if (isset($res['errcode']) and 0 == $res['errcode']) { 84 | return $res; 85 | } 86 | 87 | return null; 88 | } 89 | 90 | /** 91 | * @param $appid 92 | * 93 | * @return array|mixed|null 94 | */ 95 | public function getAppAuditStatus($appid) 96 | { 97 | $audit = $this->codePublishRepository->getAuditByAppID($appid); 98 | 99 | if (!$audit) { 100 | return null; 101 | } 102 | 103 | $server = $this->platformService->getAccount($appid); 104 | 105 | if (null == $server) { 106 | return []; 107 | } 108 | 109 | $res = $server->code->getAuditStatus($audit->auditid); 110 | 111 | $res_reason = isset($res['reason']) ? $res['reason'] : ''; 112 | 113 | if (isset($res['status'])) { 114 | return $this->codePublishRepository->renew($audit, $res['status'], $res_reason); 115 | } 116 | 117 | return $audit; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Services/CodeTemplateService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Services; 13 | 14 | /** 15 | * 小程序代码模版库管理服务 16 | * Class CodeTemplateService. 17 | */ 18 | class CodeTemplateService 19 | { 20 | const DRAFT = 1; //草稿箱 21 | 22 | const FORMAL = 2; //正式模板 23 | 24 | protected $platformService; 25 | 26 | public function __construct( 27 | PlatformService $platformService 28 | ) { 29 | $this->platformService = $platformService; 30 | } 31 | 32 | /** 33 | * 获取草稿箱内的所有临时代码草稿 34 | * 35 | * @return mixed 36 | */ 37 | public function getCodeTemplateGetDrafts() 38 | { 39 | return $this->platformService->server->code_template->getDrafts(); 40 | } 41 | 42 | /** 43 | * 将草稿箱的草稿选为小程序代码模版. 44 | * 45 | * @param $draft_id 46 | * 47 | * @return mixed 48 | */ 49 | public function getCodeTemplateCreateFromDraft($draft_id) 50 | { 51 | return $server = $this->platformService->server->code_template->CreateFromDraft($draft_id); 52 | } 53 | 54 | /** 55 | * 获取代码模版库中的所有小程序代码模版. 56 | * 57 | * @param $draft_id 58 | * 59 | * @return mixed 60 | */ 61 | public function getCodeTemplateList() 62 | { 63 | return $server = $this->platformService->server->code_template->list(); 64 | } 65 | 66 | /** 67 | * 删除指定小程序代码模版. 68 | * 69 | * @param $draft_id 70 | * 71 | * @return mixed 72 | */ 73 | public function deleteCodeTemplate($template_id) 74 | { 75 | return $server = $this->platformService->server->code_template->delete($template_id); 76 | } 77 | 78 | /** 79 | * @param $template_id 80 | * 81 | * @return array 82 | */ 83 | public function getCodeTemplateByTemplateID($template_id) 84 | { 85 | $list = $this->platformService->server->code_template->list(); 86 | 87 | if (isset($list['template_list'])) { 88 | if (count($list['template_list'])) { 89 | foreach ($list['template_list'] as $item) { 90 | if ($template_id == $item['template_id']) { 91 | return $item; 92 | } 93 | } 94 | } 95 | } 96 | 97 | return []; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Services/DomainService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Services; 13 | 14 | /** 15 | * 服务器域名设置 16 | * Class TemplateMessageService. 17 | */ 18 | class DomainService 19 | { 20 | protected $platformService; 21 | 22 | public function __construct( 23 | PlatformService $platformService 24 | ) { 25 | $this->platformService = $platformService; 26 | } 27 | 28 | /** 29 | * @param $appid 30 | * @param array $data 31 | */ 32 | public function action($appid, $data = []) 33 | { 34 | if (!isset($data['action'])) { 35 | $data['action'] = 'get'; 36 | } 37 | 38 | // if ('get' != $data['action']) { 39 | // dd($data); 40 | // } 41 | 42 | $server = $this->platformService->getAccount($appid); 43 | 44 | if (null == $server) { 45 | return $server; 46 | } 47 | 48 | 49 | 50 | return $server->domain->modify($data); 51 | } 52 | 53 | /** 54 | * @return array 55 | */ 56 | public function local() 57 | { 58 | if (!settings('requestdomain') 59 | and !settings('wsrequestdomain') 60 | and !settings('uploaddomain') 61 | and !settings('downloaddomain')) { 62 | return []; 63 | } 64 | 65 | $data['requestdomain'] = settings('requestdomain') ? settings('requestdomain') : []; 66 | 67 | $data['wsrequestdomain'] = settings('wsrequestdomain') ? settings('wsrequestdomain') : []; 68 | 69 | $data['uploaddomain'] = settings('uploaddomain') ? settings('uploaddomain') : []; 70 | 71 | $data['downloaddomain'] = settings('downloaddomain') ? settings('downloaddomain') : []; 72 | 73 | return $data; 74 | } 75 | 76 | /** 77 | * @param array $domain 78 | * @param array $local 79 | * 80 | * @return array 81 | */ 82 | public function filterDomain(array $domain, array $local) 83 | { 84 | $data = []; 85 | 86 | foreach ($domain as $k => $item) { 87 | if (is_array($item) AND isset($local[$k]) AND count($local[$k]) > 0) { 88 | foreach ($local[$k] as $litem) { 89 | if (!in_array($litem, $domain[$k])) { 90 | //$data[$k]=$local[$k]; 91 | 92 | $data = $local; 93 | } 94 | } 95 | } 96 | } 97 | 98 | return $data; 99 | } 100 | 101 | /** 102 | * @param $appid 103 | * @param array $data 104 | * @param string $action 105 | * @return array|\EasyWeChat\Kernel\Support\Collection|\EasyWeChat\OpenPlatform\Application|\EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Application|\EasyWeChat\OpenPlatform\Authorizer\OfficialAccount\Application|null|object|\Psr\Http\Message\ResponseInterface|string 106 | * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException 107 | */ 108 | public function setWebviewDomain($appid, $data = [],$action='add'){ 109 | 110 | $server = $this->platformService->getAccount($appid); 111 | 112 | if (null == $server) { 113 | return $server; 114 | } 115 | 116 | return $server->domain->setWebviewDomain($data,$action); 117 | 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Services/OAuthService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Services; 13 | 14 | use iBrand\Wechat\Platform\Repositories\OAuthTokenRepository; 15 | 16 | /** 17 | * 第三方OAuthService服务 18 | * Class OAuthService. 19 | */ 20 | class OAuthService 21 | { 22 | const API_USERINFO = 'https://api.weixin.qq.com/sns/userinfo'; 23 | 24 | protected $repository; 25 | 26 | public function __construct( 27 | OAuthTokenRepository $repository 28 | ) { 29 | $this->repository = $repository; 30 | } 31 | 32 | /** 33 | * 保存用户授权信息. 34 | * 35 | * @param $user 36 | * @param $appid 37 | * 38 | * @return mixed 39 | */ 40 | public function saveAuthorization($user, $appid) 41 | { 42 | // 保存Token 43 | $token = $this->repository->ensureToken($appid, $user->id); 44 | $token->access_token = $user->token; 45 | /*$token->refresh_token = $user->token->refresh_token; 46 | $token->scope = $user->token->scope; 47 | $token->expires_in = $user->token->expires_in;*/ 48 | $token->save(); 49 | 50 | return $token; 51 | } 52 | 53 | /** 54 | * 获取refresh_token. 55 | * 56 | * @param $appid 57 | * @param $openid 58 | */ 59 | public function getRefreshToken($appid, $openid) 60 | { 61 | if ($token = $this->repository->getToken($appid, $openid)) { 62 | return $token->refresh_token; 63 | } 64 | 65 | return null; 66 | } 67 | 68 | /** 69 | * @param $appid 70 | * @param $openid 71 | * 72 | * @return mixed|null 73 | */ 74 | public function getUserInfo($appid, $openid) 75 | { 76 | if (!$token = $this->repository->getToken($appid, $openid)) { 77 | return null; 78 | } 79 | $abs_url = self::API_USERINFO.'?openid='.$openid.'&access_token='.$token->access_token.'&lang=zh_CN'; 80 | 81 | $abs_url_data = file_get_contents($abs_url); 82 | 83 | $obj_data = json_decode($abs_url_data, true); 84 | 85 | return $obj_data; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/Services/TemplateMessageService.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform\Services; 13 | 14 | /** 15 | * 小程序模板消息设置 16 | * Class TemplateMessageService. 17 | */ 18 | class TemplateMessageService 19 | { 20 | protected $platformService; 21 | 22 | public function __construct( 23 | PlatformService $platformService 24 | ) { 25 | $this->platformService = $platformService; 26 | } 27 | 28 | /** 29 | * @param $appid 30 | */ 31 | public function list($appid) 32 | { 33 | $server = $this->platformService->getAccount($appid); 34 | 35 | if (null == $server) { 36 | return $server; 37 | } 38 | 39 | return $server->template_message->list(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/WechatPlatFormBackend.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace iBrand\Wechat\Platform; 13 | 14 | use Encore\Admin\Admin; 15 | use Encore\Admin\Extension; 16 | use iBrand\Wechat\Platform\Seeds\WechatPlatFormBackendTablesSeeder; 17 | use Illuminate\Support\Facades\Artisan; 18 | 19 | /** 20 | * Class WechatPlatFormBackend. 21 | */ 22 | class WechatPlatFormBackend extends Extension 23 | { 24 | /** 25 | * Bootstrap this package. 26 | */ 27 | public static function boot() 28 | { 29 | Admin::extend('ibrand-wechat-platform-backend', __CLASS__); 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public static function import() 36 | { 37 | Artisan::call('db:seed', ['--class' => WechatPlatFormBackendTablesSeeder::class]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/config.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | return [ 13 | /* 14 | * 开放平台第三方平台 15 | */ 16 | 'open_platform' => [ 17 | 'default' => [ 18 | 'app_id' => env('WECHAT_OPEN_PLATFORM_APPID', ''), 19 | 'secret' => env('WECHAT_OPEN_PLATFORM_SECRET', ''), 20 | 'token' => env('WECHAT_OPEN_PLATFORM_TOKEN', ''), 21 | 'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''), 22 | 23 | /* 24 | * 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 25 | */ 26 | 'response_type' => 'array', 27 | 28 | /* 29 | * 使用 Laravel 的缓存系统 30 | */ 31 | 'use_laravel_cache' => true, 32 | 33 | /* 34 | * 日志配置 35 | * 36 | * level: 日志级别,可选为: 37 | * debug/info/notice/warning/error/critical/alert/emergency 38 | * file:日志文件位置(绝对路径!!!),要求可写权限 39 | */ 40 | 'log' => [ 41 | 'level' => env('WECHAT_LOG_LEVEL', 'debug'), 42 | 'file' => env('WECHAT_LOG_FILE', storage_path('logs/wechat-'.date('Y-m').'.log')), 43 | ], 44 | ], 45 | ], 46 | ]; 47 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/helpers.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | function FilterHttpsAndWss($http) 13 | { 14 | if ($http) { 15 | $arr = explode('//', $http); 16 | $http = $arr[1]; 17 | } 18 | 19 | return $http; 20 | } 21 | 22 | function get_host() 23 | { 24 | $scheme = $_SERVER['HTTPS'] == 'off' ? 'http://' : 'https://'; 25 | $url = $scheme . $_SERVER['HTTP_HOST']; 26 | return $url; 27 | } 28 | 29 | function is_color($str){ 30 | $exp="/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/"; 31 | 32 | return preg_match($exp,$str); 33 | 34 | } 35 | 36 | function ibrand_count($obj){ 37 | 38 | if(is_array($obj)){ 39 | return count($obj); 40 | } 41 | 42 | if(is_object($obj)){ 43 | 44 | return $obj->count(); 45 | } 46 | 47 | if($obj){ 48 | 49 | return 1; 50 | } 51 | 52 | return 0; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/mini_program_errcode.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | return [ 13 | '-1' => '系统繁忙', 14 | 15 | '85064' => '找不到草稿或模板', 16 | '85065' => '模版库已满', 17 | 18 | '85015' => '该账号不是小程序账号或版本输入错误', 19 | '85016' => '域名数量超过限制', 20 | '85017' => '没有新增域名,请确认小程序已经添加了域名或该域名是否没有在第三方平台添加', 21 | '85018' => '域名没有在第三方平台设置', 22 | 23 | '89019' => '业务域名无更改,无需重复设置', 24 | '89020' => '尚未设置小程序业务域名,请先在第三方平台中设置小程序业务域名后在调用本接口', 25 | '89021' => '请求保存的域名不是第三方平台中已设置的小程序业务域名或子域名', 26 | '89029' => '业务域名数量超过限制', 27 | '89031' => '个人小程序不支持调用setwebviewdomain接口', 28 | 29 | '85001' => '微信号不存在或微信号设置为不可搜索', 30 | '85002' => '小程序绑定的体验者数量达到上限', 31 | '85003' => '微信号绑定的小程序体验者达到上限', 32 | '85004' => '微信号已经绑定', 33 | 34 | '85013' => '无效的自定义配置', 35 | '85014' => '无效的模版编号', 36 | '85043' => '模版错误', 37 | '85044' => '代码包超过大小限制', 38 | '85045' => 'ext_json有不存在的路径', 39 | '85046' => 'tabBar中缺少path', 40 | '85047' => 'pages字段为空', 41 | '85048' => 'ext_json解析失败', 42 | 43 | '86000' => '不是由第三方代小程序进行调用', 44 | '86001' => '不存在第三方的已经提交的代码', 45 | 46 | '85006' => '标签格式错误', 47 | '85007' => '页面路径错误', 48 | '85008' => '类目填写错误', 49 | '85009' => '已经有正在审核的版本', 50 | '85010' => 'item_list有项目为空', 51 | '85011' => '标题填写错误', 52 | '85023' => '审核列表填写的项目数不在1-5以内', 53 | '85077' => '小程序类目信息失效(类目中含有官方下架的类目,请重新选择类目)', 54 | '86002' => '小程序还未设置昵称、头像、简介。请先设置完后再重新提交', 55 | '85085' => '近7天提交审核的小程序数量过多,请耐心等待审核完毕后再次提交', 56 | '85086' => '提交代码审核之前需提前上传代码', 57 | 58 | '85012' => '无效的审核id', 59 | 60 | '85019' => '没有审核版本', 61 | '85020' => '审核状态未满足发布', 62 | 63 | '85021' => '状态不可变', 64 | '85022' => 'action非法', 65 | 66 | '87011' => '现网已经在灰度发布,不能进行版本回退', 67 | '87012' => '该版本不能回退,可能的原因:1:无上一个线上版用于回退 2:此版本为已回退版本,不能回退 3:此版本为回退功能上线之前的版本,不能回退', 68 | 69 | '87013' => '撤回次数达到上限(每天一次,每个月10次)', 70 | ]; 71 | -------------------------------------------------------------------------------- /modules/WechatPlatform/src/routes/web.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | $router->post('/oauth/token', 'PlatformController@getToken'); 13 | 14 | // 引导用户进行公众号授权 15 | $router->get('/platform/auth', 'PlatformController@auth')->name('web.platform.auth'); 16 | // 引导用户进行小程序授权 17 | $router->get('/platform/mini/auth', 'PlatformController@authMini')->name('web.platform.mini.auth'); 18 | 19 | // 授权成功提示页面 20 | $router->get('/platform/auth/result', 'PlatformController@authResult')->name('component.auth.result'); 21 | // 引导用户进行OAuth授权 22 | $router->get('/oauth', 'OAuthController@oauth')->middleware(['middleware' => 'parameter']); 23 | // OAuth授权结果返回 24 | $router->get('/', 'OAuthController@result')->name('oauth.result'); 25 | 26 | $router->get('/wx6f54b9a50feda087/test',function (){ 27 | return response()->json( 28 | ['status' => true, 'code' => 200, 'message' => '', 'data' => []]); 29 | }); 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 6 | "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 7 | "watch-poll": "npm run watch -- --watch-poll", 8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 9 | "prod": "npm run production", 10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 11 | }, 12 | "devDependencies": { 13 | "axios": "^0.17", 14 | "bootstrap-sass": "^3.3.7", 15 | "cross-env": "^5.1", 16 | "jquery": "^3.2", 17 | "laravel-mix": "^1.0", 18 | "lodash": "^4.17.4", 19 | "vue": "^2.5.7" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Feature 14 | 15 | 16 | 17 | ./tests/Unit 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guojiangclub/laravel-wechat-platform/f364e89bd69881ca6aabc3d4bd19e78856a364ac/public/favicon.ico -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /resources/assets/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | window.Vue = require('vue'); 11 | 12 | /** 13 | * Next, we will create a fresh Vue application instance and attach it to 14 | * the page. Then, you may begin adding components to this application 15 | * or customize the JavaScript scaffolding to fit your unique needs. 16 | */ 17 | 18 | Vue.component('example-component', require('./components/ExampleComponent.vue')); 19 | 20 | const app = new Vue({ 21 | el: '#app' 22 | }); 23 | -------------------------------------------------------------------------------- /resources/assets/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | try { 11 | window.$ = window.jQuery = require('jquery'); 12 | 13 | require('bootstrap-sass'); 14 | } catch (e) {} 15 | 16 | /** 17 | * We'll load the axios HTTP library which allows us to easily issue requests 18 | * to our Laravel back-end. This library automatically handles sending the 19 | * CSRF token as a header based on the value of the "XSRF" token cookie. 20 | */ 21 | 22 | window.axios = require('axios'); 23 | 24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 25 | 26 | /** 27 | * Next we will register the CSRF Token as a common header with Axios so that 28 | * all outgoing HTTP requests automatically have it attached. This is just 29 | * a simple convenience so we don't have to attach every token manually. 30 | */ 31 | 32 | let token = document.head.querySelector('meta[name="csrf-token"]'); 33 | 34 | if (token) { 35 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 36 | } else { 37 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 38 | } 39 | 40 | /** 41 | * Echo exposes an expressive API for subscribing to channels and listening 42 | * for events that are broadcast by Laravel. Echo and event broadcasting 43 | * allows your team to easily build robust real-time web applications. 44 | */ 45 | 46 | // import Echo from 'laravel-echo' 47 | 48 | // window.Pusher = require('pusher-js'); 49 | 50 | // window.Echo = new Echo({ 51 | // broadcaster: 'pusher', 52 | // key: 'your-pusher-key', 53 | // cluster: 'mt1', 54 | // encrypted: true 55 | // }); 56 | -------------------------------------------------------------------------------- /resources/assets/js/components/ExampleComponent.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /resources/assets/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f5f8fa; 4 | 5 | // Borders 6 | $laravel-border-color: darken($body-bg, 10%); 7 | $list-group-border: $laravel-border-color; 8 | $navbar-default-border: $laravel-border-color; 9 | $panel-default-border: $laravel-border-color; 10 | $panel-inner-border: $laravel-border-color; 11 | 12 | // Brands 13 | $brand-primary: #3097D1; 14 | $brand-info: #8eb4cb; 15 | $brand-success: #2ab27b; 16 | $brand-warning: #cbb956; 17 | $brand-danger: #bf5329; 18 | 19 | // Typography 20 | $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/"; 21 | $font-family-sans-serif: "Raleway", sans-serif; 22 | $font-size-base: 14px; 23 | $line-height-base: 1.6; 24 | $text-color: #636b6f; 25 | 26 | // Navbar 27 | $navbar-default-bg: #fff; 28 | 29 | // Buttons 30 | $btn-default-color: $text-color; 31 | 32 | // Inputs 33 | $input-border: lighten($text-color, 40%); 34 | $input-border-focus: lighten($brand-primary, 25%); 35 | $input-color-placeholder: lighten($text-color, 30%); 36 | 37 | // Panels 38 | $panel-default-heading-bg: #fff; 39 | -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | 2 | // Fonts 3 | @import url("https://fonts.googleapis.com/css?family=Raleway:300,400,600"); 4 | 5 | // Variables 6 | @import "variables"; 7 | 8 | // Bootstrap 9 | @import "~bootstrap-sass/assets/stylesheets/bootstrap"; 10 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Laravel 9 | 10 | 11 | 12 | 13 | 14 | 66 | 67 | 68 |
69 | @if (Route::has('login')) 70 | 78 | @endif 79 | 80 |
81 |
82 | Laravel 83 |
84 | 85 | 92 |
93 |
94 | 95 | 96 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 17 | return $request->user(); 18 | }); 19 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 20 | 21 | Hash::setRounds(4); 22 | 23 | return $app; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/assets/js/app.js', 'public/js') 15 | .sass('resources/assets/sass/app.scss', 'public/css'); 16 | --------------------------------------------------------------------------------