├── public ├── favicon.ico ├── robots.txt ├── mix-manifest.json ├── vendor │ └── telescope │ │ ├── favicon.ico │ │ └── mix-manifest.json ├── .htaccess ├── index.php └── svg │ ├── 404.svg │ └── 503.svg ├── storage ├── laravels.pid ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore ├── debugbar │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── database ├── .gitignore ├── factories │ ├── PageFactory.php │ ├── CommentFactory.php │ ├── PostFactory.php │ └── UserFactory.php ├── seeds │ ├── PagesTableSeeder.php │ ├── CommentsTableSeeder.php │ ├── UsersTableSeeder.php │ ├── PostsTableSeeder.php │ └── DatabaseSeeder.php └── migrations │ ├── 2018_11_30_031547_alter_posts_add_deleted_at.php │ ├── 2018_12_03_025516_alter_users_add_settings.php │ ├── 2018_12_06_031107_create_tags_table.php │ ├── 2018_12_03_014531_alter_users_add_card_no.php │ ├── 2018_12_04_025704_alter_posts_add_type.php │ ├── 2018_12_09_020359_alter_comments_add_status.php │ ├── 2019_01_08_193205_alter_users_add_point.php │ ├── 2018_12_04_022427_alter_posts_add_status.php │ ├── 2018_11_23_013950_alter_users_add_nickname.php │ ├── 2018_12_07_085904_create_images_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2018_12_07_071838_create_countries_table.php │ ├── 2018_12_07_072241_alter_users_add_country_id.php │ ├── 2018_12_06_031407_create_post_tags_table.php │ ├── 2018_12_07_134704_create_taggables_table.php │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2018_12_17_110823_create_admins_table.php │ ├── 2019_01_08_195432_create_point_logs_table.php │ ├── 2018_12_07_104431_create_comments_table.php │ ├── 2018_12_07_105229_create_pages_table.php │ ├── 2018_11_28_021221_create_posts_table.php │ └── 2018_12_06_005806_create_user_profiles_table.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── resources ├── views │ ├── user │ │ ├── profile.php │ │ └── index.blade.php │ ├── page │ │ ├── style.css │ │ └── show.blade.php │ ├── components │ │ └── alert.blade.php │ ├── welcome.blade.php │ ├── post │ │ └── index.blade.php │ ├── home.blade.php │ ├── admin │ │ ├── home.blade.php │ │ ├── login.blade.php │ │ └── register.blade.php │ ├── auth │ │ ├── verify.blade.php │ │ ├── passwords │ │ │ ├── email.blade.php │ │ │ └── reset.blade.php │ │ ├── login.blade.php │ │ └── register.blade.php │ ├── request │ │ └── form.blade.php │ └── layouts │ │ ├── app.blade.php │ │ └── admin.blade.php ├── sass │ ├── app.scss │ └── _variables.scss ├── lang │ └── en │ │ ├── pagination.php │ │ ├── auth.php │ │ └── passwords.php └── js │ ├── components │ ├── ExampleComponent.vue │ ├── FileUploadComponent.vue │ ├── WelcomeComponent.vue │ ├── PaginationComponent.vue │ └── passport │ │ └── AuthorizedClients.vue │ ├── app.js │ └── bootstrap.js ├── README.md ├── .gitattributes ├── tests ├── TestCase.php ├── Unit │ ├── ExampleTest.php │ └── UserTest.php ├── Feature │ └── ExampleTest.php └── CreatesApplication.php ├── .gitignore ├── app ├── Image.php ├── Contracts │ ├── PusherSdkInterface.php │ ├── BillerInterface.php │ ├── UserRepositoryInterface.php │ ├── BillingNotifierInterface.php │ ├── EventPusherInterface.php │ └── OrderRepositoryInterface.php ├── Models │ └── Task.php ├── Country.php ├── Extensions │ ├── CustomRequest.php │ ├── MongoHandler.php │ ├── MongoStore.php │ └── EloquentUserProvider.php ├── PostTag.php ├── UserProfile.php ├── Page.php ├── Http │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ ├── VerifyCsrfToken.php │ │ ├── RedirectIfAuthenticated.php │ │ └── Authenticate.php │ ├── Controllers │ │ ├── Controller.php │ │ ├── AdminController.php │ │ ├── HomeController.php │ │ ├── Admin │ │ │ ├── LoginController.php │ │ │ └── RegisterController.php │ │ ├── TaskController.php │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── ResetPasswordController.php │ │ │ ├── VerificationController.php │ │ │ ├── RegisterController.php │ │ │ └── LoginController.php │ │ ├── RequestController.php │ │ └── PostController.php │ ├── Requests │ │ └── SubmitFormRequest.php │ └── Kernel.php ├── Scopes │ └── EmailVerifiedAtScope.php ├── Tag.php ├── Services │ ├── SmsBillingNotifier.php │ ├── EmailBillingNotifier.php │ ├── PusherEventPusher.php │ └── StripeBiller.php ├── Repositories │ ├── UserRepository.php │ └── DummyOrderRepository.php ├── Providers │ ├── EventPusherServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── RouteServiceProvider.php │ └── TelescopeServiceProvider.php ├── PointLog.php ├── Comment.php ├── Admin.php ├── Rules │ └── SensitiveWordRule.php ├── Observers │ └── UserObserver.php ├── Events │ ├── UserDeleted.php │ └── UserDeleting.php ├── Console │ ├── Kernel.php │ └── Commands │ │ └── WelcomeMessage.php ├── Exceptions │ └── Handler.php ├── Post.php ├── User.php └── Listeners │ └── UserEventSubscriber.php ├── .editorconfig ├── bin ├── laravels └── fswatch ├── routes ├── channels.php ├── console.php └── api.php ├── webpack.mix.js ├── server.php ├── .env.example ├── package.json ├── config ├── view.php ├── services.php ├── hashing.php ├── broadcasting.php ├── filesystems.php ├── logging.php ├── queue.php ├── cache.php ├── laravels.php ├── auth.php ├── telescope.php └── mail.php ├── phpunit.xml ├── artisan └── composer.json /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/laravels.pid: -------------------------------------------------------------------------------- 1 | 209 -------------------------------------------------------------------------------- /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/debugbar/.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 | -------------------------------------------------------------------------------- /resources/views/user/profile.php: -------------------------------------------------------------------------------- 1 | 用户ID: 2 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /resources/views/page/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: gray; 3 | } -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-tutorial 2 | [Laravel 从入门到精通系列教程源码](https://laravelacademy.org/laravel-tutorial-5_7) 3 | -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } 5 | -------------------------------------------------------------------------------- /resources/views/page/show.blade.php: -------------------------------------------------------------------------------- 1 | 页面ID: {{ $id }} 2 |
3 | By {{ $siteName }} -------------------------------------------------------------------------------- /public/vendor/telescope/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-tutorial-code/HEAD/public/vendor/telescope/favicon.ico -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /resources/views/user/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
{{ $title }}
3 | {{ $slot }} 4 | 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /public/vendor/telescope/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/app.js": "/app.js?id=cdb69d8b0c9f88e86c10", 3 | "/app.css": "/app.css?id=0c1e654d28f1c73326c1", 4 | "/app-dark.css": "/app-dark.css?id=13df33880547628477b2" 5 | } -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | morphTo(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/Contracts/PusherSdkInterface.php: -------------------------------------------------------------------------------- 1 | hasManyThrough(Post::class, User::class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.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/Contracts/BillerInterface.php: -------------------------------------------------------------------------------- 1 | 'array' 11 | ]; 12 | 13 | public function user() 14 | { 15 | return $this->belongsTo(User::class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /database/factories/PageFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Page::class, function (Faker $faker) { 6 | return [ 7 | 'title' => $faker->title, 8 | 'slug' => $faker->slug, 9 | 'content' => $faker->text, 10 | 'user_id' => mt_rand(1, 15) 11 | ]; 12 | }); 13 | -------------------------------------------------------------------------------- /database/seeds/PagesTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /database/seeds/CommentsTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/Page.php: -------------------------------------------------------------------------------- 1 | morphMany(Comment::class, 'commentable'); 12 | } 13 | 14 | public function tags() 15 | { 16 | return $this->morphToMany(Tag::class, 'taggable'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /bin/laravels: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run($input, $output); 11 | exit($code); -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Scopes/EmailVerifiedAtScope.php: -------------------------------------------------------------------------------- 1 | whereNotNull('email_verified_at'); 13 | } 14 | } -------------------------------------------------------------------------------- /database/factories/CommentFactory.php: -------------------------------------------------------------------------------- 1 | define(App\Comment::class, function (Faker $faker) { 6 | return [ 7 | 'content' => $faker->paragraph, 8 | 'user_id' => mt_rand(1, 15), 9 | 'commentable_id' => mt_rand(1, 30), 10 | 'commentable_type' => $faker->randomElement([\App\Post::class, \App\Page::class]) 11 | ]; 12 | }); 13 | -------------------------------------------------------------------------------- /app/Tag.php: -------------------------------------------------------------------------------- 1 | morphedByMany(Post::class, 'taggable'); 14 | } 15 | 16 | public function pages() 17 | { 18 | return $this->morphedByMany(Page::class, 'taggable'); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Services/SmsBillingNotifier.php: -------------------------------------------------------------------------------- 1 | toArray(); 20 | } 21 | } -------------------------------------------------------------------------------- /app/Providers/EventPusherServiceProvider.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Services/PusherEventPusher.php: -------------------------------------------------------------------------------- 1 | pusher = $pusher; 12 | } 13 | 14 | public function push($message, array $data = array()) 15 | { 16 | // 通过 Pusher SDK 推送消息 17 | } 18 | } -------------------------------------------------------------------------------- /app/Repositories/DummyOrderRepository.php: -------------------------------------------------------------------------------- 1 | 30, 16 | self::OPT_EMAIL_VERIFY => 20, 17 | self::OPT_USER_LOGIN => 5 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /database/factories/PostFactory.php: -------------------------------------------------------------------------------- 1 | define(\App\Post::class, function (Faker $faker) { 6 | return [ 7 | 'title' => $faker->title, 8 | 'content' => $faker->text, 9 | 'user_id' => mt_rand(1, 15), 10 | 'views' => $faker->randomDigit 11 | ]; 12 | }); 13 | 14 | $factory->define(\App\Tag::class, function (Faker $faker) { 15 | return [ 16 | 'name' => $faker->unique()->word 17 | ]; 18 | }); -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/Comment.php: -------------------------------------------------------------------------------- 1 | morphTo(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /resources/views/post/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Laravel分页组件 9 | 10 | 11 | 12 | 13 |
14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | middleware('auth:admin'); 17 | } 18 | 19 | /** 20 | * Show the application dashboard. 21 | * 22 | * @return \Illuminate\Http\Response 23 | */ 24 | public function index() 25 | { 26 | return view('admin.home'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /app/Admin.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 18 | } 19 | 20 | /** 21 | * Show the application dashboard. 22 | * 23 | * @return \Illuminate\Http\Response 24 | */ 25 | public function index() 26 | { 27 | return view('home'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /database/seeds/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | insert([ 16 | 'name' => str_random(10), 17 | 'email' => str_random(10).'@gmail.com', 18 | 'password' => bcrypt('secret'), 19 | ]);*/ 20 | 21 | //factory(\App\User::class, 15)->create(); 22 | factory(\App\UserProfile::class, 5)->create(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /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/Services/StripeBiller.php: -------------------------------------------------------------------------------- 1 | notifier = $notifier; 22 | } 23 | 24 | public function bill(array $user, $amount) 25 | { 26 | // Bill the user via Stripe... 27 | $this->notifier->notify($user, $amount); 28 | } 29 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/seeds/PostsTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | factory(\App\Tag::class, 60)->create(); 17 | $post_tags_data = []; 18 | for ($i = 0; $i < 30; $i++) { 19 | $post_tags_data[] = [ 20 | 'tag_id' => mt_rand(1, 60), 21 | 'post_id' => mt_rand(1, 30), 22 | ]; 23 | } 24 | DB::table('post_tags')->insert($post_tags_data); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/views/home.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
Dashboard
9 | 10 |
11 | @if (session('status')) 12 | 15 | @endif 16 | 17 | You are logged in! 18 |
19 |
20 |
21 |
22 |
23 | @endsection 24 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(UsersTableSeeder::class); 15 | 16 | $taggables_data = []; 17 | for ($i = 0; $i < 30; $i++) { 18 | $taggables_data[] = [ 19 | 'tag_id' => mt_rand(1, 60), 20 | 'taggable_id' => mt_rand(1, 30), 21 | 'taggable_type' => array_random([\App\Post::class, \App\Page::class]) 22 | ]; 23 | } 24 | DB::table('taggables')->insert($taggables_data); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/Unit/UserTest.php: -------------------------------------------------------------------------------- 1 | shouldReceive('all')->once()->andReturn(['学院君']); 20 | $this->instance(UserRepositoryInterface::class, $repository); 21 | $response = $this->get('/users'); 22 | 23 | $response->assertStatus(200); 24 | $response->assertViewHas('users', ['学院君']); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/views/admin/home.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.admin') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
Admin Dashboard
9 | 10 |
11 | @if (session('status')) 12 | 15 | @endif 16 | 17 | You are logged in the admin dashboard! 18 |
19 |
20 |
21 |
22 |
23 | @endsection 24 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | if ($guard == 'admin') { 22 | return redirect('/admin'); 23 | } 24 | return redirect('/home'); 25 | } 26 | 27 | return $next($request); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /database/migrations/2018_11_30_031547_alter_posts_add_deleted_at.php: -------------------------------------------------------------------------------- 1 | softDeletes(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('posts', function (Blueprint $table) { 29 | $table->dropColumn('deleted_at'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_03_025516_alter_users_add_settings.php: -------------------------------------------------------------------------------- 1 | json('settings')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('users', function (Blueprint $table) { 29 | $table->dropColumn('settings'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_06_031107_create_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 100)->unique()->comment('标签名'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('tags'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_03_014531_alter_users_add_card_no.php: -------------------------------------------------------------------------------- 1 | string('card_no')->comment('银行卡号')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('users', function (Blueprint $table) { 29 | $table->dropColumn('card_no'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_04_025704_alter_posts_add_type.php: -------------------------------------------------------------------------------- 1 | tinyInteger('type')->unsigned()->default(1)->comment('文章类型'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('posts', function (Blueprint $table) { 29 | $table->dropColumn('type'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_09_020359_alter_comments_add_status.php: -------------------------------------------------------------------------------- 1 | tinyInteger('status')->unsigned()->default(0); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('comments', function (Blueprint $table) { 29 | $table->dropColumn('status'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2019_01_08_193205_alter_users_add_point.php: -------------------------------------------------------------------------------- 1 | integer('point')->unsigned()->default(0)->after('password'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('users', function (Blueprint $table) { 29 | $table->dropColumn('point'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_04_022427_alter_posts_add_status.php: -------------------------------------------------------------------------------- 1 | tinyInteger('status')->unsigned()->default(0)->comment('文章状态'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('posts', function (Blueprint $table) { 29 | $table->dropColumn('status'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Rules/SensitiveWordRule.php: -------------------------------------------------------------------------------- 1 | string('nickname', 100)->after('name')->nullable()->comment('用户昵称'); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | * 24 | * @return void 25 | */ 26 | public function down() 27 | { 28 | Schema::table('users', function (Blueprint $table) { 29 | $table->dropColumn('nickname'); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_07_085904_create_images_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('url')->comment('图片URL'); 19 | $table->morphs('imageable'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('images'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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/Http/Controllers/Admin/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest:admin')->except('logout'); 19 | } 20 | 21 | public function showLoginForm() 22 | { 23 | return view('admin.login'); 24 | } 25 | 26 | protected function guard() 27 | { 28 | return Auth::guard('admin'); 29 | } 30 | 31 | protected function loggedOut(Request $request) 32 | { 33 | return redirect(route('admin.login')); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Http/Controllers/TaskController.php: -------------------------------------------------------------------------------- 1 | with('tasks', Task::all()); 19 | } 20 | 21 | public function index2() 22 | { 23 | dd('tasks2'); 24 | } 25 | 26 | public function create() 27 | { 28 | 29 | } 30 | 31 | public function store(Request $request) 32 | { 33 | $task = new Task(); 34 | $task->title = $request->input('title'); 35 | $task->description = $request->input('description'); 36 | $task->save(); 37 | return redirect('task'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/migrations/2018_12_07_071838_create_countries_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name', 100)->unique(); 19 | $table->string('slug', 100)->unique(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('countries'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2018_12_07_072241_alter_users_add_country_id.php: -------------------------------------------------------------------------------- 1 | integer('country_id')->unsigned()->default(0); 18 | $table->index('country_id'); 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('country_id'); 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /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 | * Next, we will create a fresh Vue application instance and attach it to 14 | * the page. Then, you may begin adding components to this application 15 | * or customize the JavaScript scaffolding to fit your unique needs. 16 | */ 17 | 18 | Vue.component('welcome-component', require('./components/WelcomeComponent.vue')); 19 | Vue.component('fileupload-component', require('./components/FileUploadComponent.vue')); 20 | Vue.component('pagination-component', require('./components/PaginationComponent.vue')); 21 | 22 | const app = new Vue({ 23 | el: '#app' 24 | }); 25 | -------------------------------------------------------------------------------- /app/Extensions/MongoHandler.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('post_id')->unsigned()->default(0); 19 | $table->integer('tag_id')->unsigned()->default(0); 20 | $table->unique(['post_id', 'tag_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('post_tags'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2018_12_07_134704_create_taggables_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('tag_id'); 19 | $table->morphs('taggable'); 20 | $table->index('tag_id'); 21 | $table->unique(['tag_id', 'taggable_id', 'taggable_type']); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('taggables'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Observers/UserObserver.php: -------------------------------------------------------------------------------- 1 | id . ']' . $user->name); 13 | } 14 | 15 | public function creating(User $user) 16 | { 17 | Log::info('即将插入用户到数据库[' . $user->id . ']' . $user->name); 18 | } 19 | 20 | public function updating(User $user) 21 | { 22 | Log::info('即将更新用户到数据库[' . $user->id . ']' . $user->name); 23 | } 24 | 25 | public function updated(User $user) 26 | { 27 | Log::info('已经更新用户到数据库[' . $user->id . ']' . $user->name); 28 | } 29 | 30 | public function created(User $user) 31 | { 32 | Log::info('已经插入用户到数据库[' . $user->id . ']' . $user->name); 33 | } 34 | 35 | public function saved(User $user) 36 | { 37 | Log::info('已经保存用户到数据库[' . $user->id . ']' . $user->name); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 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/2018_12_17_110823_create_admins_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 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('admins'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2019_01_08_195432_create_point_logs_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('user_id')->unsigned(); 19 | $table->tinyInteger('type')->unsigned()->comment('操作类型'); 20 | $table->smallInteger('value')->comment('积分变动值'); 21 | $table->timestamps(); 22 | $table->index('user_id'); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('point_logs'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2018_12_07_104431_create_comments_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->text('content')->comment('评论内容'); 19 | $table->integer('user_id')->unsigned()->default(0); 20 | $table->morphs('commentable'); 21 | $table->index('user_id'); 22 | $table->softDeletes(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('comments'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Events/UserDeleted.php: -------------------------------------------------------------------------------- 1 | user = $user; 28 | } 29 | 30 | /** 31 | * Get the channels the event should broadcast on. 32 | * 33 | * @return \Illuminate\Broadcasting\Channel|array 34 | */ 35 | public function broadcastOn() 36 | { 37 | return new PrivateChannel('channel-name'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /resources/views/auth/verify.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Verify Your Email Address') }}
9 | 10 |
11 | @if (session('resent')) 12 | 15 | @endif 16 | 17 | {{ __('Before proceeding, please check your email for a verification link.') }} 18 | {{ __('If you did not receive the email') }}, {{ __('click here to request another') }}. 19 |
20 |
21 |
22 |
23 |
24 | @endsection 25 | -------------------------------------------------------------------------------- /app/Events/UserDeleting.php: -------------------------------------------------------------------------------- 1 | user = $user; 28 | } 29 | 30 | /** 31 | * Get the channels the event should broadcast on. 32 | * 33 | * @return \Illuminate\Broadcasting\Channel|array 34 | */ 35 | public function broadcastOn() 36 | { 37 | return new PrivateChannel('channel-name'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/migrations/2018_12_07_105229_create_pages_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('title'); 19 | $table->string('slug')->unique(); 20 | $table->text('content'); 21 | $table->integer('user_id')->unsigned()->default(0); 22 | $table->index('user_id'); 23 | $table->softDeletes(); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::dropIfExists('pages'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/migrations/2018_11_28_021221_create_posts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('title')->comment('标题'); 19 | $table->text('content')->comment('内容'); 20 | $table->integer('user_id')->unsigned()->default(0); 21 | $table->integer('views')->unsigned()->default(0)->comment('浏览数'); 22 | $table->index('user_id'); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('posts'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2018_12_06_005806_create_user_profiles_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('user_id')->unsigned()->default(0)->unique(); 19 | $table->string('bio')->nullable()->comment('个性签名'); 20 | $table->string('city')->nullable()->comment('所在城市'); 21 | $table->json('hobby')->nullable()->comment('个人爱好'); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::dropIfExists('user_profiles'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 29 | // ->hourly(); 30 | } 31 | 32 | /** 33 | * Register the commands for the application. 34 | * 35 | * @return void 36 | */ 37 | protected function commands() 38 | { 39 | $this->load(__DIR__.'/Commands'); 40 | 41 | require base_path('routes/console.php'); 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.7" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | define(App\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 | 26 | $factory->define(App\UserProfile::class, function (Faker $faker) { 27 | return [ 28 | 'user_id' => $faker->unique()->randomDigit, 29 | 'bio' => $faker->sentence, 30 | 'city' => $faker->city, 31 | 'hobby' => $faker->words, 32 | ]; 33 | }); 34 | 35 | -------------------------------------------------------------------------------- /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\User::class, 35 | 'key' => env('STRIPE_KEY'), 36 | 'secret' => env('STRIPE_SECRET'), 37 | ], 38 | 39 | ]; 40 | -------------------------------------------------------------------------------- /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/Http/Controllers/Auth/VerificationController.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 38 | $this->middleware('signed')->only('verify'); 39 | $this->middleware('throttle:6,1')->only('verify', 'resend'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | [ 23 | SendEmailVerificationNotification::class, 24 | ], 25 | ]; 26 | 27 | protected $subscribe = [ 28 | UserEventSubscriber::class 29 | ]; 30 | 31 | /** 32 | * Register any events for your application. 33 | * 34 | * @return void 35 | */ 36 | public function boot() 37 | { 38 | parent::boot(); 39 | 40 | User::observe(UserObserver::class); 41 | 42 | // 监听模型事件 43 | User::retrieved(function ($user) { 44 | Log::info('从模型中获取用户[' . $user->id . ']:' . $user->name); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | auth->guard($guard)->check()) { 31 | return $this->auth->shouldUse($guard); 32 | } 33 | } 34 | 35 | // 这里我们以 guards 传入的第一个参数为准选择跳转到的登录页面 36 | $guard = $guards[0]; 37 | if ($guard == 'admin') { 38 | $this->redirectTo = route('admin.login'); 39 | } 40 | 41 | throw new AuthenticationException( 42 | 'Unauthenticated.', $guards, $this->redirectTo ? : $this->redirectTo($request) 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | share('siteName', 'Laravel学院'); 31 | view()->share('siteUrl', 'https://laravelacademy.org'); 32 | } 33 | 34 | /** 35 | * Register any application services. 36 | * 37 | * @return void 38 | */ 39 | public function register() 40 | { 41 | if ($this->app->isLocal()) { 42 | $this->app->register(TelescopeServiceProvider::class); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/Console/Commands/WelcomeMessage.php: -------------------------------------------------------------------------------- 1 | ask('你叫什么名字'); 41 | $city = $this->choice('你来自哪个城市', [ 42 | '北京', '杭州', '深圳' 43 | ], 0); 44 | $password = $this->secret('输入密码才能执行此命令'); 45 | if ($password != '123') { 46 | $this->error('密码错误'); 47 | exit(-1); 48 | } 49 | if ($this->confirm('确定要执行此命令吗?')) { 50 | $this->info('欢迎来自' . $city . '的' . $name . '访问 Laravel 学院'); 51 | } else { 52 | exit(0); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | 20 | 21 | Artisan::command('welcome:message_simple', function () { 22 | $this->info('欢迎访问 Laravel 学院!'); 23 | })->describe('打印欢迎信息'); 24 | 25 | Artisan::command('welcome:output_table', function () { 26 | $headers = ['姓名', '城市']; 27 | $data = [ 28 | ['张三', '北京'], 29 | ['李四', '上海'] 30 | ]; 31 | $this->table($headers, $data); 32 | })->describe('打印图表'); 33 | 34 | Artisan::command('welcome:progress_bar', function () { 35 | $totalUnits = 10; 36 | $this->output->progressStart($totalUnits); 37 | 38 | $i = 0; 39 | while ($i++ < $totalUnits) { 40 | sleep(1); 41 | $this->output->progressAdvance(); 42 | } 43 | 44 | $this->output->progressFinish(); 45 | })->describe('打印图表'); -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | group(function () { 18 | Route::get('/user', function (Request $request) { 19 | $user = $request->user(); 20 | if ($user->tokenCan('all-user-info')) { 21 | // 如果用户令牌有获取所有信息权限,返回所有用户字段 22 | return $user; 23 | } 24 | // 否则返回用户名和邮箱等基本信息 25 | return ['name' => $user->name, 'email' => $user->email]; 26 | })->middleware('scope:basic-user-info,all-user-info'); 27 | Route::get('/post/{id}', function (Request $request, $id) { 28 | return \App\Post::find($id); 29 | })->middleware('scopes:get-post-info'); 30 | Route::get('/user/{id}', function ($id) { 31 | return \App\User::find($id); 32 | }); 33 | }); 34 | 35 | Route::middleware('client')->get('/test', function (Request $request) { 36 | return '欢迎访问 Laravel 学院!'; 37 | }); 38 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 20 | ]; 21 | 22 | /** 23 | * Register any authentication / authorization services. 24 | * 25 | * @return void 26 | */ 27 | public function boot() 28 | { 29 | $this->registerPolicies(); 30 | 31 | // 通过自定义的 EloquentUserProvider 覆盖系统默认的 32 | Auth::provider('eloquent', function ($app, $config) { 33 | return new EloquentUserProvider($app->make('hash'), $config['model']); 34 | }); 35 | 36 | // OAuth 相关路由 37 | Passport::routes(); 38 | 39 | // 启用隐式授权令牌 40 | Passport::enableImplicitGrant(); 41 | 42 | // 令牌作用域 43 | Passport::tokensCan([ 44 | 'basic-user-info' => '获取用户名、邮箱信息', 45 | 'all-user-info' => '获取用户所有信息', 46 | 'get-post-info' => '获取文章详细信息', 47 | ]); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/Extensions/MongoStore.php: -------------------------------------------------------------------------------- 1 | [ 29 | 'bail', 30 | 'required', 31 | 'string', 32 | 'between:2,32', 33 | new SensitiveWordRule() 34 | ], 35 | 'url' => 'sometimes|url|max:200', 36 | 'picture' => 'nullable|string', 37 | ]; 38 | } 39 | 40 | public function messages() 41 | { 42 | return [ 43 | 'title.required' => '标题字段不能为空', 44 | 'title.string' => '标题字段仅支持字符串', 45 | 'title.between' => '标题长度必须介于2-32之间', 46 | 'url.url' => 'URL格式不正确,请输入有效的URL', 47 | 'url.max' => 'URL长度不能超过200', 48 | ]; 49 | } 50 | 51 | public function attributes() 52 | { 53 | return [ 54 | 'title' => '标题', 55 | 'url' => 'URL', 56 | 'picture' => '图片' 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/Extensions/EloquentUserProvider.php: -------------------------------------------------------------------------------- 1 | createModel()->newQuery(); 27 | 28 | // 用于标识是否是第一个登录字段,如果包含多个登录字段,使用 OR 查询 29 | $flag = false; 30 | foreach ($credentials as $key => $value) { 31 | if (Str::contains($key, 'password')) { 32 | continue; 33 | } 34 | 35 | if ($flag) { 36 | $query->orWhere($key, $value); 37 | } else { 38 | $query->where($key, $value); 39 | $flag = true; 40 | } 41 | } 42 | 43 | return $query->first(); 44 | } 45 | } -------------------------------------------------------------------------------- /app/Post.php: -------------------------------------------------------------------------------- 1 | where('views', '>', '0')->orderBy('views', 'desc'); 24 | } 25 | 26 | public function scopeActive(Builder $query) 27 | { 28 | return $query->where('status', Post::ACTIVED); 29 | } 30 | 31 | public function scopeOfType(Builder $query, $type) 32 | { 33 | return $query->where('type', $type); 34 | } 35 | 36 | public function author() 37 | { 38 | return $this->belongsTo(User::class, 'user_id', 'id', 'author') 39 | ->withDefault([ 40 | 'id' => 0, 41 | 'name' => '游客用户', 42 | ]); 43 | } 44 | 45 | /*public function tags() 46 | { 47 | return $this->belongsToMany(Tag::class, 'post_tags')->using(PostTag::class); 48 | }*/ 49 | 50 | public function image() 51 | { 52 | return $this->morphOne(Image::class, 'imageable'); 53 | } 54 | 55 | public function comments() 56 | { 57 | return $this->morphMany(Comment::class, 'commentable'); 58 | } 59 | 60 | public function tags() 61 | { 62 | return $this->morphToMany(Tag::class, 'taggable'); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /resources/js/components/FileUploadComponent.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 17 | 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/views/request/form.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 表单请求 9 | 10 | 11 | 12 | 13 |
14 |
15 | @if ($errors->any()) 16 |
17 |
    18 | @foreach ($errors->all() as $error) 19 |
  • {{ $error }}
  • 20 | @endforeach 21 |
22 |
23 | @endif 24 |
25 |
26 | 27 | 28 |
29 |
30 | 31 | 32 |
33 | 34 | 35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest:admin'); 22 | } 23 | 24 | public function showRegistrationForm() 25 | { 26 | return view('admin.register'); 27 | } 28 | 29 | protected function guard() 30 | { 31 | return Auth::guard('admin'); 32 | } 33 | 34 | /** 35 | * Get a validator for an incoming registration request. 36 | * 37 | * @param array $data 38 | * @return \Illuminate\Contracts\Validation\Validator 39 | */ 40 | protected function validator(array $data) 41 | { 42 | return Validator::make($data, [ 43 | 'name' => 'required|string|max:255', 44 | 'email' => 'required|string|email|max:255|unique:users', 45 | 'password' => 'required|string|min:6|confirmed', 46 | ]); 47 | } 48 | 49 | /** 50 | * Create a new user instance after a valid registration. 51 | * 52 | * @param array $data 53 | * @return \App\User 54 | */ 55 | protected function create(array $data) 56 | { 57 | return Admin::create([ 58 | 'name' => $data['name'], 59 | 'email' => $data['email'], 60 | 'password' => Hash::make($data['password']), 61 | ]); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 41 | 42 | $this->mapWebRoutes(); 43 | 44 | // 45 | } 46 | 47 | /** 48 | * Define the "web" routes for the application. 49 | * 50 | * These routes all receive session state, CSRF protection, etc. 51 | * 52 | * @return void 53 | */ 54 | protected function mapWebRoutes() 55 | { 56 | Route::middleware('web') 57 | ->namespace($this->namespace) 58 | ->group(base_path('routes/web.php')); 59 | } 60 | 61 | /** 62 | * Define the "api" routes for the application. 63 | * 64 | * These routes are typically stateless. 65 | * 66 | * @return void 67 | */ 68 | protected function mapApiRoutes() 69 | { 70 | Route::prefix('api') 71 | ->middleware('api') 72 | ->namespace($this->namespace) 73 | ->group(base_path('routes/api.php')); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/Providers/TelescopeServiceProvider.php: -------------------------------------------------------------------------------- 1 | hideSensitiveRequestDetails(); 22 | 23 | Telescope::filter(function (IncomingEntry $entry) { 24 | if ($this->app->isLocal()) { 25 | return true; 26 | } 27 | 28 | return $entry->isReportableException() || 29 | $entry->isFailedJob() || 30 | $entry->isScheduledTask() || 31 | $entry->hasMonitoredTag(); 32 | }); 33 | } 34 | 35 | /** 36 | * Prevent sensitive request details from being logged by Telescope. 37 | * 38 | * @return void 39 | */ 40 | protected function hideSensitiveRequestDetails() 41 | { 42 | if ($this->app->isLocal()) { 43 | return; 44 | } 45 | 46 | Telescope::hideRequestParameters(['_token']); 47 | 48 | Telescope::hideRequestHeaders([ 49 | 'cookie', 50 | 'x-csrf-token', 51 | 'x-xsrf-token', 52 | ]); 53 | } 54 | 55 | /** 56 | * Register the Telescope gate. 57 | * 58 | * This gate determines who can access Telescope in non-local environments. 59 | * 60 | * @return void 61 | */ 62 | protected function gate() 63 | { 64 | Gate::define('viewTelescope', function ($user) { 65 | return in_array($user->email, [ 66 | // 67 | ]); 68 | }); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | window.Popper = require('popper.js').default; 4 | 5 | /** 6 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 7 | * for JavaScript based Bootstrap features such as modals and tabs. This 8 | * code may be modified to fit the specific needs of your application. 9 | */ 10 | 11 | try { 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 | -------------------------------------------------------------------------------- /resources/js/components/WelcomeComponent.vue: -------------------------------------------------------------------------------- 1 | 53 | 54 | 77 | 78 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Reset Password') }}
9 | 10 |
11 | @if (session('status')) 12 | 15 | @endif 16 | 17 |
18 | @csrf 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | @if ($errors->has('email')) 27 | 28 | {{ $errors->first('email') }} 29 | 30 | @endif 31 |
32 |
33 | 34 |
35 |
36 | 39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | @endsection 48 | -------------------------------------------------------------------------------- /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 | "barryvdh/laravel-ide-helper": "^2.5", 10 | "doctrine/dbal": "^2.8", 11 | "fideloper/proxy": "^4.0", 12 | "garygreen/pretty-routes": "^1.0", 13 | "hhxsv5/laravel-s": "~3.3", 14 | "laravel/framework": "5.7.*", 15 | "laravel/passport": "^7.0", 16 | "laravel/tinker": "^1.0", 17 | "predis/predis": "^1.1", 18 | "pusher/pusher-php-server": "^3.2" 19 | }, 20 | "require-dev": { 21 | "beyondcode/laravel-dump-server": "^1.0", 22 | "filp/whoops": "^2.0", 23 | "fzaninotto/faker": "^1.4", 24 | "laravel/telescope": "^1.0", 25 | "mockery/mockery": "^1.0", 26 | "nunomaduro/collision": "^2.0", 27 | "phpunit/phpunit": "^7.0" 28 | }, 29 | "autoload": { 30 | "classmap": [ 31 | "database/seeds", 32 | "database/factories" 33 | ], 34 | "psr-4": { 35 | "App\\": "app/" 36 | } 37 | }, 38 | "autoload-dev": { 39 | "psr-4": { 40 | "Tests\\": "tests/" 41 | } 42 | }, 43 | "extra": { 44 | "laravel": { 45 | "dont-discover": [ 46 | ] 47 | } 48 | }, 49 | "scripts": { 50 | "post-root-package-install": [ 51 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 52 | ], 53 | "post-create-project-cmd": [ 54 | "@php artisan key:generate --ansi" 55 | ], 56 | "post-autoload-dump": [ 57 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 58 | "@php artisan package:discover --ansi" 59 | ] 60 | }, 61 | "config": { 62 | "preferred-install": "dist", 63 | "sort-packages": true, 64 | "optimize-autoloader": true 65 | }, 66 | "minimum-stability": "dev", 67 | "prefer-stable": true 68 | } 69 | -------------------------------------------------------------------------------- /app/Http/Controllers/RequestController.php: -------------------------------------------------------------------------------- 1 | validate($request, [ 25 | 'picture' => 'bail|required|image|mimes:jpg,png,jpeg|max:1024' 26 | ],[ 27 | 'picture.required' => '请选择要上传的图片', 28 | 'picture.image' => '只支持上传图片', 29 | 'picture.mimes' => '只支持上传jpg/png/jpeg格式图片', 30 | 'picture.max' => '上传图片超过最大尺寸限制(1M)' 31 | ]); 32 | 33 | if ($request->hasFile('picture')) { 34 | $picture = $request->file('picture'); 35 | if (!$picture->isValid()) { 36 | abort(400, '无效的上传文件'); 37 | } 38 | // 文件扩展名 39 | $extension = $picture->getClientOriginalExtension(); 40 | // 文件名 41 | $fileName = $picture->getClientOriginalName(); 42 | // 生成新的统一格式的文件名 43 | $newFileName = md5($fileName . time() . mt_rand(1, 10000)) . '.' . $extension; 44 | // 图片保存路径 45 | $savePath = 'images/' . $newFileName; 46 | // Web 访问路径 47 | $webPath = '/storage/' . $savePath; 48 | // 将文件保存到 storage/app/public/images 目录下,先判断同名文件是否已经存在 49 | if (Storage::disk('public')->has($savePath)) { 50 | return response()->json(['path' => $webPath]); 51 | } 52 | if ($picture->storePubliclyAs('images', $newFileName, ['disk' => 'public'])) { 53 | return response()->json(['path' => $webPath]); 54 | } 55 | abort(500, '文件上传失败'); 56 | } else { 57 | abort(400, '请选择要上传的文件'); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisterController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => 'required|string|max:255', 53 | 'email' => 'required|string|email|max:255|unique:users', 54 | 'password' => 'required|string|min:6|confirmed', 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return \App\User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => Hash::make($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 50 | } 51 | 52 | /*public function username() 53 | { 54 | return 'name'; 55 | }*/ 56 | 57 | // 将支持的登录字段都传递到 UserProvider 进行查询 58 | public function credentials(Request $request) 59 | { 60 | $credentials = $request->only($this->username(), 'password'); 61 | foreach ($this->supportFields as $field) { 62 | if (empty($credentials[$field])) { 63 | $credentials[$field] = $credentials[$this->username()]; 64 | } 65 | } 66 | return $credentials; 67 | } 68 | 69 | public function personal() 70 | { 71 | $user = User::where('name', '学院君')->first(); 72 | $token = $user->createToken('Users')->accessToken; 73 | dd($token); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /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/User.php: -------------------------------------------------------------------------------- 1 | 'array' 27 | ]; 28 | 29 | /** 30 | * The attributes that should be hidden for arrays. 31 | * 32 | * @var array 33 | */ 34 | protected $hidden = [ 35 | 'password', 'remember_token', 36 | ]; 37 | 38 | protected $dispatchesEvents = [ 39 | 'deleting' => UserDeleting::class, 40 | 'deleted' => UserDeleted::class 41 | ]; 42 | 43 | public function getDisplayNameAttribute() 44 | { 45 | return $this->nickname ? $this->nickname : $this->name; 46 | } 47 | 48 | public function setCardNoAttribute($value) 49 | { 50 | $value = str_replace(' ', '', $value); // 将所有空格去掉 51 | $this->attributes['card_no'] = encrypt($value); 52 | } 53 | 54 | public function getCardNumAttribute() 55 | { 56 | if (!$this->card_no) { 57 | return ''; 58 | } 59 | $cardNo = decrypt($this->card_no); 60 | $lastFour = mb_substr($cardNo, -4); 61 | return '**** **** **** ' . $lastFour; 62 | } 63 | 64 | protected static function boot() 65 | { 66 | parent::boot(); 67 | 68 | //static::addGlobalScope(new EmailVerifiedAtScope()); 69 | /*static::addGlobalScope('email_verified_at_scope', function (Builder $builder) { 70 | return $builder->whereNotNull('email_verified_at'); 71 | });*/ 72 | } 73 | 74 | public function profile() 75 | { 76 | return $this->hasOne(UserProfile::class); 77 | } 78 | 79 | public function posts() 80 | { 81 | return $this->hasMany(Post::class); 82 | } 83 | 84 | public function image() 85 | { 86 | return $this->morphOne(Image::class, 'imageable'); 87 | } 88 | 89 | public function pointLogs() 90 | { 91 | return $this->hasMany(PointLog::class); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/Http/Controllers/PostController.php: -------------------------------------------------------------------------------- 1 | onEachSide(2)->withPath(url('post')); 91 | // 处理页码及对应分页URL(页码过多,部分页码省略) 92 | $window = UrlWindow::make($posts); 93 | $pages = array_filter([ 94 | $window['first'], 95 | is_array($window['slider']) ? '...' : null, 96 | $window['slider'], 97 | is_array($window['last']) ? '...' : null, 98 | $window['last'], 99 | ]); 100 | return response()->json([ 101 | 'paginator' => $posts, 102 | 'elements' => $pages 103 | ]); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /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' => ['single'], 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' => 7, 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' => '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 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Reset Password') }}
9 | 10 |
11 |
12 | @csrf 13 | 14 | 15 | 16 |
17 | 18 | 19 |
20 | 21 | 22 | @if ($errors->has('email')) 23 | 24 | {{ $errors->first('email') }} 25 | 26 | @endif 27 |
28 |
29 | 30 |
31 | 32 | 33 |
34 | 35 | 36 | @if ($errors->has('password')) 37 | 38 | {{ $errors->first('password') }} 39 | 40 | @endif 41 |
42 |
43 | 44 |
45 | 46 | 47 |
48 | 49 |
50 |
51 | 52 |
53 |
54 | 57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | @endsection 66 | -------------------------------------------------------------------------------- /resources/views/admin/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.admin') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Admin Login') }}
9 | 10 |
11 |
12 | @csrf 13 | 14 |
15 | 16 | 17 |
18 | 19 | 20 | @if ($errors->has('email')) 21 | 22 | {{ $errors->first('email') }} 23 | 24 | @endif 25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 | 34 | @if ($errors->has('password')) 35 | 36 | {{ $errors->first('password') }} 37 | 38 | @endif 39 |
40 |
41 | 42 |
43 |
44 |
45 | 46 | 47 | 50 |
51 |
52 |
53 | 54 |
55 |
56 | 59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | @endsection 68 | -------------------------------------------------------------------------------- /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 | \Laravel\Passport\Http\Middleware\CreateFreshApiToken::class, 39 | ], 40 | 41 | 'api' => [ 42 | 'throttle:60,1', 43 | 'bindings', 44 | ], 45 | ]; 46 | 47 | /** 48 | * The application's route middleware. 49 | * 50 | * These middleware may be assigned to groups or used individually. 51 | * 52 | * @var array 53 | */ 54 | protected $routeMiddleware = [ 55 | 'auth' => \App\Http\Middleware\Authenticate::class, 56 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 57 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 58 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 61 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 62 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 63 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 64 | 'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class, 65 | 'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class, 66 | 'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class, 67 | ]; 68 | 69 | /** 70 | * The priority-sorted list of middleware. 71 | * 72 | * This forces the listed middleware to always be in the given order. 73 | * 74 | * @var array 75 | */ 76 | protected $middlewarePriority = [ 77 | \Illuminate\Session\Middleware\StartSession::class, 78 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 79 | \App\Http\Middleware\Authenticate::class, 80 | \Illuminate\Session\Middleware\AuthenticateSession::class, 81 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 82 | \Illuminate\Auth\Middleware\Authorize::class, 83 | ]; 84 | } 85 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Login') }}
9 | 10 |
11 |
12 | @csrf 13 | 14 |
15 | 16 | 17 |
18 | 19 | 20 | @if ($errors->has('email')) 21 | 22 | {{ $errors->first('email') }} 23 | 24 | @endif 25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 | 34 | @if ($errors->has('password')) 35 | 36 | {{ $errors->first('password') }} 37 | 38 | @endif 39 |
40 |
41 | 42 |
43 |
44 |
45 | 46 | 47 | 50 |
51 |
52 |
53 | 54 |
55 |
56 | 59 | 60 | 61 | {{ __('Forgot Your Password?') }} 62 | 63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | @endsection 72 | -------------------------------------------------------------------------------- /resources/js/components/PaginationComponent.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 54 | 55 | -------------------------------------------------------------------------------- /config/laravels.php: -------------------------------------------------------------------------------- 1 | env('LARAVELS_LISTEN_IP', '127.0.0.1'), 8 | 'listen_port' => env('LARAVELS_LISTEN_PORT', 5200), 9 | 'socket_type' => defined('SWOOLE_SOCK_TCP') ? \SWOOLE_SOCK_TCP : 1, 10 | 'enable_coroutine_runtime' => false, 11 | 'server' => env('LARAVELS_SERVER', 'LaravelS'), 12 | 'handle_static' => env('LARAVELS_HANDLE_STATIC', false), 13 | 'laravel_base_path' => env('LARAVEL_BASE_PATH', base_path()), 14 | 'inotify_reload' => [ 15 | 'enable' => env('LARAVELS_INOTIFY_RELOAD', false), 16 | 'watch_path' => base_path(), 17 | 'file_types' => ['.php'], 18 | 'excluded_dirs' => [], 19 | 'log' => true, 20 | ], 21 | 'event_handlers' => [ 22 | ], 23 | 'websocket' => [ 24 | 'enable' => false, 25 | //'handler' => XxxWebSocketHandler::class, 26 | ], 27 | 'sockets' => [ 28 | ], 29 | 'processes' => [ 30 | ], 31 | 'timer' => [ 32 | 'enable' => false, 33 | 'jobs' => [ 34 | // Enable LaravelScheduleJob to run `php artisan schedule:run` every 1 minute, replace Linux Crontab 35 | //\Hhxsv5\LaravelS\Illuminate\LaravelScheduleJob::class, 36 | // Two ways to configure parameters: 37 | // [\App\Jobs\XxxCronJob::class, [1000, true]], // Pass in parameters when registering 38 | // \App\Jobs\XxxCronJob::class, // Override the corresponding method to return the configuration 39 | ], 40 | ], 41 | 'events' => [ 42 | ], 43 | 'swoole_tables' => [ 44 | ], 45 | 'register_providers' => [ 46 | ], 47 | 'swoole' => [ 48 | 'daemonize' => env('LARAVELS_DAEMONIZE', false), 49 | 'dispatch_mode' => 2, 50 | 'reactor_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 4, 51 | 'worker_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 8, 52 | //'task_worker_num' => function_exists('\swoole_cpu_num') ? \swoole_cpu_num() * 2 : 8, 53 | 'task_ipc_mode' => 1, 54 | 'task_max_request' => 5000, 55 | 'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp', 56 | 'max_request' => 3000, 57 | 'open_tcp_nodelay' => true, 58 | 'pid_file' => storage_path('laravels.pid'), 59 | 'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))), 60 | 'log_level' => 4, 61 | 'document_root' => base_path('public'), 62 | 'buffer_output_size' => 2 * 1024 * 1024, 63 | 'socket_buffer_size' => 128 * 1024 * 1024, 64 | 'package_max_length' => 4 * 1024 * 1024, 65 | 'reload_async' => true, 66 | 'max_wait_time' => 60, 67 | 'enable_reuse_port' => true, 68 | 'enable_coroutine' => false, 69 | 'http_compression' => false, 70 | 71 | /** 72 | * More settings of Swoole 73 | * @see https://wiki.swoole.com/wiki/page/274.html Chinese 74 | * @see https://www.swoole.co.uk/docs/modules/swoole-server/configuration English 75 | */ 76 | ], 77 | ]; 78 | -------------------------------------------------------------------------------- /resources/js/components/passport/AuthorizedClients.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 52 | 53 | 108 | -------------------------------------------------------------------------------- /resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{ config('app.name', 'Laravel') }} 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 74 | 75 |
76 | @yield('content') 77 |
78 |
79 | 80 | 81 | -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Register') }}
9 | 10 |
11 |
12 | @csrf 13 | 14 |
15 | 16 | 17 |
18 | 19 | 20 | @if ($errors->has('name')) 21 | 22 | {{ $errors->first('name') }} 23 | 24 | @endif 25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 | 34 | @if ($errors->has('email')) 35 | 36 | {{ $errors->first('email') }} 37 | 38 | @endif 39 |
40 |
41 | 42 |
43 | 44 | 45 |
46 | 47 | 48 | @if ($errors->has('password')) 49 | 50 | {{ $errors->first('password') }} 51 | 52 | @endif 53 |
54 |
55 | 56 |
57 | 58 | 59 |
60 | 61 |
62 |
63 | 64 |
65 |
66 | 69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | @endsection 78 | -------------------------------------------------------------------------------- /resources/views/admin/register.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.admin') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
{{ __('Admin Register') }}
9 | 10 |
11 |
12 | @csrf 13 | 14 |
15 | 16 | 17 |
18 | 19 | 20 | @if ($errors->has('name')) 21 | 22 | {{ $errors->first('name') }} 23 | 24 | @endif 25 |
26 |
27 | 28 |
29 | 30 | 31 |
32 | 33 | 34 | @if ($errors->has('email')) 35 | 36 | {{ $errors->first('email') }} 37 | 38 | @endif 39 |
40 |
41 | 42 |
43 | 44 | 45 |
46 | 47 | 48 | @if ($errors->has('password')) 49 | 50 | {{ $errors->first('password') }} 51 | 52 | @endif 53 |
54 |
55 | 56 |
57 | 58 | 59 |
60 | 61 |
62 |
63 | 64 |
65 |
66 | 69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | @endsection 78 | -------------------------------------------------------------------------------- /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 | 'admin' => [ 44 | 'driver' => 'session', 45 | 'provider' => 'admins', 46 | ], 47 | 'api' => [ 48 | 'driver' => 'passport', 49 | 'provider' => 'users', 50 | ], 51 | ], 52 | 53 | /* 54 | |-------------------------------------------------------------------------- 55 | | User Providers 56 | |-------------------------------------------------------------------------- 57 | | 58 | | All authentication drivers have a user provider. This defines how the 59 | | users are actually retrieved out of your database or other storage 60 | | mechanisms used by this application to persist your user's data. 61 | | 62 | | If you have multiple user tables or models you may configure multiple 63 | | sources which represent each model / table. These sources may then 64 | | be assigned to any extra authentication guards you have defined. 65 | | 66 | | Supported: "database", "eloquent" 67 | | 68 | */ 69 | 70 | 'providers' => [ 71 | 'users' => [ 72 | 'driver' => 'eloquent', 73 | 'model' => App\User::class, 74 | ], 75 | 76 | 'admins' => [ 77 | 'driver' => 'eloquent', 78 | 'model' => App\Admin::class, 79 | ], 80 | 81 | // 'users' => [ 82 | // 'driver' => 'database', 83 | // 'table' => 'users', 84 | // ], 85 | ], 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Resetting Passwords 90 | |-------------------------------------------------------------------------- 91 | | 92 | | You may specify multiple password reset configurations if you have more 93 | | than one user table or model in the application and you want to have 94 | | separate password reset settings based on the specific user types. 95 | | 96 | | The expire time is the number of minutes that the reset token should be 97 | | considered valid. This security feature keeps tokens short-lived so 98 | | they have less time to be guessed. You may change this as needed. 99 | | 100 | */ 101 | 102 | 'passwords' => [ 103 | 'users' => [ 104 | 'provider' => 'users', 105 | 'table' => 'password_resets', 106 | 'expire' => 60, 107 | ], 108 | ], 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /app/Listeners/UserEventSubscriber.php: -------------------------------------------------------------------------------- 1 | user->id . ']:' . $event->user->name); 21 | } 22 | 23 | /** 24 | * 处理用户删除后事件 25 | */ 26 | public function onUserDeleted($event) { 27 | Log::info('用户已经删除[' . $event->user->id . ']:' . $event->user->name); 28 | } 29 | 30 | /** 31 | * 处理用户注册事件 32 | * @param $event 33 | */ 34 | public function onUserRegistered($event) { 35 | // 用户注册成功后初始积分为30 36 | $event->user->point += PointLog::$OPT_POINT[PointLog::OPT_USER_REGISTER]; 37 | $event->user->save(); 38 | // 保存积分变更日志 39 | $pointLog = new PointLog(); 40 | $pointLog->type = PointLog::OPT_USER_REGISTER; 41 | $pointLog->value = PointLog::$OPT_POINT[PointLog::OPT_USER_REGISTER]; 42 | $event->user->pointLogs()->save($pointLog); 43 | } 44 | 45 | /** 46 | * 处理验证邮箱事件 47 | * @param $event 48 | */ 49 | public function onEmailVerified($event) { 50 | // 用户验证邮箱后增加20积分 51 | $event->user->point += PointLog::$OPT_POINT[PointLog::OPT_EMAIL_VERIFY]; 52 | $event->user->save(); 53 | // 保存积分变更日志 54 | $pointLog = new PointLog(); 55 | $pointLog->type = PointLog::OPT_EMAIL_VERIFY; 56 | $pointLog->value = PointLog::$OPT_POINT[PointLog::OPT_EMAIL_VERIFY]; 57 | $event->user->pointLogs()->save($pointLog); 58 | } 59 | 60 | /** 61 | * 处理用户登录事件 62 | * @param $event 63 | */ 64 | public function onUserLogin($event) { 65 | $pointLog = PointLog::where('user_id', $event->user->id)->where('type', PointLog::OPT_USER_LOGIN)->orderBy('created_at', 'desc')->first(); 66 | $firstLoginToday = false; 67 | if (!$pointLog) { 68 | // 注册后首次登录 69 | $firstLoginToday = true; 70 | } else { 71 | $lastLoginTime = new Carbon($pointLog->created_at); 72 | if ($lastLoginTime->isYesterday()) { 73 | // 上次登录时间是昨天 74 | $firstLoginToday = true; 75 | } 76 | } 77 | if ($firstLoginToday) { 78 | // 用户每日首次登录成功后增加5积分 79 | $event->user->point += PointLog::$OPT_POINT[PointLog::OPT_USER_LOGIN]; 80 | $event->user->save(); 81 | // 保存积分变更日志 82 | $pointLog = new PointLog(); 83 | $pointLog->type = PointLog::OPT_USER_LOGIN; 84 | $pointLog->value = PointLog::$OPT_POINT[PointLog::OPT_USER_LOGIN]; 85 | $event->user->pointLogs()->save($pointLog); 86 | } 87 | } 88 | 89 | /** 90 | * 为订阅者注册监听器 91 | * 92 | * @param Illuminate\Events\Dispatcher $events 93 | */ 94 | public function subscribe($events) 95 | { 96 | $events->listen( 97 | UserDeleting::class, 98 | UserEventSubscriber::class . '@onUserDeleting' 99 | ); 100 | 101 | $events->listen( 102 | UserDeleted::class, 103 | UserEventSubscriber::class . '@onUserDeleted' 104 | ); 105 | 106 | $events->listen( 107 | Registered::class, 108 | UserEventSubscriber::class . '@onUserRegistered' 109 | ); 110 | 111 | $events->listen( 112 | Verified::class, 113 | UserEventSubscriber::class . '@onEmailVerified' 114 | ); 115 | 116 | $events->listen( 117 | Login::class, 118 | UserEventSubscriber::class . '@onUserLogin' 119 | ); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /resources/views/layouts/admin.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{ config('app.name', 'Laravel') }} Admin 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 76 | 77 |
78 | @yield('content') 79 |
80 |
81 | 82 | 83 | -------------------------------------------------------------------------------- /public/svg/404.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/telescope.php: -------------------------------------------------------------------------------- 1 | 'telescope', 9 | 10 | /* 11 | |-------------------------------------------------------------------------- 12 | | Telescope Storage Driver 13 | |-------------------------------------------------------------------------- 14 | | 15 | | This configuration options determines the storage driver that will 16 | | be used to store Telescope's data. In addition, you may set any 17 | | custom options as needed by the particular driver you choose. 18 | | 19 | */ 20 | 21 | 'driver' => env('TELESCOPE_DRIVER', 'database'), 22 | 23 | 'storage' => [ 24 | 'database' => [ 25 | 'connection' => env('DB_CONNECTION', 'mysql'), 26 | ], 27 | ], 28 | 29 | /* 30 | |-------------------------------------------------------------------------- 31 | | Telescope Master Switch 32 | |-------------------------------------------------------------------------- 33 | | 34 | | This option may be used to disable all Telescope watchers regardless 35 | | of their individual configuration, which simply provides a single 36 | | and convenient way to enable or disable Telescope data storage. 37 | | 38 | */ 39 | 40 | 'enabled' => env('TELESCOPE_ENABLED', true), 41 | 42 | /* 43 | |-------------------------------------------------------------------------- 44 | | Telescope Route Middleware 45 | |-------------------------------------------------------------------------- 46 | | 47 | | These middleware will be assigned to every Telescope route, giving you 48 | | the chance to add your own middleware to this list or change any of 49 | | the existing middleware. Or, you can simply stick with this list. 50 | | 51 | */ 52 | 53 | 'middleware' => [ 54 | 'web', 55 | Authorize::class, 56 | ], 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Ignored Paths & Commands 61 | |-------------------------------------------------------------------------- 62 | | 63 | | The following array lists the URI paths and Artisan commands that will 64 | | not be watched by Telescope. In addition to this list, some Laravel 65 | | commands, like migrations and queue commands, are always ignored. 66 | | 67 | */ 68 | 69 | 'ignore_paths' => [ 70 | // 71 | ], 72 | 73 | 'ignore_commands' => [ 74 | // 75 | ], 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Telescope Watchers 80 | |-------------------------------------------------------------------------- 81 | | 82 | | The following array lists the "watchers" that will be registered with 83 | | Telescope. The watchers gather the application's profile data when 84 | | a request or task is executed. Feel free to customize this list. 85 | | 86 | */ 87 | 88 | 'watchers' => [ 89 | Watchers\CacheWatcher::class => env('TELESCOPE_CACHE_WATCHER', true), 90 | Watchers\CommandWatcher::class => env('TELESCOPE_COMMAND_WATCHER', true), 91 | Watchers\DumpWatcher::class => env('TELESCOPE_DUMP_WATCHER', true), 92 | Watchers\EventWatcher::class => env('TELESCOPE_EVENT_WATCHER', true), 93 | Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true), 94 | Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true), 95 | Watchers\LogWatcher::class => env('TELESCOPE_LOG_WATCHER', true), 96 | Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true), 97 | Watchers\ModelWatcher::class => env('TELESCOPE_MODEL_WATCHER', true), 98 | Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true), 99 | 100 | Watchers\QueryWatcher::class => [ 101 | 'enabled' => env('TELESCOPE_QUERY_WATCHER', true), 102 | 'slow' => 100, 103 | ], 104 | 105 | Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true), 106 | 107 | Watchers\RequestWatcher::class => [ 108 | 'enabled' => env('TELESCOPE_REQUEST_WATCHER', true), 109 | 'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64), 110 | ], 111 | 112 | Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true), 113 | ], 114 | ]; 115 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /public/svg/503.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------