├── public ├── favicon.ico ├── robots.txt ├── images │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── contact.jpeg │ ├── poster │ │ ├── top.png │ │ ├── bottom.png │ │ └── middle.png │ ├── version_1 │ │ ├── -.png │ │ ├── kick.png │ │ ├── open.png │ │ ├── active.png │ │ ├── back2.png │ │ ├── click.png │ │ ├── close.png │ │ ├── invite.png │ │ ├── share.png │ │ ├── spent.png │ │ ├── tudaren.png │ │ ├── unpaid.png │ │ ├── headbackg.png │ │ ├── index-off.png │ │ ├── index-on.png │ │ ├── kongbaiye.png │ │ ├── minebackg.png │ │ ├── question.png │ │ ├── selected.png │ │ ├── unretrive.png │ │ ├── kongbaiye1.png │ │ ├── poster-save.png │ │ ├── poster-share.png │ │ ├── shouyebackg.png │ │ ├── 404-portrait.jpeg │ │ ├── more_selected.png │ │ ├── xiaochengxuma.png │ │ ├── zijidezhangdan.png │ │ ├── create_activity.png │ │ ├── more_unselected.png │ │ ├── tongyoufenzhang.png │ │ ├── zhangdan_selected.png │ │ └── zhangdan_unselected.png │ ├── weapp_qrcode.jpg │ └── receive_money.jpeg ├── fonts │ └── PingFang-Bold.ttf ├── .htaccess ├── web.config ├── index.php └── svg │ ├── 404.svg │ ├── 503.svg │ └── 403.svg ├── database ├── .gitignore ├── seeds │ └── DatabaseSeeder.php ├── migrations │ ├── 2019_03_16_133503_add_user_id_to_table_bills.php │ ├── 2019_03_19_144118_add_wx_a_code_to_table_activities.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2019_04_02_074642_change_money_format_in_table_bills.php │ ├── 2019_03_16_054538_create_activities_table.php │ ├── 2019_04_05_053953_create_q_as_table.php │ ├── 2019_04_02_075442_change_money_format_in_table_bill_items.php │ ├── 2019_04_02_075302_change_split_money_format_in_table_bill_participants.php │ ├── 2019_07_27_142944_add_wxpay_and_alipay_to_table_users.php │ ├── 2019_03_16_080225_create_bill_items_table.php │ ├── 2019_03_16_054624_create_activity_participants_table.php │ ├── 2019_03_09_143047_add_weixin_session_key_to_users_table.php │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2019_03_16_054639_create_bills_table.php │ ├── 2019_03_16_054712_create_bill_participants_table.php │ └── 2019_03_09_144444_add_weixin_fields_to_users_table.php └── factories │ └── UserFactory.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── .gitattributes ├── app ├── Models │ ├── BillItem.php │ ├── QA.php │ ├── ActivityParticipant.php │ ├── BillParticipant.php │ ├── Model.php │ ├── Bill.php │ ├── Activity.php │ └── User.php ├── Http │ ├── Controllers │ │ ├── Api │ │ │ ├── Controller.php │ │ │ ├── QAsController.php │ │ │ ├── UsersController.php │ │ │ ├── PdfController.php │ │ │ ├── AuthorizationsController.php │ │ │ └── ActivitiesController.php │ │ └── Controller.php │ ├── Requests │ │ ├── Request.php │ │ └── Api │ │ │ ├── FormRequest.php │ │ │ ├── Activities │ │ │ └── SaveRequest.php │ │ │ ├── WeappAuthorizationRequest.php │ │ │ └── Bills │ │ │ └── SaveRequest.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ ├── Authenticate.php │ │ ├── VerifyCsrfToken.php │ │ ├── ChangeLocale.php │ │ └── RedirectIfAuthenticated.php │ └── Kernel.php ├── Policies │ ├── Policy.php │ └── BillPolicy.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── RouteServiceProvider.php │ └── AppServiceProvider.php ├── Transformers │ ├── QATransformer.php │ ├── UserTransformer.php │ ├── BillItemTransformer.php │ ├── BillParticipantTransformer.php │ ├── ActivityTransformer.php │ └── BillTransformer.php ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php └── Handlers │ └── ImageUploadHandler.php ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── Feature │ └── ExampleTest.php └── CreatesApplication.php ├── .gitignore ├── .editorconfig ├── resources ├── sass │ ├── app.scss │ └── _variables.scss ├── lang │ └── en │ │ ├── pagination.php │ │ ├── auth.php │ │ ├── passwords.php │ │ └── validation.php ├── js │ ├── components │ │ └── ExampleComponent.vue │ ├── app.js │ └── bootstrap.js └── views │ ├── welcome.blade.php │ └── pdf.blade.php ├── routes ├── web.php ├── channels.php ├── console.php └── api.php ├── webpack.mix.js ├── server.php ├── readme.md ├── package.json ├── .env.example ├── config ├── view.php ├── services.php ├── snappy.php ├── hashing.php ├── broadcasting.php ├── filesystems.php ├── logging.php ├── queue.php ├── cache.php ├── auth.php ├── wechat.php ├── mail.php ├── database.php ├── session.php ├── api.php └── app.php ├── phpunit.xml ├── artisan └── composer.json /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /public/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/1.png -------------------------------------------------------------------------------- /public/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/2.png -------------------------------------------------------------------------------- /public/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/3.png -------------------------------------------------------------------------------- /public/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/4.png -------------------------------------------------------------------------------- /public/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/5.png -------------------------------------------------------------------------------- /public/images/contact.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/contact.jpeg -------------------------------------------------------------------------------- /public/fonts/PingFang-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/fonts/PingFang-Bold.ttf -------------------------------------------------------------------------------- /public/images/poster/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/poster/top.png -------------------------------------------------------------------------------- /public/images/version_1/-.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/-.png -------------------------------------------------------------------------------- /public/images/weapp_qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/weapp_qrcode.jpg -------------------------------------------------------------------------------- /public/images/poster/bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/poster/bottom.png -------------------------------------------------------------------------------- /public/images/poster/middle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/poster/middle.png -------------------------------------------------------------------------------- /public/images/receive_money.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/receive_money.jpeg -------------------------------------------------------------------------------- /public/images/version_1/kick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/kick.png -------------------------------------------------------------------------------- /public/images/version_1/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/open.png -------------------------------------------------------------------------------- /public/images/version_1/active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/active.png -------------------------------------------------------------------------------- /public/images/version_1/back2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/back2.png -------------------------------------------------------------------------------- /public/images/version_1/click.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/click.png -------------------------------------------------------------------------------- /public/images/version_1/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/close.png -------------------------------------------------------------------------------- /public/images/version_1/invite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/invite.png -------------------------------------------------------------------------------- /public/images/version_1/share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/share.png -------------------------------------------------------------------------------- /public/images/version_1/spent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/spent.png -------------------------------------------------------------------------------- /public/images/version_1/tudaren.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/tudaren.png -------------------------------------------------------------------------------- /public/images/version_1/unpaid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/unpaid.png -------------------------------------------------------------------------------- /public/images/version_1/headbackg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/headbackg.png -------------------------------------------------------------------------------- /public/images/version_1/index-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/index-off.png -------------------------------------------------------------------------------- /public/images/version_1/index-on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/index-on.png -------------------------------------------------------------------------------- /public/images/version_1/kongbaiye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/kongbaiye.png -------------------------------------------------------------------------------- /public/images/version_1/minebackg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/minebackg.png -------------------------------------------------------------------------------- /public/images/version_1/question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/question.png -------------------------------------------------------------------------------- /public/images/version_1/selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/selected.png -------------------------------------------------------------------------------- /public/images/version_1/unretrive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/unretrive.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /public/images/version_1/kongbaiye1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/kongbaiye1.png -------------------------------------------------------------------------------- /public/images/version_1/poster-save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/poster-save.png -------------------------------------------------------------------------------- /public/images/version_1/poster-share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/poster-share.png -------------------------------------------------------------------------------- /public/images/version_1/shouyebackg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/shouyebackg.png -------------------------------------------------------------------------------- /public/images/version_1/404-portrait.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/404-portrait.jpeg -------------------------------------------------------------------------------- /public/images/version_1/more_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/more_selected.png -------------------------------------------------------------------------------- /public/images/version_1/xiaochengxuma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/xiaochengxuma.png -------------------------------------------------------------------------------- /public/images/version_1/zijidezhangdan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/zijidezhangdan.png -------------------------------------------------------------------------------- /public/images/version_1/create_activity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/create_activity.png -------------------------------------------------------------------------------- /public/images/version_1/more_unselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/more_unselected.png -------------------------------------------------------------------------------- /public/images/version_1/tongyoufenzhang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/tongyoufenzhang.png -------------------------------------------------------------------------------- /public/images/version_1/zhangdan_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/zhangdan_selected.png -------------------------------------------------------------------------------- /public/images/version_1/zhangdan_unselected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foolstack-omg/laravel-bill-split/HEAD/public/images/version_1/zhangdan_unselected.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Models/BillItem.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | /.idea 7 | /.vscode 8 | /nbproject 9 | /.vagrant 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | .env 15 | .phpunit.result.cache 16 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.yml] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/Controller.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/Models/Model.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/Http/Requests/Api/FormRequest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Policies/BillPolicy.php: -------------------------------------------------------------------------------- 1 | isAuthorOf($bill); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /resources/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f8fafc; 4 | 5 | // Typography 6 | $font-family-sans-serif: "Nunito", sans-serif; 7 | $font-size-base: 0.9rem; 8 | $line-height-base: 1.6; 9 | 10 | // Colors 11 | $blue: #3490dc; 12 | $indigo: #6574cd; 13 | $purple: #9561e2; 14 | $pink: #f66D9b; 15 | $red: #e3342f; 16 | $orange: #f6993f; 17 | $yellow: #ffed4a; 18 | $green: #38c172; 19 | $teal: #4dc0b5; 20 | $cyan: #6cb2eb; 21 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/QAsController.php: -------------------------------------------------------------------------------- 1 | response()->collection(QA::all(), new QATransformer()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | $qa->question, 20 | 'answer' => $qa->answer 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Requests/Api/Activities/SaveRequest.php: -------------------------------------------------------------------------------- 1 | 'int', 19 | 'name' => 'required|string|between:1,20', 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Models/Bill.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 9 | } 10 | 11 | public function items() { 12 | return $this->hasMany(BillItem::class); 13 | } 14 | 15 | public function participants() { 16 | return $this->hasMany(BillParticipant::class); 17 | } 18 | 19 | public function activity() { 20 | return $this->belongsTo(Activity::class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | header('accept-language'); 19 | if ($language) { 20 | \App::setLocale($language); 21 | } 22 | 23 | return $next($request); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const 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/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /server.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 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/home'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Transformers/UserTransformer.php: -------------------------------------------------------------------------------- 1 | $user->id, 14 | 'name' => $user->name, 15 | 'avatar_url' => $user->avatar_url, 16 | 'wxpay' => $user->wxpay, 17 | 'alipay' => $user->alipay, 18 | 'created_at' => $user->created_at->toDateTimeString(), 19 | 'updated_at' => $user->updated_at->toDateTimeString(), 20 | ]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/js/components/ExampleComponent.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 24 | -------------------------------------------------------------------------------- /app/Transformers/BillItemTransformer.php: -------------------------------------------------------------------------------- 1 | $item->id, 22 | 'bill_id' => $item->bill_id, 23 | 'title' => $item->title, 24 | 'money' => $item->money, 25 | ]; 26 | 27 | return $data; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Http/Requests/Api/WeappAuthorizationRequest.php: -------------------------------------------------------------------------------- 1 | 'required|string', 16 | 'name' => 'required|string', 17 | 'avatar_url' => 'present|string|nullable', 18 | 'gender' => 'present|int', 19 | 'city' => 'present|string|nullable', 20 | 'province' => 'present|string|nullable', 21 | 'country' => 'present|string|nullable' 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | \App\Policies\BillPolicy::class, 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 | -------------------------------------------------------------------------------- /database/migrations/2019_03_16_133503_add_user_id_to_table_bills.php: -------------------------------------------------------------------------------- 1 | unsignedInteger('user_id')->index()->comment('创建人ID')->after('id'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('bills', function (Blueprint $table) { 29 | $table->dropColumn('user_id'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2019_03_19_144118_add_wx_a_code_to_table_activities.php: -------------------------------------------------------------------------------- 1 | text('wx_a_code')->comment('微信小程序码图片地址'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('activities', function (Blueprint $table) { 29 | $table->dropColumn('wx_a_code'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Models\User::class, function (Faker $faker) { 17 | return [ 18 | 'name' => $faker->name, 19 | 'email' => $faker->unique()->safeEmail, 20 | 'email_verified_at' => now(), 21 | 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 22 | 'remember_token' => str_random(10), 23 | ]; 24 | }); 25 | -------------------------------------------------------------------------------- /database/migrations/2019_04_02_074642_change_money_format_in_table_bills.php: -------------------------------------------------------------------------------- 1 | unsignedDecimal('money', 12, 2)->comment('账单金额')->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('bills', function (Blueprint $table) { 29 | $table->unsignedDecimal('money', 10, 2)->comment('账单金额')->change(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2019_03_16_054538_create_activities_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->unsignedInteger('user_id')->index()->comment('用户ID'); 19 | $table->string('name')->comment('活动名称'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('activities'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2019_04_05_053953_create_q_as_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('question')->comment('问题'); 19 | $table->text('answer')->comment('回答'); 20 | $table->timestamps(); 21 | }); 22 | 23 | DB::statement("ALTER TABLE `q_as` COMMENT 'Q&A'"); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('q_as'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2019_04_02_075442_change_money_format_in_table_bill_items.php: -------------------------------------------------------------------------------- 1 | unsignedDecimal('money', 12, 2)->default(0)->comment('账单金额')->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('bill_items', function (Blueprint $table) { 29 | $table->unsignedDecimal('money', 10, 2)->default(0)->comment('账单金额')->change(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2019_04_02_075302_change_split_money_format_in_table_bill_participants.php: -------------------------------------------------------------------------------- 1 | decimal('split_money', 12, 2)->comment('分摊金额')->change(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('bill_participants', function (Blueprint $table) { 29 | $table->decimal('split_money', 10, 2)->comment('分摊金额')->change(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2019_07_27_142944_add_wxpay_and_alipay_to_table_users.php: -------------------------------------------------------------------------------- 1 | string('wxpay')->default('')->comment('微信支付二维码'); 18 | $table->string('alipay')->default('')->comment('支付宝支付二维码'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::table('users', function (Blueprint $table) { 30 | $table->dropColumn('wxpay'); 31 | $table->dropColumn('alipay'); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2019_03_16_080225_create_bill_items_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->unsignedInteger('bill_id')->index()->comment('账单ID'); 19 | $table->string('title')->comment('账单名称'); 20 | $table->unsignedDecimal('money', 10, 2)->default(0)->comment('账单金额'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('bill_items'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## 同游分账 - 服务器端 2 | 3 | 基于Laravel5.7 - Dingo Api - Jwt 开发的微信小程序服务器端接口程序 4 | 5 | - [小程序客户端项目链接](https://github.com/654943305/bill-split-weapp) 6 | 7 | ## 功能点 8 | - 微信小程序服务器端接口使用 9 | - Dingo Api和Jwt的使用 10 | - 使用Policy实现权限控制 11 | - 使用Transformer控制Api返回结果 12 | 13 | ## 项目部署 14 | 15 | 1. `composer install` 16 | 2. `cp .env.example .env` 17 | 3. `php artisan key:generate` 18 | 4. `php artisan jwt:secret` 19 | 5. 配置 `.env` 文件中的微信小程序配置项以及数据库配置 20 | 6. 执行 `php artisan migrate` 21 | 7. `php artisan storage:link` 22 | 23 | ## 小程序码 24 | 25 | 26 | 27 | 28 | 29 | ## 支持一下 30 | 31 | 您的支持是我前进最大的动力 32 | 33 | 34 | 35 | 36 | 37 | ## 项目成员 38 | 39 | - 技术 (刘晓峰 Stefan) 40 | - UI设计 (优雅de兔子君)[设计师作品集](https://mrbunny.zcool.com.cn) 41 | 42 | ## 联系我们 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/migrations/2019_03_16_054624_create_activity_participants_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->unsignedInteger('activity_id')->comment('活动ID'); 19 | $table->unsignedInteger('user_id')->index()->comment('用户ID'); 20 | $table->unique(['user_id', 'activity_id']); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::dropIfExists('activity_participants'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2019_03_09_143047_add_weixin_session_key_to_users_table.php: -------------------------------------------------------------------------------- 1 | string('weapp_openid')->nullable()->unique()->after('remember_token'); 18 | $table->string('weixin_session_key')->nullable()->after('weapp_openid'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::table('users', function (Blueprint $table) { 30 | $table->dropColumn('weapp_openid'); 31 | $table->dropColumn('weixin_session_key'); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique()->nullable()->default(null); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password')->nullable()->default(null); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2019_03_16_054639_create_bills_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->unsignedInteger('activity_id')->index()->comment('活动ID'); 19 | $table->string('title')->comment('标题'); 20 | $table->string('description')->default('')->comment('账单描述'); 21 | $table->unsignedDecimal('money', 10, 2)->comment('账单金额'); 22 | 23 | 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('bills'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/Models/Activity.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 12 | } 13 | 14 | public function participatedUsers() { 15 | return $this->belongsToMany(User::class, 'activity_participants', 'activity_id', 'user_id') 16 | ->withTimestamps(); 17 | } 18 | 19 | public function bills() { 20 | return $this->hasMany(Bill::class); 21 | } 22 | 23 | public function getWxACodeAttribute(){ 24 | if($this->attributes['wx_a_code']){ 25 | // 如果 image 字段本身就已经是完整的 url 就直接返回 26 | if (Str::startsWith($this->attributes['wx_a_code'], ['http://', 'https://'])) { 27 | return $this->attributes['wx_a_code']; 28 | } 29 | return \Storage::disk('public')->url($this->attributes['wx_a_code']); 30 | }else{ 31 | return $this->attributes['wx_a_code']; 32 | } 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/Transformers/BillParticipantTransformer.php: -------------------------------------------------------------------------------- 1 | $model->id, 27 | 'bill_id' => $model->bill_id, 28 | 'user_id' => $model->user_id, 29 | 'split_money' => $model->split_money, 30 | 'fixed' => $model->fixed, 31 | 'paid' => $model->paid 32 | ]; 33 | 34 | return $data; 35 | } 36 | 37 | public function includeUser(BillParticipant $model) { 38 | return $this->item($model->user, new UserTransformer()); 39 | } 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /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": "npm run development -- --watch", 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.18", 14 | "bootstrap": "^4.0.0", 15 | "cross-env": "^5.1", 16 | "jquery": "^3.2", 17 | "laravel-mix": "^2.0", 18 | "lodash": "^4.17.5", 19 | "popper.js": "^1.12", 20 | "vue": "^2.5.17" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | 9 | DB_CONNECTION=mysql 10 | DB_HOST=127.0.0.1 11 | DB_PORT=3306 12 | DB_DATABASE=homestead 13 | DB_USERNAME=homestead 14 | DB_PASSWORD=secret 15 | 16 | BROADCAST_DRIVER=log 17 | CACHE_DRIVER=file 18 | QUEUE_CONNECTION=sync 19 | SESSION_DRIVER=file 20 | SESSION_LIFETIME=120 21 | 22 | REDIS_HOST=127.0.0.1 23 | REDIS_PASSWORD=null 24 | REDIS_PORT=6379 25 | 26 | MAIL_DRIVER=smtp 27 | MAIL_HOST=smtp.mailtrap.io 28 | MAIL_PORT=2525 29 | MAIL_USERNAME=null 30 | MAIL_PASSWORD=null 31 | MAIL_ENCRYPTION=null 32 | 33 | PUSHER_APP_ID= 34 | PUSHER_APP_KEY= 35 | PUSHER_APP_SECRET= 36 | PUSHER_APP_CLUSTER=mt1 37 | 38 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 39 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 40 | 41 | JWT_SECRET= 42 | JWT_TTL=3600 43 | 44 | API_STANDARDS_TREE=prs 45 | API_SUBTYPE=bill-split 46 | API_PREFIX=api 47 | API_VERSION=v1 48 | API_DEBUG=true 49 | 50 | WECHAT_MINI_PROGRAM_APPID= 51 | WECHAT_MINI_PROGRAM_SECRET= 52 | WECHAT_MINI_PROGRAM_TOKEN= 53 | WECHAT_MINI_PROGRAM_AES_KEY= 54 | -------------------------------------------------------------------------------- /app/Http/Requests/Api/Bills/SaveRequest.php: -------------------------------------------------------------------------------- 1 | 'string|nullable', 20 | 'description' => 'string|nullable', 21 | 'money' => 'required|numeric|min:0', 22 | 'participants.data' => 'array', 23 | 'participants.data.*.user_id' => 'required|int', 24 | 'participants.data.*.split_money' => 'required|numeric', 25 | 'participants.data.*.fixed' => 'required|boolean', 26 | 'participants.data.*.paid' => 'required|boolean', 27 | 'items.data' => 'array', 28 | 'items.data.*.id' => 'int|nullable', 29 | 'items.data.*.title' => 'required|string', 30 | 'items.data.*.money' => 'required|numeric|min:0', 31 | 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /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/migrations/2019_03_16_054712_create_bill_participants_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->unsignedInteger('bill_id')->index()->comment('账单ID'); 19 | $table->unsignedInteger('user_id')->index()->comment('用户ID'); 20 | $table->unique(['bill_id', 'user_id']); 21 | $table->decimal('split_money', 10, 2)->comment('分摊金额'); 22 | $table->boolean('fixed')->default(0)->comment('是否固定金额'); 23 | $table->boolean('paid')->default(0)->comment('是否已支付'); 24 | 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('bill_participants'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /resources/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 | * The following block of code may be used to automatically register your 14 | * Vue components. It will recursively scan this directory for the Vue 15 | * components and automatically register them with their "basename". 16 | * 17 | * Eg. ./components/ExampleComponent.vue -> 18 | */ 19 | 20 | Vue.component('example-component', require('./components/ExampleComponent.vue')); 21 | 22 | // const files = require.context('./', true, /\.vue$/i) 23 | 24 | // files.keys().map(key => { 25 | // return Vue.component(_.last(key.split('/')).split('.')[0], files(key)) 26 | // }) 27 | 28 | /** 29 | * Next, we will create a fresh Vue application instance and attach it to 30 | * the page. Then, you may begin adding components to this application 31 | * or customize the JavaScript scaffolding to fit your unique needs. 32 | */ 33 | 34 | const app = new Vue({ 35 | el: '#app' 36 | }); 37 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | ./tests/Feature 18 | 19 | 20 | 21 | 22 | ./app 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | $activity->id, 24 | 'user_id' => $activity->user_id, 25 | 'created_at' => $activity->created_at->format('Y/m/d'), 26 | 'name' => $activity->name, 27 | 'wx_a_code' => $activity->wx_a_code, 28 | 'split_sum' => $activity->split_sum ?? null, 29 | 'unpaid_sum' => $activity->unpaid_sum ?? null, 30 | 'all_unpaid_sum' => $activity->all_unpaid_sum ?? null, 31 | ]; 32 | } 33 | 34 | public function includeUser(Activity $activity) { 35 | return $this->item($activity->user, new UserTransformer()); 36 | } 37 | 38 | public function includeParticipatedUsers(Activity $activity) 39 | { 40 | return $this->collection($activity->participatedUsers()->orderBy('created_at','desc')->get(), new UserTransformer()); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | ], 22 | 23 | 'ses' => [ 24 | 'key' => env('SES_KEY'), 25 | 'secret' => env('SES_SECRET'), 26 | 'region' => env('SES_REGION', 'us-east-1'), 27 | ], 28 | 29 | 'sparkpost' => [ 30 | 'secret' => env('SPARKPOST_SECRET'), 31 | ], 32 | 33 | 'stripe' => [ 34 | 'model' => App\Models\User::class, 35 | 'key' => env('STRIPE_KEY'), 36 | 'secret' => env('STRIPE_SECRET'), 37 | 'webhook' => [ 38 | 'secret' => env('STRIPE_WEBHOOK_SECRET'), 39 | 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300), 40 | ], 41 | ], 42 | 43 | ]; 44 | -------------------------------------------------------------------------------- /database/migrations/2019_03_09_144444_add_weixin_fields_to_users_table.php: -------------------------------------------------------------------------------- 1 | string('avatar_url')->comment('用户头像')->after('remember_token'); 18 | $table->tinyInteger('gender')->default(0)->comment('用户的性别,值为1时是男性,值为2时是女性,值为0时是未知')->after('avatar_url'); 19 | $table->string('city')->comment('用户所在城市')->default('')->after('gender'); 20 | $table->string('province')->comment('用户所在省份')->default('')->after('city'); 21 | $table->string('country')->comment('用户所在国家')->default('')->after('province'); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::table('users', function (Blueprint $table) { 33 | $table->dropColumn('avatar_url'); 34 | $table->dropColumn('gender'); 35 | $table->dropColumn('city'); 36 | $table->dropColumn('province'); 37 | $table->dropColumn('country'); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | getKey(); 18 | } 19 | 20 | public function getJWTCustomClaims() 21 | { 22 | return []; 23 | } 24 | 25 | /** 26 | * The attributes that are mass assignable. 27 | * 28 | * @var array 29 | */ 30 | protected $fillable = [ 31 | 'name', 'email', 'password', 'gender', 'avatar_url', 'province', 'city', 'country', 32 | 'weixin_session_key', 'weapp_openid' 33 | ]; 34 | 35 | /** 36 | * The attributes that should be hidden for arrays. 37 | * 38 | * @var array 39 | */ 40 | protected $hidden = [ 41 | 'password', 'remember_token', 42 | ]; 43 | 44 | public function activities() { 45 | return $this->hasMany(Activity::class); 46 | } 47 | 48 | public function participatedActivities() { 49 | return $this->belongsToMany(Activity::class, 'activity_participants', 'user_id', 'activity_id') 50 | ->withTimestamps(); 51 | } 52 | 53 | public function isAuthorOf($model) 54 | { 55 | return $this->id == $model->user_id; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /config/snappy.php: -------------------------------------------------------------------------------- 1 | [ 37 | 'enabled' => true, 38 | 'binary' => env('WKHTML_PDF_BINARY', 'vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'), 39 | 'timeout' => false, 40 | 'options' => [], 41 | 'env' => [], 42 | ], 43 | 44 | 'image' => [ 45 | 'enabled' => true, 46 | 'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'), 47 | 'timeout' => false, 48 | 'options' => [], 49 | 'env' => [], 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /app/Transformers/BillTransformer.php: -------------------------------------------------------------------------------- 1 | $bill->id, 25 | 'user_id' => $bill->user_id, 26 | 'created_at' => $bill->created_at->format('Y/m/d H:i'), 27 | 'activity_id' => $bill->activity_id, 28 | 'title' => $bill->title, 29 | 'description' => $bill->description, 30 | 'money' => $bill->money, 31 | ]; 32 | if(isset($bill->split_money)){ 33 | $data['split_money'] = $bill->split_money; 34 | } 35 | if(isset($bill->unpaid_money)){ 36 | $data['unpaid_money'] = $bill->unpaid_money; 37 | } 38 | if(isset($bill->all_unpaid_money)){ 39 | $data['all_unpaid_money'] = $bill->all_unpaid_money; 40 | } 41 | return $data; 42 | } 43 | 44 | public function includeUser(Bill $bill) { 45 | return $this->item($bill->user, new UserTransformer()); 46 | } 47 | 48 | public function includeItems(Bill $bill) { 49 | return $this->collection($bill->items, new BillItemTransformer()); 50 | } 51 | 52 | public function includeParticipants(Bill $bill) { 53 | return $this->collection($bill->participants()->orderBy('id', 'desc')->get(), new BillParticipantTransformer()); 54 | } 55 | 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 1024, 48 | 'threads' => 2, 49 | 'time' => 2, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 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 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | fullUrl().' ==============='); 20 | 21 | DB::listen(function (QueryExecuted $query) { 22 | $sqlWithPlaceholders = str_replace(['%', '?'], ['%%', '%s'], $query->sql); 23 | 24 | $bindings = $query->connection->prepareBindings($query->bindings); 25 | $pdo = $query->connection->getPdo(); 26 | $realSql = vsprintf($sqlWithPlaceholders, array_map([$pdo, 'quote'], $bindings)); 27 | $duration = $this->formatDuration($query->time / 1000); 28 | 29 | Log::debug(sprintf('[%s] %s', $duration, $realSql)); 30 | }); 31 | 32 | \Schema::defaultStringLength(191); 33 | } 34 | 35 | /** 36 | * Register any application services. 37 | * 38 | * @return void 39 | */ 40 | public function register() 41 | { 42 | if ($this->app->environment() !== 'production') { 43 | $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class); 44 | } 45 | } 46 | 47 | /** 48 | * Format duration. 49 | * 50 | * @param float $seconds 51 | * 52 | * @return string 53 | */ 54 | private function formatDuration($seconds) 55 | { 56 | if ($seconds < 0.001) { 57 | return round($seconds * 1000000) . 'μs'; 58 | } elseif ($seconds < 1) { 59 | return round($seconds * 1000, 2) . 'ms'; 60 | } 61 | 62 | return round($seconds, 2) . 's'; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /resources/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.Popper = require('popper.js').default; 12 | window.$ = window.jQuery = require('jquery'); 13 | 14 | require('bootstrap'); 15 | } catch (e) {} 16 | 17 | /** 18 | * We'll load the axios HTTP library which allows us to easily issue requests 19 | * to our Laravel back-end. This library automatically handles sending the 20 | * CSRF token as a header based on the value of the "XSRF" token cookie. 21 | */ 22 | 23 | window.axios = require('axios'); 24 | 25 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 26 | 27 | /** 28 | * Next we will register the CSRF Token as a common header with Axios so that 29 | * all outgoing HTTP requests automatically have it attached. This is just 30 | * a simple convenience so we don't have to attach every token manually. 31 | */ 32 | 33 | let token = document.head.querySelector('meta[name="csrf-token"]'); 34 | 35 | if (token) { 36 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 37 | } else { 38 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 39 | } 40 | 41 | /** 42 | * Echo exposes an expressive API for subscribing to channels and listening 43 | * for events that are broadcast by Laravel. Echo and event broadcasting 44 | * allows your team to easily build robust real-time web applications. 45 | */ 46 | 47 | // import Echo from 'laravel-echo' 48 | 49 | // window.Pusher = require('pusher-js'); 50 | 51 | // window.Echo = new Echo({ 52 | // broadcaster: 'pusher', 53 | // key: process.env.MIX_PUSHER_APP_KEY, 54 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 55 | // encrypted: true 56 | // }); 57 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Handlers/ImageUploadHandler.php: -------------------------------------------------------------------------------- 1 | path('') . '/' . $folder_name; 20 | 21 | // 获取文件的后缀名,因图片从剪贴板里黏贴时后缀名为空,所以此处确保后缀一直存在 22 | $extension = strtolower($file->getClientOriginalExtension()) ?: 'png'; 23 | 24 | // 拼接文件名,加前缀是为了增加辨析度,前缀可以是相关数据模型的 ID 25 | // 值如:1_1493521050_7BVc9v9ujP.png 26 | $filename = $file_prefix . '_' . time() . '_' . str_random(10) . '.' . $extension; 27 | 28 | // 如果上传的不是图片将终止操作 29 | if ( ! in_array($extension, $this->allowed_ext)) { 30 | return false; 31 | } 32 | 33 | // 将图片移动到我们的目标存储路径中 34 | $file->move($upload_path, $filename); 35 | 36 | // 如果限制了图片宽度,就进行裁剪 37 | if ($max_width && $extension != 'gif') { 38 | 39 | // 此类中封装的函数,用于裁剪图片 40 | $this->reduceSize($upload_path . '/' . $filename, $max_width); 41 | } 42 | 43 | return [ 44 | 'path' => \Storage::disk('public')->url("/$folder_name/$filename") 45 | ]; 46 | } 47 | 48 | public function reduceSize($file_path, $max_width) 49 | { 50 | // 先实例化,传参是文件的磁盘物理路径 51 | $image = Image::make($file_path); 52 | 53 | // 进行大小调整的操作 54 | $image->resize($max_width, null, function ($constraint) { 55 | 56 | // 设定宽度是 $max_width,高度等比例双方缩放 57 | $constraint->aspectRatio(); 58 | 59 | // 防止裁图时图片尺寸变大 60 | $constraint->upsize(); 61 | }); 62 | 63 | // 对图片修改后进行保存 64 | $image->save(null, 60); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/UsersController.php: -------------------------------------------------------------------------------- 1 | response->item($this->user(), new UserTransformer()); 21 | } 22 | 23 | public function storeImages(Request $request, ImageUploadHandler $uploader) 24 | { 25 | $types = ['wxpay', 'alipay']; 26 | 27 | if(!in_array($request->type, $types)) { 28 | return $this->response->error('不支持的支付类型', 500); 29 | } 30 | 31 | $user = $this->user(); 32 | 33 | $size = 350; 34 | $result = $uploader->save($request->image, str_plural($request->type), $user->id, $size); 35 | 36 | switch ($request->type) { 37 | case 'wxpay': 38 | $user->wxpay = $result['path']; 39 | break; 40 | case 'alipay': 41 | $user->alipay = $result['path']; 42 | break; 43 | default: 44 | return $this->response->error('不支持的支付类型', 500); 45 | } 46 | $user->save(); 47 | 48 | return $this->response->item($user, new UserTransformer())->setStatusCode(201); 49 | } 50 | 51 | public function deleteImages(Request $request) { 52 | $user = $this->user(); 53 | $types = ['wxpay', 'alipay']; 54 | 55 | if(!in_array($request->type, $types)) { 56 | return $this->response->error('不支持的支付类型', 500); 57 | } 58 | switch ($request->type) { 59 | case 'wxpay': 60 | $user->wxpay = ''; 61 | break; 62 | case 'alipay': 63 | $user->alipay = ''; 64 | break; 65 | default: 66 | return $this->response->error('不支持的支付类型', 500); 67 | } 68 | 69 | $user->save(); 70 | 71 | return $this->response->item($user, new UserTransformer())->setStatusCode(201); 72 | 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/PdfController.php: -------------------------------------------------------------------------------- 1 | input('data')), true); 20 | 21 | // $data = [ 22 | // 'title' => '世茂广场', 23 | // 'subtitle' => '上画监测报告', 24 | // 'ads' => [ 25 | // [ 26 | // 'images' => ['https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3039140561,11452166&fm=26&gp=0.jpg', 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3039140561,11452166&fm=26&gp=0.jpg'], 27 | // 'position1' => '建南路', 28 | // 'position2' => '宁宝花园西门站(东)', 29 | // 'code' => 'hct179' 30 | // ], 31 | // [ 32 | // 'images' => ['https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3039140561,11452166&fm=26&gp=0.jpg', 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3039140561,11452166&fm=26&gp=0.jpg'], 33 | // 'position1' => '石鼓路', 34 | // 'position2' => '银亭社区站', 35 | // 'code' => 'hct285' 36 | // ] 37 | // ] 38 | // ]; 39 | 40 | $pdf = PDF::loadView('pdf', ['data' => $data])->setOptions([ 41 | // 'orientation' => 'Landscape', 42 | 'margin-bottom' => 0, 43 | 'margin-left' => 0, 44 | 'margin-right' => 0, 45 | 'margin-top' => 0,//210 x 297 46 | 'page-height' => 152, 47 | 'page-width' => 273, 48 | 'disable-smart-shrinking' => true 49 | ]); //pdf.invoice是你的blade模板 50 | $pdf->snappy()->setTimeout(600); 51 | return $pdf->download($data['title'].'-'.$data['subtitle'].'-'.date('Ymd-', time()).str_random(4).'.pdf'); 52 | } 53 | 54 | public function view(Request $request) { 55 | $data = json_decode(urldecode($request->input('data')), true); 56 | 57 | return view('pdf', ['data' => $data]); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /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", "sftp", "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 | 'url' => env('AWS_URL'), 65 | ], 66 | 67 | ], 68 | 69 | ]; 70 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/AuthorizationsController.php: -------------------------------------------------------------------------------- 1 | response()->noContent(); 14 | } 15 | 16 | public function weappStore(WeappAuthorizationRequest $request) 17 | { 18 | $code = $request->code; 19 | 20 | // 根据 code 获取微信 openid 和 session_key 21 | $miniProgram = \EasyWeChat::miniProgram(); 22 | $data = $miniProgram->auth->session($code); 23 | 24 | // 如果结果错误,说明 code 已过期或不正确,返回 401 错误 25 | if (isset($data['errcode'])) { 26 | return $this->response->errorUnauthorized('code 不正确'); 27 | } 28 | 29 | // 找到 openid 对应的用户 30 | $user = User::query()->where('weapp_openid', $data['openid'])->first(); 31 | 32 | $attributes['weixin_session_key'] = $data['session_key']; 33 | 34 | $attributes['name'] = $request->name; 35 | $attributes['avatar_url'] = $request->avatar_url ?? ''; 36 | $attributes['gender'] = $request->gender ?? 0; 37 | $attributes['city'] = $request->city ?? ''; 38 | $attributes['province'] = $request->province ?? ''; 39 | $attributes['country'] = $request->country ?? ''; 40 | // 未找到对应用户则需要提交用户名密码进行用户绑定 41 | if (!$user) { 42 | $attributes['weapp_openid'] = $data['openid']; 43 | $user = User::query()->create($attributes); 44 | }else{ 45 | // 更新用户数据 46 | $user->update($attributes); 47 | } 48 | 49 | // 为对应用户创建 JWT 50 | $token = Auth::guard('api')->fromUser($user); 51 | 52 | return $this->respondWithToken($token)->setStatusCode(201); 53 | } 54 | 55 | public function update(Request $request) 56 | { 57 | $token = Auth::guard('api')->refresh(); 58 | return $this->respondWithToken($token); 59 | } 60 | 61 | public function destroy() 62 | { 63 | Auth::guard('api')->logout(); 64 | return $this->response->noContent(); 65 | } 66 | 67 | protected function respondWithToken($token) 68 | { 69 | return $this->response->array([ 70 | 'access_token' => $token, 71 | 'token_type' => 'Bearer', 72 | 'expires_in' => Auth::guard('api')->factory()->getTTL() * 60 73 | ]); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "php": "^7.1.3", 9 | "ext-gd": "*", 10 | "barryvdh/laravel-ide-helper": "^2.6", 11 | "barryvdh/laravel-snappy": "^0.4.8", 12 | "dingo/api": "^2.0.0-alpha2", 13 | "doctrine/dbal": "^2.9", 14 | "fideloper/proxy": "^4.0", 15 | "h4cc/wkhtmltoimage-amd64": "0.12.x", 16 | "h4cc/wkhtmltopdf-amd64": "0.12.x", 17 | "intervention/image": "^2.5", 18 | "laravel/framework": "5.7.*", 19 | "laravel/tinker": "^1.0", 20 | "liyu/dingo-serializer-switch": "^0.3.1", 21 | "overtrue/laravel-wechat": "~4.0", 22 | "tymon/jwt-auth": "1.0.0-rc.3", 23 | "ext-json": "*" 24 | }, 25 | "require-dev": { 26 | "beyondcode/laravel-dump-server": "^1.0", 27 | "filp/whoops": "^2.0", 28 | "fzaninotto/faker": "^1.4", 29 | "mockery/mockery": "^1.0", 30 | "nunomaduro/collision": "^2.0", 31 | "phpunit/phpunit": "^7.0" 32 | }, 33 | "autoload": { 34 | "classmap": [ 35 | "database/seeds", 36 | "database/factories" 37 | ], 38 | "psr-4": { 39 | "App\\": "app/" 40 | } 41 | }, 42 | "autoload-dev": { 43 | "psr-4": { 44 | "Tests\\": "tests/" 45 | } 46 | }, 47 | "extra": { 48 | "laravel": { 49 | "dont-discover": [ 50 | ] 51 | } 52 | }, 53 | "scripts": { 54 | "post-root-package-install": [ 55 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 56 | ], 57 | "post-create-project-cmd": [ 58 | "@php artisan key:generate --ansi" 59 | ], 60 | "post-autoload-dump": [ 61 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 62 | "@php artisan package:discover --ansi" 63 | ], 64 | "post-update-cmd": [ 65 | "Illuminate\\Foundation\\ComposerScripts::postUpdate", 66 | "php artisan ide-helper:generate", 67 | "php artisan ide-helper:meta" 68 | ] 69 | }, 70 | "config": { 71 | "preferred-install": "dist", 72 | "sort-packages": true, 73 | "optimize-autoloader": true 74 | }, 75 | "minimum-stability": "dev", 76 | "prefer-stable": true 77 | } 78 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Log Channels 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the log channels for your application. Out of 27 | | the box, Laravel uses the Monolog PHP logging library. This gives 28 | | you a variety of powerful log handlers / formatters to utilize. 29 | | 30 | | Available Drivers: "single", "daily", "slack", "syslog", 31 | | "errorlog", "monolog", 32 | | "custom", "stack" 33 | | 34 | */ 35 | 36 | 'channels' => [ 37 | 'stack' => [ 38 | 'driver' => 'stack', 39 | 'channels' => ['daily'], 40 | ], 41 | 42 | 'single' => [ 43 | 'driver' => 'single', 44 | 'path' => storage_path('logs/laravel.log'), 45 | 'level' => 'debug', 46 | ], 47 | 48 | 'daily' => [ 49 | 'driver' => 'daily', 50 | 'path' => storage_path('logs/laravel.log'), 51 | 'level' => 'debug', 52 | 'days' => 14, 53 | ], 54 | 55 | 'slack' => [ 56 | 'driver' => 'slack', 57 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 58 | 'username' => 'Laravel Log', 59 | 'emoji' => ':boom:', 60 | 'level' => 'critical', 61 | ], 62 | 63 | 'papertrail' => [ 64 | 'driver' => 'monolog', 65 | 'level' => 'debug', 66 | 'handler' => SyslogUdpHandler::class, 67 | 'handler_with' => [ 68 | 'host' => env('PAPERTRAIL_URL'), 69 | 'port' => env('PAPERTRAIL_PORT'), 70 | ], 71 | ], 72 | 73 | 'stderr' => [ 74 | 'driver' => 'monolog', 75 | 'handler' => StreamHandler::class, 76 | 'with' => [ 77 | 'stream' => 'php://stderr', 78 | ], 79 | ], 80 | 81 | 'syslog' => [ 82 | 'driver' => 'syslog', 83 | 'level' => 'debug', 84 | ], 85 | 86 | 'errorlog' => [ 87 | 'driver' => 'errorlog', 88 | 'level' => 'debug', 89 | ], 90 | ], 91 | 92 | ]; 93 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 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' => env('REDIS_QUEUE', 'default'), 64 | 'retry_after' => 90, 65 | 'block_for' => null, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Cache Stores 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Here you may define all of the cache "stores" for your application as 28 | | well as their drivers. You may even define multiple stores for the 29 | | same cache driver to group types of items stored in your caches. 30 | | 31 | */ 32 | 33 | 'stores' => [ 34 | 35 | 'apc' => [ 36 | 'driver' => 'apc', 37 | ], 38 | 39 | 'array' => [ 40 | 'driver' => 'array', 41 | ], 42 | 43 | 'database' => [ 44 | 'driver' => 'database', 45 | 'table' => 'cache', 46 | 'connection' => null, 47 | ], 48 | 49 | 'file' => [ 50 | 'driver' => 'file', 51 | 'path' => storage_path('framework/cache/data'), 52 | ], 53 | 54 | 'memcached' => [ 55 | 'driver' => 'memcached', 56 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 57 | 'sasl' => [ 58 | env('MEMCACHED_USERNAME'), 59 | env('MEMCACHED_PASSWORD'), 60 | ], 61 | 'options' => [ 62 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 63 | ], 64 | 'servers' => [ 65 | [ 66 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 67 | 'port' => env('MEMCACHED_PORT', 11211), 68 | 'weight' => 100, 69 | ], 70 | ], 71 | ], 72 | 73 | 'redis' => [ 74 | 'driver' => 'redis', 75 | 'connection' => 'cache', 76 | ], 77 | 78 | ], 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Cache Key Prefix 83 | |-------------------------------------------------------------------------- 84 | | 85 | | When utilizing a RAM based store such as APC or Memcached, there might 86 | | be other applications utilizing the same cache. So, we'll specify a 87 | | value to get prefixed to all our keys so we can avoid collisions. 88 | | 89 | */ 90 | 91 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /app/Http/Kernel.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' => \App\Http\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 58 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 59 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 60 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 62 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 63 | // 接口语言设置 64 | 'change-locale' => \App\Http\Middleware\ChangeLocale::class, 65 | ]; 66 | 67 | /** 68 | * The priority-sorted list of middleware. 69 | * 70 | * This forces the listed middleware to always be in the given order. 71 | * 72 | * @var array 73 | */ 74 | protected $middlewarePriority = [ 75 | \Illuminate\Session\Middleware\StartSession::class, 76 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 77 | \App\Http\Middleware\Authenticate::class, 78 | \Illuminate\Session\Middleware\AuthenticateSession::class, 79 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 80 | \Illuminate\Auth\Middleware\Authorize::class, 81 | ]; 82 | } 83 | -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 65 | 66 | 67 |
68 | @if (Route::has('login')) 69 | 80 | @endif 81 | 82 |
83 |
84 | Laravel 85 |
86 | 87 | 95 |
96 |
97 | 98 | 99 | -------------------------------------------------------------------------------- /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' => 'jwt', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\Models\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /resources/views/pdf.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Laravel 6 | 7 | 8 | 22 | 23 | 24 |
25 | 26 | 27 |
28 |
{{ $data['title'] }}
29 |
{{ $data['subtitle'] }}
30 |
31 |
32 |
33 | 34 | 35 |
天艺传媒简介
36 | 37 |
      厦门市天艺传媒股份有限公司创立于1993年,业务范围覆盖品牌管理、创意策划、整合营销、媒体投放等传播链条。公司发 展近26年,在户外传媒领域极具市场竞争优势,形成了候车亭、站名牌、路名牌、高速大牌、厦门国际邮轮中心媒体、厦门航空 舱内座椅头片媒体、游轮冠名权及船身媒体等“海·陆·空”360°全媒体覆盖。2015年10月天艺成功登陆新三板,成为福建省户外 传媒类先行上市企业。
38 |
39 | 40 | @foreach($data['ads'] as $ad) 41 |
42 | 43 | 44 |
广告投放详情
45 | 46 | 47 | 48 |
位 置: {{ $ad['position1'] }}
49 |
点 位: {{ $ad['position2'] }}
50 |
编 号: {{ $ad['code'] }}
51 |
52 | @endforeach 53 | 54 |
55 |
THANK YOU
56 | 57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | version('v1', [ 8 | 'namespace' => 'App\Http\Controllers\Api', 9 | 'middleware' => ['serializer:array', 'bindings', 'change-locale'] 10 | ], function($api) { 11 | 12 | $api->group([ 13 | 'middleware' => 'api.throttle', 14 | 'limit' => config('api.rate_limits.sign.limit'), 15 | 'expires' => config('api.rate_limits.sign.expires'), 16 | ], function($api) { 17 | // 小程序登录 18 | $api->post('weapp/authorizations', 'AuthorizationsController@weappStore') 19 | ->name('api.weapp.authorizations.store'); 20 | 21 | // 刷新token 22 | $api->put('authorizations/current', 'AuthorizationsController@update') 23 | ->name('api.authorizations.update'); 24 | // 删除token 25 | $api->delete('authorizations/current', 'AuthorizationsController@destroy') 26 | ->name('api.authorizations.destroy'); 27 | 28 | }); 29 | 30 | $api->group([ 31 | 'middleware' => 'api.throttle', 32 | 'limit' => config('api.rate_limits.access.limit'), 33 | 'expires' => config('api.rate_limits.access.expires'), 34 | ], function ($api) { 35 | // 游客可以访问的接口 36 | $api->get('qas', 'QAsController@index') 37 | ->name('api.qas.index'); 38 | $api->get('pdf', 'PdfController@pdf') 39 | ->name('api.pdf'); 40 | $api->get('pdf/view', 'PdfController@view') 41 | ->name('api.view'); 42 | 43 | 44 | 45 | // 需要 token 验证的接口 46 | $api->group(['middleware' => 'api.auth'], function($api) { 47 | 48 | // 当前登录用户信息 49 | $api->get('user', 'UsersController@me') 50 | ->name('api.user.me'); 51 | 52 | $api->post('user/store_images', 'UsersController@storeImages') 53 | ->name('api.user.store_images'); 54 | 55 | $api->delete('user/delete_images', 'UsersController@deleteImages') 56 | ->name('api.user.delete_images'); 57 | 58 | $api->get('/activities', "ActivitiesController@myActivities") 59 | ->name('api.activities'); 60 | 61 | $api->post('activities/save/{activity?}', "ActivitiesController@save") 62 | ->name('api.activities.save'); 63 | 64 | $api->get('activities/{activity}', 'ActivitiesController@show') 65 | ->name('api.activities.show'); 66 | 67 | $api->put('activities/{activity}/participate', 'ActivitiesController@participate') 68 | ->name('api.activities.participate'); 69 | 70 | $api->delete('activities/{activity}', 'ActivitiesController@quit') 71 | ->name('api.activities.quit'); 72 | 73 | $api->get('activities/{activity}/participants', 'ActivitiesController@participants') 74 | ->name('api.activities.participants'); 75 | 76 | $api->delete('activities/{activity}/remove_participants', 'ActivitiesController@removeParticipants') 77 | ->name('api.activities.participants.delete'); 78 | 79 | $api->get('activities/{activity}/bills', 'BillsController@bills') 80 | ->name('api.activities.bills.index'); 81 | 82 | $api->post('activities/{activity}/bills/{bill?}', 'BillsController@save') 83 | ->name('api.activities.bills.save'); 84 | 85 | $api->get('bills/{bill}', 'BillsController@show') 86 | ->name('api.bills.show'); 87 | 88 | $api->delete('bills/{bill}', 'BillsController@delete') 89 | ->name('api.bills.delete'); 90 | 91 | $api->get('bills/{bill}/poster', 'BillsController@poster') 92 | ->name('api.bills.poster'); 93 | 94 | 95 | }); 96 | }); 97 | 98 | 99 | 100 | 101 | 102 | 103 | }); 104 | -------------------------------------------------------------------------------- /public/svg/404.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/wechat.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * This source file is subject to the MIT license that is bundled 9 | * with this source code in the file LICENSE. 10 | */ 11 | 12 | return [ 13 | /* 14 | * 默认配置,将会合并到各模块中 15 | */ 16 | 'defaults' => [ 17 | /* 18 | * 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 19 | */ 20 | 'response_type' => 'array', 21 | 22 | /* 23 | * 使用 Laravel 的缓存系统 24 | */ 25 | 'use_laravel_cache' => true, 26 | 27 | /* 28 | * 日志配置 29 | * 30 | * level: 日志级别,可选为: 31 | * debug/info/notice/warning/error/critical/alert/emergency 32 | * file:日志文件位置(绝对路径!!!),要求可写权限 33 | */ 34 | 'log' => [ 35 | 'level' => env('WECHAT_LOG_LEVEL', 'debug'), 36 | 'file' => env('WECHAT_LOG_FILE', storage_path('logs/wechat.log')), 37 | ], 38 | ], 39 | 40 | /* 41 | * 路由配置 42 | */ 43 | 'route' => [ 44 | /* 45 | * 开放平台第三方平台路由配置 46 | */ 47 | // 'open_platform' => [ 48 | // 'uri' => 'serve', 49 | // 'action' => Overtrue\LaravelWeChat\Controllers\OpenPlatformController::class, 50 | // 'attributes' => [ 51 | // 'prefix' => 'open-platform', 52 | // 'middleware' => null, 53 | // ], 54 | // ], 55 | ], 56 | 57 | /* 58 | * 公众号 59 | */ 60 | 'official_account' => [ 61 | 'default' => [ 62 | 'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', 'your-app-id'), // AppID 63 | 'secret' => env('WECHAT_OFFICIAL_ACCOUNT_SECRET', 'your-app-secret'), // AppSecret 64 | 'token' => env('WECHAT_OFFICIAL_ACCOUNT_TOKEN', 'your-token'), // Token 65 | 'aes_key' => env('WECHAT_OFFICIAL_ACCOUNT_AES_KEY', ''), // EncodingAESKey 66 | 67 | /* 68 | * OAuth 配置 69 | * 70 | * scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login 71 | * callback:OAuth授权完成后的回调页地址(如果使用中间件,则随便填写。。。) 72 | */ 73 | // 'oauth' => [ 74 | // 'scopes' => array_map('trim', explode(',', env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_SCOPES', 'snsapi_userinfo'))), 75 | // 'callback' => env('WECHAT_OFFICIAL_ACCOUNT_OAUTH_CALLBACK', '/examples/oauth_callback.php'), 76 | // ], 77 | ], 78 | ], 79 | 80 | /* 81 | * 开放平台第三方平台 82 | */ 83 | // 'open_platform' => [ 84 | // 'default' => [ 85 | // 'app_id' => env('WECHAT_OPEN_PLATFORM_APPID', ''), 86 | // 'secret' => env('WECHAT_OPEN_PLATFORM_SECRET', ''), 87 | // 'token' => env('WECHAT_OPEN_PLATFORM_TOKEN', ''), 88 | // 'aes_key' => env('WECHAT_OPEN_PLATFORM_AES_KEY', ''), 89 | // ], 90 | // ], 91 | 92 | /* 93 | * 小程序 94 | */ 95 | 'mini_program' => [ 96 | 'default' => [ 97 | 'app_id' => env('WECHAT_MINI_PROGRAM_APPID', ''), 98 | 'secret' => env('WECHAT_MINI_PROGRAM_SECRET', ''), 99 | 'token' => env('WECHAT_MINI_PROGRAM_TOKEN', ''), 100 | 'aes_key' => env('WECHAT_MINI_PROGRAM_AES_KEY', ''), 101 | ], 102 | ], 103 | 104 | /* 105 | * 微信支付 106 | */ 107 | // 'payment' => [ 108 | // 'default' => [ 109 | // 'sandbox' => env('WECHAT_PAYMENT_SANDBOX', false), 110 | // 'app_id' => env('WECHAT_PAYMENT_APPID', ''), 111 | // 'mch_id' => env('WECHAT_PAYMENT_MCH_ID', 'your-mch-id'), 112 | // 'key' => env('WECHAT_PAYMENT_KEY', 'key-for-signature'), 113 | // 'cert_path' => env('WECHAT_PAYMENT_CERT_PATH', 'path/to/cert/apiclient_cert.pem'), // XXX: 绝对路径!!!! 114 | // 'key_path' => env('WECHAT_PAYMENT_KEY_PATH', 'path/to/cert/apiclient_key.pem'), // XXX: 绝对路径!!!! 115 | // 'notify_url' => 'http://example.com/payments/wechat-notify', // 默认支付结果通知地址 116 | // ], 117 | // // ... 118 | // ], 119 | 120 | /* 121 | * 企业微信 122 | */ 123 | // 'work' => [ 124 | // 'default' => [ 125 | // 'corp_id' => 'xxxxxxxxxxxxxxxxx', 126 | /// 'agent_id' => 100020, 127 | // 'secret' => env('WECHAT_WORK_AGENT_CONTACTS_SECRET', ''), 128 | // //... 129 | // ], 130 | // ], 131 | ]; 132 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => [ 59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 60 | 'name' => env('MAIL_FROM_NAME', 'Example'), 61 | ], 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | E-Mail Encryption Protocol 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Here you may specify the encryption protocol that should be used when 69 | | the application send e-mail messages. A sensible default using the 70 | | transport layer security protocol should provide great security. 71 | | 72 | */ 73 | 74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | SMTP Server Username 79 | |-------------------------------------------------------------------------- 80 | | 81 | | If your SMTP server requires a username for authentication, you should 82 | | set it here. This will get used to authenticate with your server on 83 | | connection. You may also set the "password" value below this one. 84 | | 85 | */ 86 | 87 | 'username' => env('MAIL_USERNAME'), 88 | 89 | 'password' => env('MAIL_PASSWORD'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Sendmail System Path 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using the "sendmail" driver to send e-mails, we will need to know 97 | | the path to where Sendmail lives on this server. A default path has 98 | | been provided here, which will work well on most of your systems. 99 | | 100 | */ 101 | 102 | 'sendmail' => '/usr/sbin/sendmail -bs', 103 | 104 | /* 105 | |-------------------------------------------------------------------------- 106 | | Markdown Mail Settings 107 | |-------------------------------------------------------------------------- 108 | | 109 | | If you are using Markdown based email rendering, you may configure your 110 | | theme and component paths here, allowing you to customize the design 111 | | of the emails. Or, you may simply stick with the Laravel defaults! 112 | | 113 | */ 114 | 115 | 'markdown' => [ 116 | 'theme' => 'default', 117 | 118 | 'paths' => [ 119 | resource_path('views/vendor/mail'), 120 | ], 121 | ], 122 | 123 | ]; 124 | -------------------------------------------------------------------------------- /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 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 41 | ], 42 | 43 | 'mysql' => [ 44 | 'driver' => 'mysql', 45 | 'host' => env('DB_HOST', '127.0.0.1'), 46 | 'port' => env('DB_PORT', '3306'), 47 | 'database' => env('DB_DATABASE', 'forge'), 48 | 'username' => env('DB_USERNAME', 'forge'), 49 | 'password' => env('DB_PASSWORD', ''), 50 | 'unix_socket' => env('DB_SOCKET', ''), 51 | 'charset' => 'utf8mb4', 52 | 'collation' => 'utf8mb4_unicode_ci', 53 | 'prefix' => '', 54 | 'prefix_indexes' => true, 55 | 'strict' => true, 56 | 'engine' => null, 57 | ], 58 | 59 | 'pgsql' => [ 60 | 'driver' => 'pgsql', 61 | 'host' => env('DB_HOST', '127.0.0.1'), 62 | 'port' => env('DB_PORT', '5432'), 63 | 'database' => env('DB_DATABASE', 'forge'), 64 | 'username' => env('DB_USERNAME', 'forge'), 65 | 'password' => env('DB_PASSWORD', ''), 66 | 'charset' => 'utf8', 67 | 'prefix' => '', 68 | 'prefix_indexes' => true, 69 | 'schema' => 'public', 70 | 'sslmode' => 'prefer', 71 | ], 72 | 73 | 'sqlsrv' => [ 74 | 'driver' => 'sqlsrv', 75 | 'host' => env('DB_HOST', 'localhost'), 76 | 'port' => env('DB_PORT', '1433'), 77 | 'database' => env('DB_DATABASE', 'forge'), 78 | 'username' => env('DB_USERNAME', 'forge'), 79 | 'password' => env('DB_PASSWORD', ''), 80 | 'charset' => 'utf8', 81 | 'prefix' => '', 82 | 'prefix_indexes' => true, 83 | ], 84 | 85 | ], 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Migration Repository Table 90 | |-------------------------------------------------------------------------- 91 | | 92 | | This table keeps track of all the migrations that have already run for 93 | | your application. Using this information, we can determine which of 94 | | the migrations on disk haven't actually been run in the database. 95 | | 96 | */ 97 | 98 | 'migrations' => 'migrations', 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Redis Databases 103 | |-------------------------------------------------------------------------- 104 | | 105 | | Redis is an open source, fast, and advanced key-value store that also 106 | | provides a richer body of commands than a typical key-value system 107 | | such as APC or Memcached. Laravel makes it easy to dig right in. 108 | | 109 | */ 110 | 111 | 'redis' => [ 112 | 113 | 'client' => 'predis', 114 | 115 | 'default' => [ 116 | 'host' => env('REDIS_HOST', '127.0.0.1'), 117 | 'password' => env('REDIS_PASSWORD', null), 118 | 'port' => env('REDIS_PORT', 6379), 119 | 'database' => env('REDIS_DB', 0), 120 | ], 121 | 122 | 'cache' => [ 123 | 'host' => env('REDIS_HOST', '127.0.0.1'), 124 | 'password' => env('REDIS_PASSWORD', null), 125 | 'port' => env('REDIS_PORT', 6379), 126 | 'database' => env('REDIS_CACHE_DB', 1), 127 | ], 128 | 129 | ], 130 | 131 | ]; 132 | -------------------------------------------------------------------------------- /public/svg/503.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/svg/403.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/Http/Controllers/Api/ActivitiesController.php: -------------------------------------------------------------------------------- 1 | user_id = $this->user()->id; 31 | $activity->wx_a_code = ''; 32 | }else{ 33 | if(!$this->user()->isAuthorOf($activity)){ 34 | return $this->response->errorUnauthorized(); 35 | } 36 | } 37 | $activity->name = $request->name; 38 | 39 | DB::transaction(function() use ($activity, $created_activity) { 40 | 41 | $activity->save(); 42 | if(empty($activity->wx_a_code)){ 43 | $miniProgram = \EasyWeChat::miniProgram(); 44 | $response = $miniProgram->app_code->getUnlimit('activity_id:'.$activity->id); 45 | // 保存小程序码到文件 46 | if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { 47 | $filename = $response->save(\Storage::disk('public')->path(''), Uuid::uuid1()->toString()); 48 | $activity->wx_a_code = '/'.$filename; 49 | 50 | $activity->save(); 51 | } 52 | } 53 | 54 | 55 | if($created_activity) { 56 | ActivityParticipant::query()->create( 57 | ['activity_id' => $activity->id, 'user_id' => $this->user()->id] 58 | ); 59 | } 60 | }); 61 | 62 | return $this->response->item($activity, (new ActivityTransformer()))->setStatusCode(201); 63 | } 64 | 65 | public function show(Activity $activity) { 66 | $user = $this->user(); 67 | if(!ActivityParticipant::query()->where('user_id', $user->id)->where('activity_id', $activity->id)->exists()){ 68 | return $this->response->errorNotFound(); 69 | } 70 | 71 | return $this->response->item($activity, new ActivityTransformer()); 72 | 73 | } 74 | 75 | public function myActivities() { 76 | 77 | $user = $this->user(); 78 | $my_activities = $this->user() 79 | ->participatedActivities() 80 | ->orderBy('id', 'desc') 81 | ->get(); 82 | 83 | $my_activities_id = $my_activities->pluck('id'); 84 | 85 | $my_bills = Bill::query()->whereIn('activity_id', $my_activities_id) 86 | ->select('id', 'activity_id','user_id') 87 | ->where(function($query) { 88 | $query 89 | ->where('user_id', $this->user->id) 90 | ->orWhereHas('participants', function($query){ 91 | $query->where('user_id', $this->user->id); 92 | }); 93 | }) 94 | ->with(['participants' => function($query) use ($user) { 95 | 96 | }]) 97 | ->get(); 98 | 99 | $grouped = $my_bills->groupBy('activity_id'); 100 | 101 | $my_activities->each(function($value) use ($grouped){ 102 | $value->split_sum = 0.00; 103 | $value->unpaid_sum = 0.00; 104 | 105 | if(isset($grouped[$value->id])) { 106 | $value->all_unpaid_sum = 0.00; 107 | $collection = collect($grouped[$value->id]); 108 | $participants_of_me = $collection->pluck('participants')->collapse()->filter(function($participant) { 109 | return $participant->user_id === $this->user->id; 110 | }); 111 | 112 | $value->split_sum = $participants_of_me->sum(function($item){ 113 | return $item->split_money * 100; 114 | }); 115 | $value->split_sum = bcdiv($value->split_sum, 100, 2); 116 | $value->unpaid_sum = $participants_of_me->sum(function($item){ 117 | return $item->paid ? 0.00 : $item->split_money * 100; 118 | }); 119 | $value->unpaid_sum = bcdiv($value->unpaid_sum, 100, 2); 120 | 121 | 122 | $value->all_unpaid_sum = $collection->filter(function($bill) { 123 | return $bill->user_id === $this->user->id; 124 | })->pluck('participants')->collapse()->filter(function($participant) { 125 | return $participant->user_id !== $this->user->id && !$participant->paid; 126 | })->sum(function($item) { 127 | return $item->split_money * 100; 128 | }); 129 | 130 | $value->all_unpaid_sum = bcdiv($value->all_unpaid_sum, 100, 2); 131 | } 132 | }); 133 | 134 | 135 | return $this->response->collection($my_activities, new ActivityTransformer()); 136 | } 137 | 138 | 139 | public function participate(Activity $activity) { 140 | $activity->participatedUsers()->syncWithoutDetaching([$this->user()->id]); 141 | 142 | return $this->response->noContent(); 143 | } 144 | 145 | 146 | public function participants(Activity $activity) { 147 | return $this->response->collection($activity->participatedUsers()->get(), new UserTransformer()); 148 | } 149 | 150 | 151 | public function quit(Activity $activity) { 152 | DB::transaction(function() use ($activity){ 153 | $activity->participatedUsers()->detach([$this->user()->id]); 154 | if($this->user()->isAuthorOf($activity)){ 155 | $activity->participatedUsers()->detach(); 156 | $activity->delete(); 157 | foreach ($activity->bills as $bill){ 158 | $bill->participants()->delete(); 159 | $bill->items()->delete(); 160 | $bill->delete(); 161 | } 162 | } 163 | }); 164 | 165 | return $this->response->noContent(); 166 | } 167 | 168 | public function removeParticipants(FormRequest $request, Activity $activity) { 169 | if(!$this->user->isAuthorOf($activity)) { 170 | return $this->response->errorUnauthorized(); 171 | } 172 | 173 | $activity->participatedUsers()->detach($request->user_ids); 174 | 175 | return $this->response->collection($activity->participatedUsers()->get(), new UserTransformer()); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to immediately expire on the browser closing, set that option. 31 | | 32 | */ 33 | 34 | 'lifetime' => env('SESSION_LIFETIME', 120), 35 | 36 | 'expire_on_close' => false, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Session Encryption 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This option allows you to easily specify that all of your session data 44 | | should be encrypted before it is stored. All encryption will be run 45 | | automatically by Laravel and you can use the Session like normal. 46 | | 47 | */ 48 | 49 | 'encrypt' => false, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Session File Location 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When using the native session driver, we need a location where session 57 | | files may be stored. A default has been set for you but a different 58 | | location may be specified. This is only needed for file sessions. 59 | | 60 | */ 61 | 62 | 'files' => storage_path('framework/sessions'), 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Session Database Connection 67 | |-------------------------------------------------------------------------- 68 | | 69 | | When using the "database" or "redis" session drivers, you may specify a 70 | | connection that should be used to manage these sessions. This should 71 | | correspond to a connection in your database configuration options. 72 | | 73 | */ 74 | 75 | 'connection' => env('SESSION_CONNECTION', null), 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Session Database Table 80 | |-------------------------------------------------------------------------- 81 | | 82 | | When using the "database" session driver, you may specify the table we 83 | | should use to manage the sessions. Of course, a sensible default is 84 | | provided for you; however, you are free to change this as needed. 85 | | 86 | */ 87 | 88 | 'table' => 'sessions', 89 | 90 | /* 91 | |-------------------------------------------------------------------------- 92 | | Session Cache Store 93 | |-------------------------------------------------------------------------- 94 | | 95 | | When using the "apc" or "memcached" session drivers, you may specify a 96 | | cache store that should be used for these sessions. This value must 97 | | correspond with one of the application's configured cache stores. 98 | | 99 | */ 100 | 101 | 'store' => env('SESSION_STORE', null), 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Session Sweeping Lottery 106 | |-------------------------------------------------------------------------- 107 | | 108 | | Some session drivers must manually sweep their storage location to get 109 | | rid of old sessions from storage. Here are the chances that it will 110 | | happen on a given request. By default, the odds are 2 out of 100. 111 | | 112 | */ 113 | 114 | 'lottery' => [2, 100], 115 | 116 | /* 117 | |-------------------------------------------------------------------------- 118 | | Session Cookie Name 119 | |-------------------------------------------------------------------------- 120 | | 121 | | Here you may change the name of the cookie used to identify a session 122 | | instance by ID. The name specified here will get used every time a 123 | | new session cookie is created by the framework for every driver. 124 | | 125 | */ 126 | 127 | 'cookie' => env( 128 | 'SESSION_COOKIE', 129 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 130 | ), 131 | 132 | /* 133 | |-------------------------------------------------------------------------- 134 | | Session Cookie Path 135 | |-------------------------------------------------------------------------- 136 | | 137 | | The session cookie path determines the path for which the cookie will 138 | | be regarded as available. Typically, this will be the root path of 139 | | your application but you are free to change this when necessary. 140 | | 141 | */ 142 | 143 | 'path' => '/', 144 | 145 | /* 146 | |-------------------------------------------------------------------------- 147 | | Session Cookie Domain 148 | |-------------------------------------------------------------------------- 149 | | 150 | | Here you may change the domain of the cookie used to identify a session 151 | | in your application. This will determine which domains the cookie is 152 | | available to in your application. A sensible default has been set. 153 | | 154 | */ 155 | 156 | 'domain' => env('SESSION_DOMAIN', null), 157 | 158 | /* 159 | |-------------------------------------------------------------------------- 160 | | HTTPS Only Cookies 161 | |-------------------------------------------------------------------------- 162 | | 163 | | By setting this option to true, session cookies will only be sent back 164 | | to the server if the browser has a HTTPS connection. This will keep 165 | | the cookie from being sent to you if it can not be done securely. 166 | | 167 | */ 168 | 169 | 'secure' => env('SESSION_SECURE_COOKIE', false), 170 | 171 | /* 172 | |-------------------------------------------------------------------------- 173 | | HTTP Access Only 174 | |-------------------------------------------------------------------------- 175 | | 176 | | Setting this value to true will prevent JavaScript from accessing the 177 | | value of the cookie and the cookie will only be accessible through 178 | | the HTTP protocol. You are free to modify this option if needed. 179 | | 180 | */ 181 | 182 | 'http_only' => true, 183 | 184 | /* 185 | |-------------------------------------------------------------------------- 186 | | Same-Site Cookies 187 | |-------------------------------------------------------------------------- 188 | | 189 | | This option determines how your cookies behave when cross-site requests 190 | | take place, and can be used to mitigate CSRF attacks. By default, we 191 | | do not enable this as other CSRF protection services are in place. 192 | | 193 | | Supported: "lax", "strict" 194 | | 195 | */ 196 | 197 | 'same_site' => null, 198 | 199 | ]; 200 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 20 | 'alpha' => 'The :attribute may only contain letters.', 21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, dashes and underscores.', 22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 23 | 'array' => 'The :attribute must be an array.', 24 | 'before' => 'The :attribute must be a date before :date.', 25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 26 | 'between' => [ 27 | 'numeric' => 'The :attribute must be between :min and :max.', 28 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 29 | 'string' => 'The :attribute must be between :min and :max characters.', 30 | 'array' => 'The :attribute must have between :min and :max items.', 31 | ], 32 | 'boolean' => 'The :attribute field must be true or false.', 33 | 'confirmed' => 'The :attribute confirmation does not match.', 34 | 'date' => 'The :attribute is not a valid date.', 35 | 'date_format' => 'The :attribute does not match the format :format.', 36 | 'different' => 'The :attribute and :other must be different.', 37 | 'digits' => 'The :attribute must be :digits digits.', 38 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 39 | 'dimensions' => 'The :attribute has invalid image dimensions.', 40 | 'distinct' => 'The :attribute field has a duplicate value.', 41 | 'email' => 'The :attribute must be a valid email address.', 42 | 'exists' => 'The selected :attribute is invalid.', 43 | 'file' => 'The :attribute must be a file.', 44 | 'filled' => 'The :attribute field must have a value.', 45 | 'gt' => [ 46 | 'numeric' => 'The :attribute must be greater than :value.', 47 | 'file' => 'The :attribute must be greater than :value kilobytes.', 48 | 'string' => 'The :attribute must be greater than :value characters.', 49 | 'array' => 'The :attribute must have more than :value items.', 50 | ], 51 | 'gte' => [ 52 | 'numeric' => 'The :attribute must be greater than or equal :value.', 53 | 'file' => 'The :attribute must be greater than or equal :value kilobytes.', 54 | 'string' => 'The :attribute must be greater than or equal :value characters.', 55 | 'array' => 'The :attribute must have :value items or more.', 56 | ], 57 | 'image' => 'The :attribute must be an image.', 58 | 'in' => 'The selected :attribute is invalid.', 59 | 'in_array' => 'The :attribute field does not exist in :other.', 60 | 'integer' => 'The :attribute must be an integer.', 61 | 'ip' => 'The :attribute must be a valid IP address.', 62 | 'ipv4' => 'The :attribute must be a valid IPv4 address.', 63 | 'ipv6' => 'The :attribute must be a valid IPv6 address.', 64 | 'json' => 'The :attribute must be a valid JSON string.', 65 | 'lt' => [ 66 | 'numeric' => 'The :attribute must be less than :value.', 67 | 'file' => 'The :attribute must be less than :value kilobytes.', 68 | 'string' => 'The :attribute must be less than :value characters.', 69 | 'array' => 'The :attribute must have less than :value items.', 70 | ], 71 | 'lte' => [ 72 | 'numeric' => 'The :attribute must be less than or equal :value.', 73 | 'file' => 'The :attribute must be less than or equal :value kilobytes.', 74 | 'string' => 'The :attribute must be less than or equal :value characters.', 75 | 'array' => 'The :attribute must not have more than :value items.', 76 | ], 77 | 'max' => [ 78 | 'numeric' => 'The :attribute may not be greater than :max.', 79 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 80 | 'string' => 'The :attribute may not be greater than :max characters.', 81 | 'array' => 'The :attribute may not have more than :max items.', 82 | ], 83 | 'mimes' => 'The :attribute must be a file of type: :values.', 84 | 'mimetypes' => 'The :attribute must be a file of type: :values.', 85 | 'min' => [ 86 | 'numeric' => 'The :attribute must be at least :min.', 87 | 'file' => 'The :attribute must be at least :min kilobytes.', 88 | 'string' => 'The :attribute must be at least :min characters.', 89 | 'array' => 'The :attribute must have at least :min items.', 90 | ], 91 | 'not_in' => 'The selected :attribute is invalid.', 92 | 'not_regex' => 'The :attribute format is invalid.', 93 | 'numeric' => 'The :attribute must be a number.', 94 | 'present' => 'The :attribute field must be present.', 95 | 'regex' => 'The :attribute format is invalid.', 96 | 'required' => 'The :attribute field is required.', 97 | 'required_if' => 'The :attribute field is required when :other is :value.', 98 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 99 | 'required_with' => 'The :attribute field is required when :values is present.', 100 | 'required_with_all' => 'The :attribute field is required when :values are present.', 101 | 'required_without' => 'The :attribute field is required when :values is not present.', 102 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 103 | 'same' => 'The :attribute and :other must match.', 104 | 'size' => [ 105 | 'numeric' => 'The :attribute must be :size.', 106 | 'file' => 'The :attribute must be :size kilobytes.', 107 | 'string' => 'The :attribute must be :size characters.', 108 | 'array' => 'The :attribute must contain :size items.', 109 | ], 110 | 'string' => 'The :attribute must be a string.', 111 | 'timezone' => 'The :attribute must be a valid zone.', 112 | 'unique' => 'The :attribute has already been taken.', 113 | 'uploaded' => 'The :attribute failed to upload.', 114 | 'url' => 'The :attribute format is invalid.', 115 | 'uuid' => 'The :attribute must be a valid UUID.', 116 | 117 | /* 118 | |-------------------------------------------------------------------------- 119 | | Custom Validation Language Lines 120 | |-------------------------------------------------------------------------- 121 | | 122 | | Here you may specify custom validation messages for attributes using the 123 | | convention "attribute.rule" to name the lines. This makes it quick to 124 | | specify a specific custom language line for a given attribute rule. 125 | | 126 | */ 127 | 128 | 'custom' => [ 129 | 'attribute-name' => [ 130 | 'rule-name' => 'custom-message', 131 | ], 132 | ], 133 | 134 | /* 135 | |-------------------------------------------------------------------------- 136 | | Custom Validation Attributes 137 | |-------------------------------------------------------------------------- 138 | | 139 | | The following language lines are used to swap our attribute placeholder 140 | | with something more reader friendly such as "E-Mail Address" instead 141 | | of "email". This simply helps us make our message more expressive. 142 | | 143 | */ 144 | 145 | 'attributes' => [], 146 | 147 | ]; 148 | -------------------------------------------------------------------------------- /config/api.php: -------------------------------------------------------------------------------- 1 | env('API_STANDARDS_TREE', 'x'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | API Subtype 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Your subtype will follow the standards tree you use when used in the 29 | | "Accept" header to negotiate the content type and version. 30 | | 31 | | For example: Accept: application/x.SUBTYPE.v1+json 32 | | 33 | */ 34 | 35 | 'subtype' => env('API_SUBTYPE', ''), 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Default API Version 40 | |-------------------------------------------------------------------------- 41 | | 42 | | This is the default version when strict mode is disabled and your API 43 | | is accessed via a web browser. It's also used as the default version 44 | | when generating your APIs documentation. 45 | | 46 | */ 47 | 48 | 'version' => env('API_VERSION', 'v1'), 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | Default API Prefix 53 | |-------------------------------------------------------------------------- 54 | | 55 | | A default prefix to use for your API routes so you don't have to 56 | | specify it for each group. 57 | | 58 | */ 59 | 60 | 'prefix' => env('API_PREFIX', null), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Default API Domain 65 | |-------------------------------------------------------------------------- 66 | | 67 | | A default domain to use for your API routes so you don't have to 68 | | specify it for each group. 69 | | 70 | */ 71 | 72 | 'domain' => env('API_DOMAIN', null), 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Name 77 | |-------------------------------------------------------------------------- 78 | | 79 | | When documenting your API using the API Blueprint syntax you can 80 | | configure a default name to avoid having to manually specify 81 | | one when using the command. 82 | | 83 | */ 84 | 85 | 'name' => env('API_NAME', null), 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Conditional Requests 90 | |-------------------------------------------------------------------------- 91 | | 92 | | Globally enable conditional requests so that an ETag header is added to 93 | | any successful response. Subsequent requests will perform a check and 94 | | will return a 304 Not Modified. This can also be enabled or disabled 95 | | on certain groups or routes. 96 | | 97 | */ 98 | 99 | 'conditionalRequest' => env('API_CONDITIONAL_REQUEST', true), 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Strict Mode 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Enabling strict mode will require clients to send a valid Accept header 107 | | with every request. This also voids the default API version, meaning 108 | | your API will not be browsable via a web browser. 109 | | 110 | */ 111 | 112 | 'strict' => env('API_STRICT', false), 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Debug Mode 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Enabling debug mode will result in error responses caused by thrown 120 | | exceptions to have a "debug" key that will be populated with 121 | | more detailed information on the exception. 122 | | 123 | */ 124 | 125 | 'debug' => env('API_DEBUG', false), 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Generic Error Format 130 | |-------------------------------------------------------------------------- 131 | | 132 | | When some HTTP exceptions are not caught and dealt with the API will 133 | | generate a generic error response in the format provided. Any 134 | | keys that aren't replaced with corresponding values will be 135 | | removed from the final response. 136 | | 137 | */ 138 | 139 | 'errorFormat' => [ 140 | 'message' => ':message', 141 | 'errors' => ':errors', 142 | 'code' => ':code', 143 | 'status_code' => ':status_code', 144 | 'debug' => ':debug', 145 | ], 146 | 147 | /* 148 | |-------------------------------------------------------------------------- 149 | | API Middleware 150 | |-------------------------------------------------------------------------- 151 | | 152 | | Middleware that will be applied globally to all API requests. 153 | | 154 | */ 155 | 156 | 'middleware' => [ 157 | 158 | ], 159 | 160 | /* 161 | |-------------------------------------------------------------------------- 162 | | Authentication Providers 163 | |-------------------------------------------------------------------------- 164 | | 165 | | The authentication providers that should be used when attempting to 166 | | authenticate an incoming API request. 167 | | 168 | */ 169 | 170 | 'auth' => [ 171 | 'jwt' => 'Dingo\Api\Auth\Provider\JWT', 172 | ], 173 | 174 | /* 175 | |-------------------------------------------------------------------------- 176 | | Throttling / Rate Limiting 177 | |-------------------------------------------------------------------------- 178 | | 179 | | Consumers of your API can be limited to the amount of requests they can 180 | | make. You can create your own throttles or simply change the default 181 | | throttles. 182 | | 183 | */ 184 | 185 | 'throttling' => [ 186 | 187 | ], 188 | 189 | /* 190 | |-------------------------------------------------------------------------- 191 | | Response Transformer 192 | |-------------------------------------------------------------------------- 193 | | 194 | | Responses can be transformed so that they are easier to format. By 195 | | default a Fractal transformer will be used to transform any 196 | | responses prior to formatting. You can easily replace 197 | | this with your own transformer. 198 | | 199 | */ 200 | 201 | 'transformer' => env('API_TRANSFORMER', Dingo\Api\Transformer\Adapter\Fractal::class), 202 | 203 | /* 204 | |-------------------------------------------------------------------------- 205 | | Response Formats 206 | |-------------------------------------------------------------------------- 207 | | 208 | | Responses can be returned in multiple formats by registering different 209 | | response formatters. You can also customize an existing response 210 | | formatter with a number of options to configure its output. 211 | | 212 | */ 213 | 214 | 'defaultFormat' => env('API_DEFAULT_FORMAT', 'json'), 215 | 216 | 'formats' => [ 217 | 218 | 'json' => Dingo\Api\Http\Response\Format\Json::class, 219 | 220 | ], 221 | 222 | 'formatsOptions' => [ 223 | 224 | 'json' => [ 225 | 'pretty_print' => env('API_JSON_FORMAT_PRETTY_PRINT_ENABLED', false), 226 | 'indent_style' => env('API_JSON_FORMAT_INDENT_STYLE', 'space'), 227 | 'indent_size' => env('API_JSON_FORMAT_INDENT_SIZE', 2), 228 | ], 229 | 230 | ], 231 | 232 | /* 233 | * 接口频率限制 234 | */ 235 | 'rate_limits' => [ 236 | // 访问频率限制,次数/分钟 237 | 'access' => [ 238 | 'expires' => env('RATE_LIMITS_EXPIRES', 1), 239 | 'limit' => env('RATE_LIMITS', 60), 240 | ], 241 | // 登录相关,次数/分钟 242 | 'sign' => [ 243 | 'expires' => env('SIGN_RATE_LIMITS_EXPIRES', 1), 244 | 'limit' => env('SIGN_RATE_LIMITS', 10), 245 | ], 246 | ], 247 | 248 | ]; 249 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'Laravel'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | your application so that it is used when running Artisan tasks. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. We have gone 64 | | ahead and set this to a sensible default for you out of the box. 65 | | 66 | */ 67 | 68 | 'timezone' => 'Asia/Shanghai', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by the translation service provider. You are free to set this value 77 | | to any of the locales which will be supported by the application. 78 | | 79 | */ 80 | 81 | 'locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Application Fallback Locale 86 | |-------------------------------------------------------------------------- 87 | | 88 | | The fallback locale determines the locale to use when the current one 89 | | is not available. You may change the value to correspond to any of 90 | | the language folders that are provided through your application. 91 | | 92 | */ 93 | 94 | 'fallback_locale' => 'en', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Faker Locale 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This locale will be used by the Faker PHP library when generating fake 102 | | data for your database seeds. For example, this will be used to get 103 | | localized telephone numbers, street address information and more. 104 | | 105 | */ 106 | 107 | 'faker_locale' => 'en_US', 108 | 109 | /* 110 | |-------------------------------------------------------------------------- 111 | | Encryption Key 112 | |-------------------------------------------------------------------------- 113 | | 114 | | This key is used by the Illuminate encrypter service and should be set 115 | | to a random, 32 character string, otherwise these encrypted strings 116 | | will not be safe. Please do this before deploying an application! 117 | | 118 | */ 119 | 120 | 'key' => env('APP_KEY'), 121 | 122 | 'cipher' => 'AES-256-CBC', 123 | 124 | /* 125 | |-------------------------------------------------------------------------- 126 | | Autoloaded Service Providers 127 | |-------------------------------------------------------------------------- 128 | | 129 | | The service providers listed here will be automatically loaded on the 130 | | request to your application. Feel free to add your own services to 131 | | this array to grant expanded functionality to your applications. 132 | | 133 | */ 134 | 135 | 'providers' => [ 136 | 137 | /* 138 | * Laravel Framework Service Providers... 139 | */ 140 | Illuminate\Auth\AuthServiceProvider::class, 141 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 142 | Illuminate\Bus\BusServiceProvider::class, 143 | Illuminate\Cache\CacheServiceProvider::class, 144 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 145 | Illuminate\Cookie\CookieServiceProvider::class, 146 | Illuminate\Database\DatabaseServiceProvider::class, 147 | Illuminate\Encryption\EncryptionServiceProvider::class, 148 | Illuminate\Filesystem\FilesystemServiceProvider::class, 149 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 150 | Illuminate\Hashing\HashServiceProvider::class, 151 | Illuminate\Mail\MailServiceProvider::class, 152 | Illuminate\Notifications\NotificationServiceProvider::class, 153 | Illuminate\Pagination\PaginationServiceProvider::class, 154 | Illuminate\Pipeline\PipelineServiceProvider::class, 155 | Illuminate\Queue\QueueServiceProvider::class, 156 | Illuminate\Redis\RedisServiceProvider::class, 157 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 158 | Illuminate\Session\SessionServiceProvider::class, 159 | Illuminate\Translation\TranslationServiceProvider::class, 160 | Illuminate\Validation\ValidationServiceProvider::class, 161 | Illuminate\View\ViewServiceProvider::class, 162 | 163 | /* 164 | * Package Service Providers... 165 | */ 166 | 167 | /* 168 | * Application Service Providers... 169 | */ 170 | App\Providers\AppServiceProvider::class, 171 | App\Providers\AuthServiceProvider::class, 172 | // App\Providers\BroadcastServiceProvider::class, 173 | App\Providers\EventServiceProvider::class, 174 | App\Providers\RouteServiceProvider::class, 175 | Intervention\Image\ImageServiceProvider::class, 176 | 177 | ], 178 | 179 | /* 180 | |-------------------------------------------------------------------------- 181 | | Class Aliases 182 | |-------------------------------------------------------------------------- 183 | | 184 | | This array of class aliases will be registered when this application 185 | | is started. However, feel free to register as many as you wish as 186 | | the aliases are "lazy" loaded so they don't hinder performance. 187 | | 188 | */ 189 | 190 | 'aliases' => [ 191 | 192 | 'App' => Illuminate\Support\Facades\App::class, 193 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 194 | 'Auth' => Illuminate\Support\Facades\Auth::class, 195 | 'Blade' => Illuminate\Support\Facades\Blade::class, 196 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 197 | 'Bus' => Illuminate\Support\Facades\Bus::class, 198 | 'Cache' => Illuminate\Support\Facades\Cache::class, 199 | 'Config' => Illuminate\Support\Facades\Config::class, 200 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 201 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 202 | 'DB' => Illuminate\Support\Facades\DB::class, 203 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 204 | 'Event' => Illuminate\Support\Facades\Event::class, 205 | 'File' => Illuminate\Support\Facades\File::class, 206 | 'Gate' => Illuminate\Support\Facades\Gate::class, 207 | 'Hash' => Illuminate\Support\Facades\Hash::class, 208 | 'Lang' => Illuminate\Support\Facades\Lang::class, 209 | 'Log' => Illuminate\Support\Facades\Log::class, 210 | 'Mail' => Illuminate\Support\Facades\Mail::class, 211 | 'Notification' => Illuminate\Support\Facades\Notification::class, 212 | 'Password' => Illuminate\Support\Facades\Password::class, 213 | 'Queue' => Illuminate\Support\Facades\Queue::class, 214 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 215 | 'Redis' => Illuminate\Support\Facades\Redis::class, 216 | 'Request' => Illuminate\Support\Facades\Request::class, 217 | 'Response' => Illuminate\Support\Facades\Response::class, 218 | 'Route' => Illuminate\Support\Facades\Route::class, 219 | 'Schema' => Illuminate\Support\Facades\Schema::class, 220 | 'Session' => Illuminate\Support\Facades\Session::class, 221 | 'Storage' => Illuminate\Support\Facades\Storage::class, 222 | 'URL' => Illuminate\Support\Facades\URL::class, 223 | 'Validator' => Illuminate\Support\Facades\Validator::class, 224 | 'View' => Illuminate\Support\Facades\View::class, 225 | 'Image' => Intervention\Image\Facades\Image::class, 226 | 227 | 228 | ], 229 | 230 | ]; 231 | --------------------------------------------------------------------------------