├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── app ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── API │ │ │ └── PostController.php │ │ ├── Admin │ │ │ ├── PostController.php │ │ │ ├── TagController.php │ │ │ └── UploadController.php │ │ ├── Auth │ │ │ ├── ForgotPasswordController.php │ │ │ ├── LoginController.php │ │ │ ├── RegisterController.php │ │ │ ├── ResetPasswordController.php │ │ │ └── VerificationController.php │ │ ├── BlogController.php │ │ ├── ContactController.php │ │ └── Controller.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── CheckForMaintenanceMode.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ ├── TrimStrings.php │ │ ├── TrustProxies.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ ├── ContactMeRequest.php │ │ ├── PostCreateRequest.php │ │ ├── PostUpdateRequest.php │ │ ├── TagCreateRequest.php │ │ ├── TagUpdateRequest.php │ │ ├── UploadFileRequest.php │ │ └── UploadNewFolderRequest.php │ └── Resources │ │ └── PostResource.php ├── Mail │ ├── ContactMail.php │ └── TestMail.php ├── Models │ ├── Post.php │ └── Tag.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── Services │ ├── Markdowner.php │ ├── PostService.php │ ├── RssFeed.php │ ├── SiteMap.php │ └── UploadsManager.php ├── User.php └── helpers.php ├── artisan ├── bootstrap ├── app.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── blog.php ├── broadcasting.php ├── cache.php ├── database.php ├── filesystems.php ├── hashing.php ├── logging.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ ├── PostFactory.php │ ├── TagFactory.php │ └── UserFactory.php ├── migrations │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2018_12_04_140026_create_posts_table.php │ ├── 2018_12_06_085741_create_user_profiles_table.php │ ├── 2018_12_09_203245_create_tags_table.php │ ├── 2018_12_09_203725_create_post_tag_pivot.php │ ├── 2018_12_11_214001_restructure_posts_table.php │ └── 2018_12_18_112220_create_jobs_table.php └── seeds │ ├── DatabaseSeeder.php │ ├── PostsTableSeeder.php │ └── TagsTableSeeder.php ├── package-lock.json ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── css │ ├── app.css │ ├── pickadate.min.css │ └── selectize.default.css ├── favicon.ico ├── fonts │ └── vendor │ │ └── @fortawesome │ │ └── fontawesome-free │ │ ├── webfa-brands-400.eot │ │ ├── webfa-brands-400.svg │ │ ├── webfa-brands-400.ttf │ │ ├── webfa-brands-400.woff │ │ ├── webfa-brands-400.woff2 │ │ ├── webfa-regular-400.eot │ │ ├── webfa-regular-400.svg │ │ ├── webfa-regular-400.ttf │ │ ├── webfa-regular-400.woff │ │ ├── webfa-regular-400.woff2 │ │ ├── webfa-solid-900.eot │ │ ├── webfa-solid-900.svg │ │ ├── webfa-solid-900.ttf │ │ ├── webfa-solid-900.woff │ │ └── webfa-solid-900.woff2 ├── index.php ├── js │ ├── app.js │ ├── pickadate.min.js │ └── selectize.min.js ├── mix-manifest.json ├── robots.txt ├── svg │ ├── 403.svg │ ├── 404.svg │ ├── 500.svg │ └── 503.svg └── web.config ├── resources ├── js │ ├── app.js │ ├── bootstrap.js │ └── components │ │ └── ExampleComponent.vue ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php ├── sass │ ├── _variables.scss │ └── app.scss └── views │ ├── admin │ ├── auth │ │ └── login.blade.php │ ├── layout.blade.php │ ├── partials │ │ ├── errors.blade.php │ │ ├── navbar.blade.php │ │ └── success.blade.php │ ├── post │ │ ├── _form.blade.php │ │ ├── create.blade.php │ │ ├── edit.blade.php │ │ └── index.blade.php │ ├── tag │ │ ├── _form.blade.php │ │ ├── create.blade.php │ │ ├── edit.blade.php │ │ └── index.blade.php │ └── upload │ │ ├── _modals.blade.php │ │ └── index.blade.php │ ├── blog │ ├── contact.blade.php │ ├── layouts │ │ ├── index.blade.php │ │ ├── master.blade.php │ │ └── post.blade.php │ └── partials │ │ ├── disqus.blade.php │ │ ├── page-footer.blade.php │ │ └── page-nav.blade.php │ ├── emails │ ├── contact.blade.php │ └── test.blade.php │ └── welcome.blade.php ├── routes ├── api.php ├── channels.php ├── console.php └── web.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ ├── .gitignore │ │ └── data │ │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ ├── testing │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore ├── tests ├── CreatesApplication.php ├── Feature │ └── ExampleTest.php ├── TestCase.php └── Unit │ └── ExampleTest.php └── webpack.mix.js /.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 | -------------------------------------------------------------------------------- /.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 | MAIL_FROM_ADDRESS= 33 | MAIL_FROM_NAME= 34 | 35 | PUSHER_APP_ID= 36 | PUSHER_APP_KEY= 37 | PUSHER_APP_SECRET= 38 | PUSHER_APP_CLUSTER=mt1 39 | 40 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 41 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 42 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | *.js linguist-vendored 5 | CHANGELOG.md export-ignore 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | /.idea 7 | /.vscode 8 | /nbproject 9 | /.vagrant 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | .env 15 | .phpunit.result.cache 16 | Envoy.blade.php 17 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('queue:work')->everyMinute(); 28 | } 29 | 30 | /** 31 | * Register the commands for the application. 32 | * 33 | * @return void 34 | */ 35 | protected function commands() 36 | { 37 | $this->load(__DIR__.'/Commands'); 38 | 39 | require base_path('routes/console.php'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | simplePaginate(5); 16 | $items = []; 17 | foreach ($posts->items() as $post) { 18 | $item['id'] = $post->id; 19 | $item['title'] = $post->title; 20 | $item['summary'] = $post->subtitle; 21 | $item['thumb'] = url(config('blog.uploads.webpath') . '/' . $post->page_image); 22 | $item['posted_at'] = $post->publish_date; 23 | $item['views'] = mt_rand(1, 10000); // 暂时没有实现文章浏览数逻辑,返回随机数 24 | $items[] = $item; 25 | } 26 | $data = [ 27 | 'message' => 'success', 28 | 'articles' => $items 29 | ]; 30 | return response()->json($data); 31 | } 32 | 33 | public function detail($id) 34 | { 35 | $post = Post::findOrFail($id); 36 | return new PostResource($post); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/PostController.php: -------------------------------------------------------------------------------- 1 | '', 19 | 'subtitle' => '', 20 | 'page_image' => '', 21 | 'content' => '', 22 | 'meta_description' => '', 23 | 'is_draft' => "0", 24 | 'publish_date' => '', 25 | 'publish_time' => '', 26 | 'layout' => 'blog.layouts.post', 27 | 'tags' => [], 28 | ]; 29 | 30 | /** 31 | * Display a listing of the posts. 32 | */ 33 | public function index() 34 | { 35 | return view('admin.post.index', ['posts' => Post::all()]); 36 | } 37 | 38 | /** 39 | * Show the new post form 40 | */ 41 | public function create() 42 | { 43 | $fields = $this->fieldList; 44 | 45 | $when = Carbon::now()->addHour(); 46 | $fields['publish_date'] = $when->format('Y-m-d'); 47 | $fields['publish_time'] = $when->format('g:i A'); 48 | 49 | foreach ($fields as $fieldName => $fieldValue) { 50 | $fields[$fieldName] = old($fieldName, $fieldValue); 51 | } 52 | 53 | $data = array_merge( 54 | $fields, 55 | ['allTags' => Tag::all()->pluck('tag')->all()] 56 | ); 57 | 58 | return view('admin.post.create', $data); 59 | } 60 | 61 | /** 62 | * Store a newly created Post 63 | * 64 | * @param PostCreateRequest $request 65 | */ 66 | public function store(PostCreateRequest $request) 67 | { 68 | $post = Post::create($request->postFillData()); 69 | $post->syncTags($request->get('tags', [])); 70 | 71 | return redirect() 72 | ->route('post.index') 73 | ->with('success', '新文章创建成功.'); 74 | } 75 | 76 | /** 77 | * Show the post edit form 78 | * 79 | * @param int $id 80 | * @return Response 81 | */ 82 | public function edit($id) 83 | { 84 | $fields = $this->fieldsFromModel($id, $this->fieldList); 85 | 86 | foreach ($fields as $fieldName => $fieldValue) { 87 | $fields[$fieldName] = old($fieldName, $fieldValue); 88 | } 89 | 90 | $data = array_merge( 91 | $fields, 92 | ['allTags' => Tag::all()->pluck('tag')->all()] 93 | ); 94 | 95 | return view('admin.post.edit', $data); 96 | } 97 | 98 | /** 99 | * 更新文章 100 | * 101 | * @param PostUpdateRequest $request 102 | * @param $id 103 | * @return \Illuminate\Http\RedirectResponse 104 | */ 105 | public function update(PostUpdateRequest $request, $id) 106 | { 107 | $post = Post::findOrFail($id); 108 | $post->fill($request->postFillData()); 109 | $post->save(); 110 | $post->syncTags($request->get('tags', [])); 111 | 112 | if ($request->action === 'continue') { 113 | return redirect() 114 | ->back() 115 | ->with('success', '文章已保存.'); 116 | } 117 | 118 | return redirect() 119 | ->route('post.index') 120 | ->with('success', '文章已保存.'); 121 | } 122 | 123 | /** 124 | * Remove the specified resource from storage. 125 | * 126 | * @param int $id 127 | * @return Response 128 | */ 129 | public function destroy($id) 130 | { 131 | $post = Post::findOrFail($id); 132 | $post->tags()->detach(); 133 | $post->delete(); 134 | 135 | return redirect() 136 | ->route('post.index') 137 | ->with('success', '文章已删除.'); 138 | } 139 | 140 | /** 141 | * Return the field values from the model 142 | * 143 | * @param integer $id 144 | * @param array $fields 145 | * @return array 146 | */ 147 | private function fieldsFromModel($id, array $fields) 148 | { 149 | $post = Post::findOrFail($id); 150 | 151 | $fieldNames = array_keys(array_except($fields, ['tags'])); 152 | 153 | $fields = ['id' => $id]; 154 | foreach ($fieldNames as $field) { 155 | $fields[$field] = $post->{$field}; 156 | } 157 | 158 | $fields['tags'] = $post->tags->pluck('tag')->all(); 159 | 160 | return $fields; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/TagController.php: -------------------------------------------------------------------------------- 1 | '', 14 | 'title' => '', 15 | 'subtitle' => '', 16 | 'meta_description' => '', 17 | 'page_image' => '', 18 | 'layout' => 'blog.layouts.index', 19 | 'reverse_direction' => 0, 20 | ]; 21 | 22 | /** 23 | * Display a listing of the resource. 24 | * 25 | * @return \Illuminate\Http\Response 26 | */ 27 | public function index() 28 | { 29 | $tags = Tag::all(); 30 | return view('admin.tag.index', ['tags' => $tags]); 31 | } 32 | 33 | /** 34 | * Show the form for creating a new resource. 35 | * 36 | * @return \Illuminate\Http\Response 37 | */ 38 | public function create() 39 | { 40 | $data = []; 41 | foreach ($this->fields as $field => $default) { 42 | $data[$field] = old($field, $default); 43 | } 44 | 45 | return view('admin.tag.create', $data); 46 | } 47 | 48 | /** 49 | * Store a newly created resource in storage. 50 | * 51 | * @param \Illuminate\Http\Request $request 52 | * @return \Illuminate\Http\Response 53 | */ 54 | public function store(Request $request) 55 | { 56 | $tag = new Tag(); 57 | foreach (array_keys($this->fields) as $field) { 58 | $tag->$field = $request->get($field); 59 | } 60 | $tag->save(); 61 | 62 | return redirect('/admin/tag') 63 | ->with('success', '标签「' . $tag->tag . '」创建成功.'); 64 | } 65 | 66 | /** 67 | * Show the form for editing the specified resource. 68 | * 69 | * @param int $id 70 | * @return \Illuminate\Http\Response 71 | */ 72 | public function edit($id) 73 | { 74 | $tag = Tag::findOrFail($id); 75 | $data = ['id' => $id]; 76 | foreach (array_keys($this->fields) as $field) { 77 | $data[$field] = old($field, $tag->$field); 78 | } 79 | 80 | return view('admin.tag.edit', $data); 81 | } 82 | 83 | /** 84 | * Update the specified resource in storage. 85 | * 86 | * @param \Illuminate\Http\Request $request 87 | * @param int $id 88 | * @return \Illuminate\Http\Response 89 | */ 90 | public function update(Request $request, $id) 91 | { 92 | $tag = Tag::findOrFail($id); 93 | 94 | foreach (array_keys(array_except($this->fields, ['tag'])) as $field) { 95 | $tag->$field = $request->get($field); 96 | } 97 | $tag->save(); 98 | 99 | return redirect("/admin/tag/$id/edit") 100 | ->with('success', '修改已保存.'); 101 | } 102 | 103 | /** 104 | * Remove the specified resource from storage. 105 | * 106 | * @param int $id 107 | * @return \Illuminate\Http\Response 108 | */ 109 | public function destroy($id) 110 | { 111 | $tag = Tag::findOrFail($id); 112 | $tag->delete(); 113 | 114 | return redirect('/admin/tag') 115 | ->with('success', '标签「' . $tag->tag . '」已经被删除.'); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/UploadController.php: -------------------------------------------------------------------------------- 1 | manager = $manager; 19 | } 20 | 21 | /** 22 | * Show page of files / subfolders 23 | */ 24 | public function index(Request $request) 25 | { 26 | $folder = $request->get('folder'); 27 | $data = $this->manager->folderInfo($folder); 28 | 29 | return view('admin.upload.index', $data); 30 | } 31 | 32 | /** 33 | * 创建新目录 34 | */ 35 | public function createFolder(UploadNewFolderRequest $request) 36 | { 37 | $new_folder = $request->get('new_folder'); 38 | $folder = $request->get('folder') . '/' . $new_folder; 39 | 40 | $result = $this->manager->createDirectory($folder); 41 | 42 | if ($result === true) { 43 | return redirect() 44 | ->back() 45 | ->with('success', '目录「' . $new_folder . '」创建成功.'); 46 | } 47 | 48 | $error = $result ?: "创建目录出错."; 49 | return redirect() 50 | ->back() 51 | ->with('errors', [$error]); 52 | } 53 | 54 | /** 55 | * 删除文件 56 | */ 57 | public function deleteFile(Request $request) 58 | { 59 | $del_file = $request->get('del_file'); 60 | $path = $request->get('folder') . '/' . $del_file; 61 | 62 | $result = $this->manager->deleteFile($path); 63 | 64 | if ($result === true) { 65 | return redirect() 66 | ->back() 67 | ->with('success', '文件「' . $del_file . '」已删除.'); 68 | } 69 | 70 | $error = $result ?: "文件删除出错."; 71 | return redirect() 72 | ->back() 73 | ->with('errors', [$error]); 74 | } 75 | 76 | /** 77 | * 删除目录 78 | */ 79 | public function deleteFolder(Request $request) 80 | { 81 | $del_folder = $request->get('del_folder'); 82 | $folder = $request->get('folder') . '/' . $del_folder; 83 | 84 | $result = $this->manager->deleteDirectory($folder); 85 | 86 | if ($result === true) { 87 | return redirect() 88 | ->back() 89 | ->with('success', '目录「' . $del_folder . '」已删除'); 90 | } 91 | 92 | $error = $result ?: "An error occurred deleting directory."; 93 | return redirect() 94 | ->back() 95 | ->with('errors', [$error]); 96 | } 97 | 98 | /** 99 | * 上传文件 100 | */ 101 | public function uploadFile(UploadFileRequest $request) 102 | { 103 | $file = $_FILES['file']; 104 | $fileName = $request->get('file_name'); 105 | $fileName = $fileName ?: $file['name']; 106 | $path = str_finish($request->get('folder'), '/') . $fileName; 107 | $content = File::get($file['tmp_name']); 108 | 109 | $result = $this->manager->saveFile($path, $content); 110 | 111 | if ($result === true) { 112 | return redirect() 113 | ->back() 114 | ->with("success", '文件「' . $fileName . '」上传成功.'); 115 | } 116 | 117 | $error = $result ?: "文件上传出错."; 118 | return redirect() 119 | ->back() 120 | ->with('errors', [$error]); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ForgotPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/LoginController.php: -------------------------------------------------------------------------------- 1 | middleware('guest')->except('logout'); 44 | } 45 | 46 | // 退出后重定向到登录页 47 | public function loggedOut(Request $request) 48 | { 49 | return redirect('/login'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /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/ResetPasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /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/Http/Controllers/BlogController.php: -------------------------------------------------------------------------------- 1 | get('tag'); 17 | $postService = new PostService($tag); 18 | $data = $postService->lists(); 19 | $layout = $tag ? Tag::layout($tag) : 'blog.layouts.index'; 20 | return view($layout, $data); 21 | } 22 | 23 | public function showPost($slug, Request $request) 24 | { 25 | $post = Post::with('tags')->where('slug', $slug)->firstOrFail(); 26 | $tag = $request->get('tag'); 27 | if ($tag) { 28 | $tag = Tag::where('tag', $tag)->firstOrFail(); 29 | } 30 | return view($post->layout, ['post' => $post, 'tag' => $tag]); 31 | } 32 | 33 | public function rss(RssFeed $feed) 34 | { 35 | $rss = $feed->getRSS(); 36 | 37 | return response($rss) 38 | ->header('Content-type', 'application/rss+xml'); 39 | } 40 | 41 | public function siteMap(SiteMap $siteMap) 42 | { 43 | $map = $siteMap->getSiteMap(); 44 | 45 | return response($map) 46 | ->header('Content-type', 'text/xml'); 47 | } 48 | } -------------------------------------------------------------------------------- /app/Http/Controllers/ContactController.php: -------------------------------------------------------------------------------- 1 | only('name', 'email', 'phone'); 20 | $data['messageLines'] = explode("\n", $request->get('message')); 21 | 22 | Mail::to($data['email'])->queue(new ContactMail($data)); 23 | 24 | return back() 25 | ->with("success", "消息已发送,感谢您的反馈"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | [ 31 | \App\Http\Middleware\EncryptCookies::class, 32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 33 | \Illuminate\Session\Middleware\StartSession::class, 34 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 36 | \App\Http\Middleware\VerifyCsrfToken::class, 37 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 38 | ], 39 | 40 | 'api' => [ 41 | 'throttle:60,1', 42 | 'bindings', 43 | ], 44 | ]; 45 | 46 | /** 47 | * The application's route middleware. 48 | * 49 | * These middleware may be assigned to groups or used individually. 50 | * 51 | * @var array 52 | */ 53 | protected $routeMiddleware = [ 54 | 'auth' => \App\Http\Middleware\Authenticate::class, 55 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 56 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 57 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 58 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 59 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 60 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 62 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 63 | ]; 64 | 65 | /** 66 | * The priority-sorted list of middleware. 67 | * 68 | * This forces non-global middleware to always be in the given order. 69 | * 70 | * @var array 71 | */ 72 | protected $middlewarePriority = [ 73 | \Illuminate\Session\Middleware\StartSession::class, 74 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 75 | \App\Http\Middleware\Authenticate::class, 76 | \Illuminate\Session\Middleware\AuthenticateSession::class, 77 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 78 | \Illuminate\Auth\Middleware\Authorize::class, 79 | ]; 80 | } 81 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/CheckForMaintenanceMode.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/admin'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 'required', 28 | 'email' => 'required|email', 29 | 'message' => 'required', 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Requests/PostCreateRequest.php: -------------------------------------------------------------------------------- 1 | 'required', 27 | 'subtitle' => 'required', 28 | 'content' => 'required', 29 | 'publish_date' => 'required', 30 | 'publish_time' => 'required', 31 | 'layout' => 'required', 32 | ]; 33 | } 34 | 35 | /** 36 | * Return the fields and values to create a new post from 37 | */ 38 | public function postFillData() 39 | { 40 | $published_at = new Carbon( 41 | $this->publish_date . ' ' . $this->publish_time 42 | ); 43 | return [ 44 | 'title' => $this->title, 45 | 'subtitle' => $this->subtitle, 46 | 'page_image' => $this->page_image, 47 | 'content_raw' => $this->get('content'), 48 | 'meta_description' => $this->meta_description, 49 | 'is_draft' => (bool)$this->is_draft, 50 | 'published_at' => $published_at, 51 | 'layout' => $this->layout, 52 | ]; 53 | } 54 | } -------------------------------------------------------------------------------- /app/Http/Requests/PostUpdateRequest.php: -------------------------------------------------------------------------------- 1 | 'bail|required|unique:tags,tag', 28 | 'title' => 'required', 29 | 'subtitle' => 'required', 30 | 'layout' => 'required', 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Requests/TagUpdateRequest.php: -------------------------------------------------------------------------------- 1 | 'required', 28 | 'subtitle' => 'required', 29 | 'layout' => 'required', 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Requests/UploadFileRequest.php: -------------------------------------------------------------------------------- 1 | 'required', 28 | 'folder' => 'required', 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Requests/UploadNewFolderRequest.php: -------------------------------------------------------------------------------- 1 | 'required', 28 | 'new_folder' => 'required', 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Resources/PostResource.php: -------------------------------------------------------------------------------- 1 | $this->id, 19 | 'title' => $this->title, 20 | 'image' => url(config('blog.uploads.webpath') . '/' . $this->page_image), 21 | 'content' => $this->content_html, 22 | 'author' => '学院君', 23 | 'posted_at' => $this->publish_date, 24 | 'views' => mt_rand(1, 100000), 25 | 'votes' => mt_rand(1, 1000) 26 | ]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/Mail/ContactMail.php: -------------------------------------------------------------------------------- 1 | formData = $formData; 24 | } 25 | 26 | /** 27 | * Build the message. 28 | * 29 | * @return $this 30 | */ 31 | public function build() 32 | { 33 | return $this->subject('博客联系我们表单:' . $this->formData['name']) 34 | ->view('emails.contact', ['data' => $this->formData]); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Mail/TestMail.php: -------------------------------------------------------------------------------- 1 | subject('测试邮件')->view('emails.test'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Models/Post.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Tag::class, 'post_tag_pivot'); 26 | } 27 | 28 | /** 29 | * Set the title attribute and automatically the slug 30 | * 31 | * @param string $value 32 | */ 33 | public function setTitleAttribute($value) 34 | { 35 | $this->attributes['title'] = $value; 36 | 37 | if (!$this->exists) { 38 | $value = uniqid(str_random(8)); 39 | $this->setUniqueSlug($value, 0); 40 | } 41 | } 42 | 43 | /** 44 | * Recursive routine to set a unique slug 45 | * 46 | * @param string $title 47 | * @param mixed $extra 48 | */ 49 | protected function setUniqueSlug($title, $extra) 50 | { 51 | $slug = str_slug($title . '-' . $extra); 52 | 53 | if (static::where('slug', $slug)->exists()) { 54 | $this->setUniqueSlug($title, $extra + 1); 55 | return; 56 | } 57 | 58 | $this->attributes['slug'] = $slug; 59 | } 60 | 61 | /** 62 | * Set the HTML content automatically when the raw content is set 63 | * 64 | * @param string $value 65 | */ 66 | public function setContentRawAttribute($value) 67 | { 68 | $markdown = new Markdowner(); 69 | 70 | $this->attributes['content_raw'] = $value; 71 | $this->attributes['content_html'] = $markdown->toHTML($value); 72 | } 73 | 74 | /** 75 | * Sync tag relation adding new tags as needed 76 | * 77 | * @param array $tags 78 | */ 79 | public function syncTags(array $tags) 80 | { 81 | Tag::addNeededTags($tags); 82 | 83 | if (count($tags)) { 84 | $this->tags()->sync( 85 | Tag::whereIn('tag', $tags)->get()->pluck('id')->all() 86 | ); 87 | return; 88 | } 89 | 90 | $this->tags()->detach(); 91 | } 92 | 93 | /** 94 | * 返回 published_at 字段的日期部分 95 | */ 96 | public function getPublishDateAttribute($value) 97 | { 98 | return $this->published_at->format('Y-m-d'); 99 | } 100 | 101 | /** 102 | * 返回 published_at 字段的时间部分 103 | */ 104 | public function getPublishTimeAttribute($value) 105 | { 106 | return $this->published_at->format('g:i A'); 107 | } 108 | 109 | /** 110 | * content_raw 字段别名 111 | */ 112 | public function getContentAttribute($value) 113 | { 114 | return $this->content_raw; 115 | } 116 | 117 | /** 118 | * Return URL to post 119 | * 120 | * @param Tag $tag 121 | * @return string 122 | */ 123 | public function url(Tag $tag = null) 124 | { 125 | $url = url('blog/' . $this->slug); 126 | if ($tag) { 127 | $url .= '?tag=' . urlencode($tag->tag); 128 | } 129 | 130 | return $url; 131 | } 132 | 133 | /** 134 | * Return array of tag links 135 | * 136 | * @param string $base 137 | * @return array 138 | */ 139 | public function tagLinks($base = '/blog?tag=%TAG%') 140 | { 141 | $tags = $this->tags()->get()->pluck('tag')->all(); 142 | $return = []; 143 | foreach ($tags as $tag) { 144 | $url = str_replace('%TAG%', urlencode($tag), $base); 145 | $return[] = '' . e($tag) . ''; 146 | } 147 | return $return; 148 | } 149 | 150 | /** 151 | * Return next post after this one or null 152 | * 153 | * @param Tag $tag 154 | * @return Post 155 | */ 156 | public function newerPost(Tag $tag = null) 157 | { 158 | $query = 159 | static::where('published_at', '>', $this->published_at) 160 | ->where('published_at', '<=', Carbon::now()) 161 | ->where('is_draft', 0) 162 | ->orderBy('published_at', 'asc'); 163 | if ($tag) { 164 | $query = $query->whereHas('tags', function ($q) use ($tag) { 165 | $q->where('tag', '=', $tag->tag); 166 | }); 167 | } 168 | 169 | return $query->first(); 170 | } 171 | 172 | /** 173 | * Return older post before this one or null 174 | * 175 | * @param Tag $tag 176 | * @return Post 177 | */ 178 | public function olderPost(Tag $tag = null) 179 | { 180 | $query = 181 | static::where('published_at', '<', $this->published_at) 182 | ->where('is_draft', 0) 183 | ->orderBy('published_at', 'desc'); 184 | if ($tag) { 185 | $query = $query->whereHas('tags', function ($q) use ($tag) { 186 | $q->where('tag', '=', $tag->tag); 187 | }); 188 | } 189 | 190 | return $query->first(); 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /app/Models/Tag.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Post::class, 'post_tag_pivot'); 22 | } 23 | 24 | /** 25 | * Add any tags needed from the list 26 | * 27 | * @param array $tags List of tags to check/add 28 | */ 29 | public static function addNeededTags(array $tags) 30 | { 31 | if (count($tags) === 0) { 32 | return; 33 | } 34 | 35 | $found = static::whereIn('tag', $tags)->get()->pluck('tag')->all(); 36 | 37 | foreach (array_diff($tags, $found) as $tag) { 38 | static::create([ 39 | 'tag' => $tag, 40 | 'title' => $tag, 41 | 'subtitle' => 'Subtitle for ' . $tag, 42 | 'page_image' => '', 43 | 'meta_description' => '', 44 | 'reverse_direction' => false, 45 | ]); 46 | } 47 | } 48 | 49 | /** 50 | * Return the index layout to use for a tag 51 | * 52 | * @param string $tag 53 | * @param string $default 54 | * @return string 55 | */ 56 | public static function layout($tag, $default = 'blog.layouts.index') 57 | { 58 | $layout = static::where('tag', $tag)->get()->pluck('layout')->first(); 59 | 60 | return $layout ?: $default; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | * 26 | * @return void 27 | */ 28 | public function boot() 29 | { 30 | parent::boot(); 31 | 32 | // 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapApiRoutes(); 39 | 40 | $this->mapWebRoutes(); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @return void 51 | */ 52 | protected function mapWebRoutes() 53 | { 54 | Route::middleware('web') 55 | ->namespace($this->namespace) 56 | ->group(base_path('routes/web.php')); 57 | } 58 | 59 | /** 60 | * Define the "api" routes for the application. 61 | * 62 | * These routes are typically stateless. 63 | * 64 | * @return void 65 | */ 66 | protected function mapApiRoutes() 67 | { 68 | Route::prefix('api') 69 | ->middleware('api') 70 | ->namespace($this->namespace) 71 | ->group(base_path('routes/api.php')); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/Services/Markdowner.php: -------------------------------------------------------------------------------- 1 | preTransformText($text); 13 | $text = MarkdownExtra::defaultTransform($text); 14 | $text = SmartyPants::defaultTransform($text); 15 | $text = $this->postTransformText($text); 16 | return $text; 17 | } 18 | 19 | protected function preTransformText($text) 20 | { 21 | return $text; 22 | } 23 | 24 | protected function postTransformText($text) 25 | { 26 | return $text; 27 | } 28 | } -------------------------------------------------------------------------------- /app/Services/PostService.php: -------------------------------------------------------------------------------- 1 | tag = $tag; 20 | } 21 | 22 | public function lists() 23 | { 24 | if ($this->tag) { 25 | return $this->tagIndexData($this->tag); 26 | } 27 | return $this->normalIndexData(); 28 | } 29 | 30 | /** 31 | * Return data for normal index page 32 | * 33 | * @return array 34 | */ 35 | protected function normalIndexData() 36 | { 37 | $posts = Post::with('tags') 38 | ->where('published_at', '<=', Carbon::now()) 39 | ->where('is_draft', 0) 40 | ->orderBy('published_at', 'desc') 41 | ->simplePaginate(config('blog.posts_per_page')); 42 | 43 | return [ 44 | 'title' => config('blog.title'), 45 | 'subtitle' => config('blog.subtitle'), 46 | 'posts' => $posts, 47 | 'page_image' => config('blog.page_image'), 48 | 'meta_description' => config('blog.description'), 49 | 'reverse_direction' => false, 50 | 'tag' => null, 51 | ]; 52 | } 53 | 54 | /** 55 | * Return data for a tag index page 56 | * 57 | * @param string $tag 58 | * @return array 59 | */ 60 | protected function tagIndexData($tag) 61 | { 62 | $tag = Tag::where('tag', $tag)->firstOrFail(); 63 | $reverse_direction = (bool)$tag->reverse_direction; 64 | 65 | $posts = Post::where('published_at', '<=', Carbon::now()) 66 | ->whereHas('tags', function ($q) use ($tag) { 67 | $q->where('tag', '=', $tag->tag); 68 | }) 69 | ->where('is_draft', 0) 70 | ->orderBy('published_at', $reverse_direction ? 'asc' : 'desc') 71 | ->simplePaginate(config('blog.posts_per_page')); 72 | $posts->appends('tag', $tag->tag); 73 | 74 | $page_image = $tag->page_image ?: config('blog.page_image'); 75 | 76 | return [ 77 | 'title' => $tag->title, 78 | 'subtitle' => $tag->subtitle, 79 | 'posts' => $posts, 80 | 'page_image' => $page_image, 81 | 'tag' => $tag, 82 | 'reverse_direction' => $reverse_direction, 83 | 'meta_description' => $tag->meta_description ?: config('blog.description'), 84 | ]; 85 | } 86 | } -------------------------------------------------------------------------------- /app/Services/RssFeed.php: -------------------------------------------------------------------------------- 1 | buildRssData(); 24 | Cache::add('rss-feed', $rss, 120); 25 | 26 | return $rss; 27 | } 28 | 29 | /** 30 | * Return a string with the feed data 31 | * 32 | * @return string 33 | */ 34 | protected function buildRssData() 35 | { 36 | $now = Carbon::now(); 37 | $feed = new Feed(); 38 | $channel = new Channel(); 39 | $channel 40 | ->title(config('blog.title')) 41 | ->description(config('blog.description')) 42 | ->url(url('/')) 43 | ->language('en') 44 | ->copyright('Copyright (c) ' . config('blog.author')) 45 | ->lastBuildDate($now->timestamp) 46 | ->appendTo($feed); 47 | 48 | $posts = Post::where('published_at', '<=', $now) 49 | ->where('is_draft', 0) 50 | ->orderBy('published_at', 'desc') 51 | ->take(config('blog.rss_size')) 52 | ->get(); 53 | foreach ($posts as $post) { 54 | $item = new Item(); 55 | $item 56 | ->title($post->title) 57 | ->description($post->subtitle) 58 | ->url($post->url()) 59 | ->pubDate($post->published_at->timestamp) 60 | ->guid($post->url(), true) 61 | ->appendTo($channel); 62 | } 63 | 64 | $feed = (string)$feed; 65 | 66 | // Replace a couple items to make the feed more compliant 67 | $feed = str_replace( 68 | '', 69 | '', 70 | $feed 71 | ); 72 | $feed = str_replace( 73 | '', 74 | '' . "\n" . ' ', 76 | $feed 77 | ); 78 | 79 | return $feed; 80 | } 81 | } -------------------------------------------------------------------------------- /app/Services/SiteMap.php: -------------------------------------------------------------------------------- 1 | buildSiteMap(); 21 | Cache::add('site-map', $siteMap, 120); 22 | return $siteMap; 23 | } 24 | 25 | /** 26 | * Build the Site Map 27 | */ 28 | protected function buildSiteMap() 29 | { 30 | $postsInfo = $this->getPostsInfo(); 31 | $dates = array_values($postsInfo); 32 | sort($dates); 33 | $lastmod = last($dates); 34 | $url = trim(url('/'), '/') . '/'; 35 | 36 | $xml = []; 37 | $xml[] = ''; 38 | $xml[] = ''; 39 | $xml[] = ' '; 40 | $xml[] = " $url"; 41 | $xml[] = " $lastmod"; 42 | $xml[] = ' daily'; 43 | $xml[] = ' 0.8'; 44 | $xml[] = ' '; 45 | 46 | foreach ($postsInfo as $slug => $lastmod) { 47 | $xml[] = ' '; 48 | $xml[] = " {$url}blog/$slug"; 49 | $xml[] = " $lastmod"; 50 | $xml[] = " "; 51 | } 52 | 53 | $xml[] = ''; 54 | 55 | return join("\n", $xml); 56 | } 57 | 58 | /** 59 | * Return all the posts as $url => $date 60 | */ 61 | protected function getPostsInfo() 62 | { 63 | return Post::where('published_at', '<=', Carbon::now()) 64 | ->where('is_draft', 0) 65 | ->orderBy('published_at', 'desc') 66 | ->pluck('updated_at', 'slug') 67 | ->all(); 68 | } 69 | } -------------------------------------------------------------------------------- /app/Services/UploadsManager.php: -------------------------------------------------------------------------------- 1 | disk = Storage::disk(config('blog.uploads.storage')); 17 | $this->mimeDetect = $mimeDetect; 18 | } 19 | 20 | /** 21 | * Return files and directories within a folder 22 | * 23 | * @param string $folder 24 | * @return array of [ 25 | * 'folder' => 'path to current folder', 26 | * 'folderName' => 'name of just current folder', 27 | * 'breadCrumbs' => breadcrumb array of [ $path => $foldername ] 28 | * 'folders' => array of [ $path => $foldername] of each subfolder 29 | * 'files' => array of file details on each file in folder 30 | * ] 31 | */ 32 | public function folderInfo($folder) 33 | { 34 | $folder = $this->cleanFolder($folder); 35 | 36 | $breadcrumbs = $this->breadcrumbs($folder); 37 | $slice = array_slice($breadcrumbs, -1); 38 | $folderName = current($slice); 39 | $breadcrumbs = array_slice($breadcrumbs, 0, -1); 40 | 41 | $subfolders = []; 42 | foreach (array_unique($this->disk->directories($folder)) as $subfolder) { 43 | $subfolders["/$subfolder"] = basename($subfolder); 44 | } 45 | 46 | $files = []; 47 | foreach ($this->disk->files($folder) as $path) { 48 | $files[] = $this->fileDetails($path); 49 | } 50 | 51 | return compact( 52 | 'folder', 53 | 'folderName', 54 | 'breadcrumbs', 55 | 'subfolders', 56 | 'files' 57 | ); 58 | } 59 | 60 | /** 61 | * Sanitize the folder name 62 | */ 63 | protected function cleanFolder($folder) 64 | { 65 | return '/' . trim(str_replace('..', '', $folder), '/'); 66 | } 67 | 68 | /** 69 | * 返回当前目录路径 70 | */ 71 | protected function breadcrumbs($folder) 72 | { 73 | $folder = trim($folder, '/'); 74 | $crumbs = ['/' => 'root']; 75 | 76 | if (empty($folder)) { 77 | return $crumbs; 78 | } 79 | 80 | $folders = explode('/', $folder); 81 | $build = ''; 82 | foreach ($folders as $folder) { 83 | $build .= '/' . $folder; 84 | $crumbs[$build] = $folder; 85 | } 86 | 87 | return $crumbs; 88 | } 89 | 90 | /** 91 | * 返回文件详细信息数组 92 | */ 93 | protected function fileDetails($path) 94 | { 95 | $path = '/' . ltrim($path, '/'); 96 | 97 | return [ 98 | 'name' => basename($path), 99 | 'fullPath' => $path, 100 | 'webPath' => $this->fileWebpath($path), 101 | 'mimeType' => $this->fileMimeType($path), 102 | 'size' => $this->fileSize($path), 103 | 'modified' => $this->fileModified($path), 104 | ]; 105 | } 106 | 107 | /** 108 | * 返回文件完整的web路径 109 | */ 110 | public function fileWebpath($path) 111 | { 112 | $path = rtrim(config('blog.uploads.webpath'), '/') . '/' . ltrim($path, '/'); 113 | return url($path); 114 | } 115 | 116 | /** 117 | * 返回文件MIME类型 118 | */ 119 | public function fileMimeType($path) 120 | { 121 | return $this->mimeDetect->findType( 122 | pathinfo($path, PATHINFO_EXTENSION) 123 | ); 124 | } 125 | 126 | /** 127 | * 返回文件大小 128 | */ 129 | public function fileSize($path) 130 | { 131 | return $this->disk->size($path); 132 | } 133 | 134 | /** 135 | * 返回最后修改时间 136 | */ 137 | public function fileModified($path) 138 | { 139 | return Carbon::createFromTimestamp( 140 | $this->disk->lastModified($path) 141 | ); 142 | } 143 | 144 | /** 145 | * 创建新目录 146 | */ 147 | public function createDirectory($folder) 148 | { 149 | $folder = $this->cleanFolder($folder); 150 | 151 | if ($this->disk->exists($folder)) { 152 | return "Folder '$folder' already exists."; 153 | } 154 | 155 | return $this->disk->makeDirectory($folder); 156 | } 157 | 158 | /** 159 | * 删除目录 160 | */ 161 | public function deleteDirectory($folder) 162 | { 163 | $folder = $this->cleanFolder($folder); 164 | 165 | $filesFolders = array_merge( 166 | $this->disk->directories($folder), 167 | $this->disk->files($folder) 168 | ); 169 | if (!empty($filesFolders)) { 170 | return "Directory must be empty to delete it."; 171 | } 172 | 173 | return $this->disk->deleteDirectory($folder); 174 | } 175 | 176 | /** 177 | * 删除文件 178 | */ 179 | public function deleteFile($path) 180 | { 181 | $path = $this->cleanFolder($path); 182 | 183 | if (!$this->disk->exists($path)) { 184 | return "File does not exist."; 185 | } 186 | 187 | return $this->disk->delete($path); 188 | } 189 | 190 | /** 191 | * 保存文件 192 | */ 193 | public function saveFile($path, $content) 194 | { 195 | $path = $this->cleanFolder($path); 196 | 197 | if ($this->disk->exists($path)) { 198 | return "File already exists."; 199 | } 200 | 201 | return $this->disk->put($path, $content); 202 | } 203 | } -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": [ 6 | "framework", 7 | "laravel" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^7.1.3", 12 | "dflydev/apache-mime-types": "^1.0", 13 | "doctrine/dbal": "^2.9", 14 | "fideloper/proxy": "^4.0", 15 | "laravel/framework": "5.7.*", 16 | "laravel/tinker": "^1.0", 17 | "michelf/php-markdown": "^1.8", 18 | "michelf/php-smartypants": "^1.8", 19 | "suin/php-rss-writer": "^1.6" 20 | }, 21 | "require-dev": { 22 | "beyondcode/laravel-dump-server": "^1.0", 23 | "filp/whoops": "^2.0", 24 | "fzaninotto/faker": "^1.4", 25 | "mockery/mockery": "^1.0", 26 | "nunomaduro/collision": "^2.0", 27 | "phpunit/phpunit": "^7.0" 28 | }, 29 | "config": { 30 | "optimize-autoloader": true, 31 | "preferred-install": "dist", 32 | "sort-packages": true 33 | }, 34 | "extra": { 35 | "laravel": { 36 | "dont-discover": [] 37 | } 38 | }, 39 | "autoload": { 40 | "psr-4": { 41 | "App\\": "app/" 42 | }, 43 | "classmap": [ 44 | "database/seeds", 45 | "database/factories" 46 | ], 47 | "files": [ 48 | "app/helpers.php" 49 | ] 50 | }, 51 | "autoload-dev": { 52 | "psr-4": { 53 | "Tests\\": "tests/" 54 | } 55 | }, 56 | "minimum-stability": "dev", 57 | "prefer-stable": true, 58 | "scripts": { 59 | "post-autoload-dump": [ 60 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 61 | "@php artisan package:discover --ansi" 62 | ], 63 | "post-root-package-install": [ 64 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 65 | ], 66 | "post-create-project-cmd": [ 67 | "@php artisan key:generate --ansi" 68 | ], 69 | "test" : [ 70 | "vendor/bin/phpunit" 71 | ] 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'eloquent', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | You may specify multiple password reset configurations if you have more 85 | | than one user table or model in the application and you want to have 86 | | separate password reset settings based on the specific user types. 87 | | 88 | | The expire time is the number of minutes that the reset token should be 89 | | considered valid. This security feature keeps tokens short-lived so 90 | | they have less time to be guessed. You may change this as needed. 91 | | 92 | */ 93 | 94 | 'passwords' => [ 95 | 'users' => [ 96 | 'provider' => 'users', 97 | 'table' => 'password_resets', 98 | 'expire' => 60, 99 | ], 100 | ], 101 | 102 | ]; 103 | -------------------------------------------------------------------------------- /config/blog.php: -------------------------------------------------------------------------------- 1 | "Laravel 学院", 5 | 'title' => "Laravel 学院", 6 | 'subtitle' => 'http://laravelacademy.org', 7 | 'description' => 'Laravel学院致力于提供优质Laravel中文学习资源', 8 | 'author' => '学院君', 9 | 'page_image' => 'home-bg.jpg', 10 | 'posts_per_page' => 5, 11 | 'rss_size' => 25, 12 | 'uploads' => [ 13 | 'storage' => 'public', 14 | 'webpath' => '/storage/uploads', 15 | ], 16 | 'contact_email' => env('MAIL_FROM_ADDRESS') 17 | ]; -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'cluster' => env('PUSHER_APP_CLUSTER'), 40 | 'encrypted' => true, 41 | ], 42 | ], 43 | 44 | 'redis' => [ 45 | 'driver' => 'redis', 46 | 'connection' => 'default', 47 | ], 48 | 49 | 'log' => [ 50 | 'driver' => 'log', 51 | ], 52 | 53 | 'null' => [ 54 | 'driver' => 'null', 55 | ], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 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 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Database Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here are each of the database connections setup for your application. 24 | | Of course, examples of configuring each database platform that is 25 | | supported by Laravel is shown below to make development simple. 26 | | 27 | | 28 | | All database work in Laravel is done through the PHP PDO facilities 29 | | so make sure you have the driver for your particular database of 30 | | choice installed on your machine before you begin development. 31 | | 32 | */ 33 | 34 | 'connections' => [ 35 | 36 | 'sqlite' => [ 37 | 'driver' => 'sqlite', 38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 39 | 'prefix' => '', 40 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 41 | ], 42 | 43 | 'mysql' => [ 44 | 'driver' => 'mysql', 45 | 'host' => env('DB_HOST', '127.0.0.1'), 46 | 'port' => env('DB_PORT', '3306'), 47 | 'database' => env('DB_DATABASE', 'forge'), 48 | 'username' => env('DB_USERNAME', 'forge'), 49 | 'password' => env('DB_PASSWORD', ''), 50 | 'unix_socket' => env('DB_SOCKET', ''), 51 | 'charset' => 'utf8mb4', 52 | 'collation' => 'utf8mb4_unicode_ci', 53 | 'prefix' => '', 54 | 'prefix_indexes' => true, 55 | 'strict' => true, 56 | 'engine' => null, 57 | ], 58 | 59 | 'pgsql' => [ 60 | 'driver' => 'pgsql', 61 | 'host' => env('DB_HOST', '127.0.0.1'), 62 | 'port' => env('DB_PORT', '5432'), 63 | 'database' => env('DB_DATABASE', 'forge'), 64 | 'username' => env('DB_USERNAME', 'forge'), 65 | 'password' => env('DB_PASSWORD', ''), 66 | 'charset' => 'utf8', 67 | 'prefix' => '', 68 | 'prefix_indexes' => true, 69 | 'schema' => 'public', 70 | 'sslmode' => 'prefer', 71 | ], 72 | 73 | 'sqlsrv' => [ 74 | 'driver' => 'sqlsrv', 75 | 'host' => env('DB_HOST', 'localhost'), 76 | 'port' => env('DB_PORT', '1433'), 77 | 'database' => env('DB_DATABASE', 'forge'), 78 | 'username' => env('DB_USERNAME', 'forge'), 79 | 'password' => env('DB_PASSWORD', ''), 80 | 'charset' => 'utf8', 81 | 'prefix' => '', 82 | 'prefix_indexes' => true, 83 | ], 84 | 85 | ], 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Migration Repository Table 90 | |-------------------------------------------------------------------------- 91 | | 92 | | This table keeps track of all the migrations that have already run for 93 | | your application. Using this information, we can determine which of 94 | | the migrations on disk haven't actually been run in the database. 95 | | 96 | */ 97 | 98 | 'migrations' => 'migrations', 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Redis Databases 103 | |-------------------------------------------------------------------------- 104 | | 105 | | Redis is an open source, fast, and advanced key-value store that also 106 | | provides a richer body of commands than a typical key-value system 107 | | such as APC or Memcached. Laravel makes it easy to dig right in. 108 | | 109 | */ 110 | 111 | 'redis' => [ 112 | 113 | 'client' => 'predis', 114 | 115 | 'default' => [ 116 | 'host' => env('REDIS_HOST', '127.0.0.1'), 117 | 'password' => env('REDIS_PASSWORD', null), 118 | 'port' => env('REDIS_PORT', 6379), 119 | 'database' => env('REDIS_DB', 0), 120 | ], 121 | 122 | 'cache' => [ 123 | 'host' => env('REDIS_HOST', '127.0.0.1'), 124 | 'password' => env('REDIS_PASSWORD', null), 125 | 'port' => env('REDIS_PORT', 6379), 126 | 'database' => env('REDIS_CACHE_DB', 1), 127 | ], 128 | 129 | ], 130 | 131 | ]; 132 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Log Channels 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may configure the log channels for your application. Out of 27 | | the box, Laravel uses the Monolog PHP logging library. This gives 28 | | you a variety of powerful log handlers / formatters to utilize. 29 | | 30 | | Available Drivers: "single", "daily", "slack", "syslog", 31 | | "errorlog", "monolog", 32 | | "custom", "stack" 33 | | 34 | */ 35 | 36 | 'channels' => [ 37 | 'stack' => [ 38 | 'driver' => 'stack', 39 | 'channels' => ['daily'], 40 | ], 41 | 42 | 'single' => [ 43 | 'driver' => 'single', 44 | 'path' => storage_path('logs/laravel.log'), 45 | 'level' => 'debug', 46 | ], 47 | 48 | 'daily' => [ 49 | 'driver' => 'daily', 50 | 'path' => storage_path('logs/laravel.log'), 51 | 'level' => 'debug', 52 | 'days' => 14, 53 | ], 54 | 55 | 'slack' => [ 56 | 'driver' => 'slack', 57 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 58 | 'username' => 'Laravel Log', 59 | 'emoji' => ':boom:', 60 | 'level' => 'critical', 61 | ], 62 | 63 | 'papertrail' => [ 64 | 'driver' => 'monolog', 65 | 'level' => 'debug', 66 | 'handler' => SyslogUdpHandler::class, 67 | 'handler_with' => [ 68 | 'host' => env('PAPERTRAIL_URL'), 69 | 'port' => env('PAPERTRAIL_PORT'), 70 | ], 71 | ], 72 | 73 | 'stderr' => [ 74 | 'driver' => 'monolog', 75 | 'handler' => StreamHandler::class, 76 | 'with' => [ 77 | 'stream' => 'php://stderr', 78 | ], 79 | ], 80 | 81 | 'syslog' => [ 82 | 'driver' => 'syslog', 83 | 'level' => 'debug', 84 | ], 85 | 86 | 'errorlog' => [ 87 | 'driver' => 'errorlog', 88 | 'level' => 'debug', 89 | ], 90 | ], 91 | 92 | ]; 93 | -------------------------------------------------------------------------------- /config/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', 'admin@laravelacademy.org'), 60 | 'name' => env('MAIL_FROM_NAME', '学院君'), 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 | |-------------------------------------------------------------------------- 125 | | Log Channel 126 | |-------------------------------------------------------------------------- 127 | | 128 | | If you are using the "log" driver, you may specify the logging channel 129 | | if you prefer to keep mail messages separate from other log entries 130 | | for simpler reading. Otherwise, the default channel will be used. 131 | | 132 | */ 133 | 134 | 'log_channel' => env('MAIL_LOG_CHANNEL'), 135 | 136 | ]; 137 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'sync'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection information for each server that 24 | | is used by your application. A default configuration has been added 25 | | for each back-end shipped with Laravel. You are free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'retry_after' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'retry_after' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => env('SQS_KEY', 'your-public-key'), 54 | 'secret' => env('SQS_SECRET', 'your-secret-key'), 55 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 56 | 'queue' => env('SQS_QUEUE', 'your-queue-name'), 57 | 'region' => env('SQS_REGION', 'us-east-1'), 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => env('REDIS_QUEUE', 'default'), 64 | 'retry_after' => 90, 65 | 'block_for' => null, 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Failed Queue Jobs 73 | |-------------------------------------------------------------------------- 74 | | 75 | | These options configure the behavior of failed queue job logging so you 76 | | can control which database and table are used to store the jobs that 77 | | have failed. You may change them to any database / table you wish. 78 | | 79 | */ 80 | 81 | 'failed' => [ 82 | 'database' => env('DB_CONNECTION', 'mysql'), 83 | 'table' => 'failed_jobs', 84 | ], 85 | 86 | ]; 87 | -------------------------------------------------------------------------------- /config/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 | 'webhook' => [ 38 | 'secret' => env('STRIPE_WEBHOOK_SECRET'), 39 | 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300), 40 | ], 41 | ], 42 | 43 | ]; 44 | -------------------------------------------------------------------------------- /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' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/PostFactory.php: -------------------------------------------------------------------------------- 1 | define(Post::class, function (Faker $faker) { 7 | $images = ['about-bg.jpg', 'contact-bg.jpg', 'home-bg.jpg', 'post-bg.jpg']; 8 | $title = $faker->sentence(mt_rand(3, 10)); 9 | return [ 10 | 'title' => $title, 11 | 'subtitle' => str_limit($faker->sentence(mt_rand(10, 20)), 252), 12 | 'page_image' => $images[mt_rand(0, 3)], 13 | 'content_raw' => join("\n\n", $faker->paragraphs(mt_rand(3, 6))), 14 | 'published_at' => $faker->dateTimeBetween('-1 month', '+3 days'), 15 | 'meta_description' => "Meta for $title", 16 | 'is_draft' => false, 17 | ]; 18 | }); 19 | -------------------------------------------------------------------------------- /database/factories/TagFactory.php: -------------------------------------------------------------------------------- 1 | define(Tag::class, function (Faker $faker) { 7 | $images = ['about-bg.jpg', 'contact-bg.jpg', 'home-bg.jpg', 'post-bg.jpg']; 8 | $word = $faker->word; 9 | return [ 10 | 'tag' => $word, 11 | 'title' => ucfirst($word), 12 | 'subtitle' => $faker->sentence, 13 | 'page_image' => $images[mt_rand(0, 3)], 14 | 'meta_description' => "Meta for $word", 15 | 'reverse_direction' => false, 16 | ]; 17 | }); 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 18 | $table->string('token'); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::dropIfExists('password_resets'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2018_12_04_140026_create_posts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('slug')->unique(); 19 | $table->string('title')->comment('标题'); 20 | $table->text('content'); 21 | $table->softDeletes(); 22 | $table->timestamp('published_at')->nullable(); 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_085741_create_user_profiles_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::dropIfExists('user_profiles'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2018_12_09_203245_create_tags_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('tag')->unique(); 19 | $table->string('title'); 20 | $table->string('subtitle'); 21 | $table->string('page_image'); 22 | $table->string('meta_description'); 23 | $table->string('layout')->default('blog.layouts.index'); 24 | $table->boolean('reverse_direction'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::dropIfExists('tags'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2018_12_09_203725_create_post_tag_pivot.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->integer('post_id')->unsigned()->index(); 19 | $table->integer('tag_id')->unsigned()->index(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('post_tag_pivot'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/migrations/2018_12_11_214001_restructure_posts_table.php: -------------------------------------------------------------------------------- 1 | string('subtitle')->after('title'); 16 | $table->renameColumn('content', 'content_raw'); 17 | $table->text('content_html')->after('content'); 18 | $table->string('page_image')->after('content_html'); 19 | $table->string('meta_description')->after('page_image'); 20 | $table->boolean('is_draft')->after('meta_description'); 21 | $table->string('layout')->after('is_draft')->default('blog.layouts.post'); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down() 29 | { 30 | Schema::table('posts', function (Blueprint $table) { 31 | $table->dropColumn('layout'); 32 | $table->dropColumn('is_draft'); 33 | $table->dropColumn('meta_description'); 34 | $table->dropColumn('page_image'); 35 | $table->dropColumn('content_html'); 36 | $table->renameColumn('content_raw', 'content'); 37 | $table->dropColumn('subtitle'); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /database/migrations/2018_12_18_112220_create_jobs_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 18 | $table->string('queue')->index(); 19 | $table->longText('payload'); 20 | $table->unsignedTinyInteger('attempts'); 21 | $table->unsignedInteger('reserved_at')->nullable(); 22 | $table->unsignedInteger('available_at'); 23 | $table->unsignedInteger('created_at'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('jobs'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(TagsTableSeeder::class); 17 | $this->call(PostsTableSeeder::class); 18 | Model::reguard(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /database/seeds/PostsTableSeeder.php: -------------------------------------------------------------------------------- 1 | pluck('tag')->all(); 19 | 20 | Post::truncate(); 21 | 22 | // Don't forget to truncate the pivot table 23 | DB::table('post_tag_pivot')->truncate(); 24 | 25 | factory(Post::class, 20)->create()->each(function ($post) use ($tags) { 26 | 27 | // 30% of the time don't assign a tag 28 | if (mt_rand(1, 100) <= 30) { 29 | return; 30 | } 31 | 32 | shuffle($tags); 33 | $postTags = [$tags[0]]; 34 | 35 | // 30% of the time we're assigning tags, assign 2 36 | if (mt_rand(1, 100) <= 30) { 37 | $postTags[] = $tags[1]; 38 | } 39 | 40 | $post->syncTags($postTags); 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /database/seeds/TagsTableSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /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 | "@fortawesome/fontawesome-free": "^5.6.0", 14 | "axios": "^0.18", 15 | "bootstrap": "^4.0.0", 16 | "clean-blog": "0.0.1-security", 17 | "cross-env": "^5.1", 18 | "datatables.net-bs4": "^1.10.19", 19 | "jquery": "^3.2", 20 | "laravel-mix": "^3.0.0", 21 | "less": "^3.9.0", 22 | "less-loader": "^4.1.0", 23 | "lodash": "^4.17.5", 24 | "pickadate": "^3.5.6", 25 | "popper.js": "^1.12", 26 | "selectize": "^0.12.6", 27 | "startbootstrap-clean-blog": "^5.0.1", 28 | "vue": "^2.5.17" 29 | }, 30 | "dependencies": { 31 | "ajv": "^6.6.1", 32 | "imagemin": "^6.0.0", 33 | "npm": "^6.4.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Handle Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-brands-400.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-regular-400.woff2 -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.eot -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.ttf -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff -------------------------------------------------------------------------------- /public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nonfu/laravel-blog-code/33a4287175f8ace5b999b1bdee761b58cb353838/public/fonts/vendor/@fortawesome/fontawesome-free/webfa-solid-900.woff2 -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | define('LARAVEL_START', microtime(true)); 11 | 12 | /* 13 | |-------------------------------------------------------------------------- 14 | | Register The Auto Loader 15 | |-------------------------------------------------------------------------- 16 | | 17 | | Composer provides a convenient, automatically generated class loader for 18 | | our application. We just need to utilize it! We'll simply require it 19 | | into the script here so that we don't have to worry about manual 20 | | loading any of our classes later on. It feels great to relax. 21 | | 22 | */ 23 | 24 | require __DIR__.'/../vendor/autoload.php'; 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Turn On The Lights 29 | |-------------------------------------------------------------------------- 30 | | 31 | | We need to illuminate PHP development, so let us turn on the lights. 32 | | This bootstraps the framework and gets it ready for use, then it 33 | | will load up this application so that we can run it and send 34 | | the responses back to the browser and delight our users. 35 | | 36 | */ 37 | 38 | $app = require_once __DIR__.'/../bootstrap/app.php'; 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Run The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once we have the application, we can handle the incoming request 46 | | through the kernel, and send the associated response back to 47 | | the client's browser allowing them to enjoy the creative 48 | | and wonderful application we have prepared for them. 49 | | 50 | */ 51 | 52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 53 | 54 | $response = $kernel->handle( 55 | $request = Illuminate\Http\Request::capture() 56 | ); 57 | 58 | $response->send(); 59 | 60 | $kernel->terminate($request, $response); 61 | -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css", 4 | "/css/selectize.default.css": "/css/selectize.default.css", 5 | "/css/pickadate.min.css": "/css/pickadate.min.css", 6 | "/js/selectize.min.js": "/js/selectize.min.js", 7 | "/js/pickadate.min.js": "/js/pickadate.min.js" 8 | } 9 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/svg/404.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/svg/503.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Laravel. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | //window.Vue = require('vue'); 11 | 12 | /** 13 | * The following block of code may be used to automatically register your 14 | * Vue components. It will recursively scan this directory for the Vue 15 | * components and automatically register them with their "basename". 16 | * 17 | * Eg. ./components/ExampleComponent.vue -> 18 | */ 19 | 20 | //Vue.component('example-component', require('./components/ExampleComponent.vue')); 21 | 22 | // const files = require.context('./', true, /\.vue$/i) 23 | // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key))) 24 | 25 | /** 26 | * Next, we will create a fresh Vue application instance and attach it to 27 | * the page. Then, you may begin adding components to this application 28 | * or customize the JavaScript scaffolding to fit your unique needs. 29 | */ 30 | 31 | /*const app = new Vue({ 32 | el: '#app' 33 | });*/ 34 | 35 | /** 36 | * Blog Javascript 37 | * Copied from Clean Blog v1.0.0 (http://startbootstrap.com) 38 | */ 39 | 40 | // Navigation Scripts to Show Header on Scroll-Up 41 | jQuery(document).ready(function ($) { 42 | var MQL = 1170; 43 | 44 | //primary navigation slide-in effect 45 | if ($(window).width() > MQL) { 46 | var headerHeight = $('.navbar-custom').height(); 47 | $(window).on('scroll', { 48 | previousTop: 0 49 | }, 50 | function () { 51 | var currentTop = $(window).scrollTop(); 52 | 53 | //if user is scrolling up 54 | if (currentTop < this.previousTop) { 55 | if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) { 56 | $('.navbar-custom').addClass('is-visible'); 57 | } else { 58 | $('.navbar-custom').removeClass('is-visible is-fixed'); 59 | } 60 | //if scrolling down... 61 | } else { 62 | $('.navbar-custom').removeClass('is-visible'); 63 | if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) { 64 | $('.navbar-custom').addClass('is-fixed'); 65 | } 66 | } 67 | this.previousTop = currentTop; 68 | }); 69 | } 70 | 71 | // Initialize tooltips 72 | $('[data-toggle="tooltip"]').tooltip(); 73 | }); 74 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | 4 | /** 5 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 6 | * for JavaScript based Bootstrap features such as modals and tabs. This 7 | * code may be modified to fit the specific needs of your application. 8 | */ 9 | 10 | try { 11 | window.Popper = require('popper.js').default; 12 | window.$ = window.jQuery = require('jquery'); 13 | 14 | require('bootstrap'); 15 | require('datatables.net-bs4'); 16 | require('selectize'); 17 | } catch (e) {} 18 | 19 | /** 20 | * We'll load the axios HTTP library which allows us to easily issue requests 21 | * to our Laravel back-end. This library automatically handles sending the 22 | * CSRF token as a header based on the value of the "XSRF" token cookie. 23 | */ 24 | 25 | window.axios = require('axios'); 26 | 27 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 28 | 29 | /** 30 | * Next we will register the CSRF Token as a common header with Axios so that 31 | * all outgoing HTTP requests automatically have it attached. This is just 32 | * a simple convenience so we don't have to attach every token manually. 33 | */ 34 | 35 | let token = document.head.querySelector('meta[name="csrf-token"]'); 36 | 37 | if (token) { 38 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 39 | } else { 40 | console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); 41 | } 42 | 43 | /** 44 | * Echo exposes an expressive API for subscribing to channels and listening 45 | * for events that are broadcast by Laravel. Echo and event broadcasting 46 | * allows your team to easily build robust real-time web applications. 47 | */ 48 | 49 | // import Echo from 'laravel-echo' 50 | 51 | // window.Pusher = require('pusher-js'); 52 | 53 | // window.Echo = new Echo({ 54 | // broadcaster: 'pusher', 55 | // key: process.env.MIX_PUSHER_APP_KEY, 56 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 57 | // encrypted: true 58 | // }); 59 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /resources/sass/_variables.scss: -------------------------------------------------------------------------------- 1 | 2 | // Body 3 | $body-bg: #f8fafc; 4 | 5 | // Typography 6 | $font-family-sans-serif: "Nunito", sans-serif; 7 | $font-size-base: 0.9rem; 8 | $line-height-base: 1.6; 9 | 10 | // Colors 11 | $blue: #3490dc; 12 | $indigo: #6574cd; 13 | $purple: #9561e2; 14 | $pink: #f66D9b; 15 | $red: #e3342f; 16 | $orange: #f6993f; 17 | $yellow: #ffed4a; 18 | $green: #38c172; 19 | $teal: #4dc0b5; 20 | $cyan: #6cb2eb; 21 | -------------------------------------------------------------------------------- /resources/sass/app.scss: -------------------------------------------------------------------------------- 1 | 2 | // Fonts 3 | @import url('https://fonts.googleapis.com/css?family=Nunito'); 4 | 5 | // Variables 6 | @import 'variables'; 7 | 8 | // Bootstrap 9 | @import '~bootstrap/scss/bootstrap'; 10 | 11 | // DataTables 12 | @import "~datatables.net-bs4/css/dataTables.bootstrap4"; 13 | 14 | // Font Awesome 15 | @import '~@fortawesome/fontawesome-free/scss/brands'; 16 | @import '~@fortawesome/fontawesome-free/scss/regular'; 17 | @import '~@fortawesome/fontawesome-free/scss/solid'; 18 | @import "~@fortawesome/fontawesome-free/scss/fontawesome"; 19 | 20 | // Clean Blog 21 | @import "~startbootstrap-clean-blog/scss/clean-blog"; 22 | 23 | .navbar-laravel { 24 | background-color: #fff; 25 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04); 26 | } 27 | 28 | .intro-header .post-heading .meta a, article a { 29 | text-decoration: underline; 30 | } 31 | 32 | h2 { 33 | padding-top: 22px; 34 | } 35 | h3 { 36 | padding-top: 15px; 37 | } 38 | 39 | h2 + p, h3 + p, h4 + p { 40 | margin-top: 5px; 41 | } 42 | 43 | // Adjust position of captions 44 | .caption-title { 45 | margin-bottom: 5px; 46 | } 47 | .caption-title + p { 48 | margin-top: 0; 49 | } 50 | 51 | // Change the styling of dt/dd elements 52 | dt { 53 | margin-bottom: 5px; 54 | } 55 | dd { 56 | margin-left: 30px; 57 | margin-bottom: 10px; 58 | } 59 | -------------------------------------------------------------------------------- /resources/views/admin/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |
8 |
用户登录
9 |
10 | 11 | @include('admin.partials.errors') 12 | 13 |
14 | 15 | 16 |
17 | 18 |
19 | 21 |
22 |
23 | 24 |
25 | 26 |
27 | 28 |
29 |
30 | 31 |
32 |
33 |
34 | 37 |
38 |
39 |
40 | 41 |
42 |
43 | 44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | @endsection -------------------------------------------------------------------------------- /resources/views/admin/layout.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{ config('blog.title') }} 管理后台 10 | 11 | 12 | @yield('styles') 13 | 14 | 15 | 16 | {{-- Navigation Bar --}} 17 | 30 | 31 |
32 | @yield('content') 33 |
34 | 35 | 36 | @yield('scripts') 37 | 38 | -------------------------------------------------------------------------------- /resources/views/admin/partials/errors.blade.php: -------------------------------------------------------------------------------- 1 | @if ($errors->any()) 2 |
3 | Whoops! 4 | There were some problems with your input.

5 |
    6 | @foreach ($errors->all() as $error) 7 |
  • {{ $error }}
  • 8 | @endforeach 9 |
10 |
11 | @endif 12 | -------------------------------------------------------------------------------- /resources/views/admin/partials/navbar.blade.php: -------------------------------------------------------------------------------- 1 | 15 | 16 | -------------------------------------------------------------------------------- /resources/views/admin/partials/success.blade.php: -------------------------------------------------------------------------------- 1 | @if (Session::has('success')) 2 |
3 | 4 | 5 | Success. 6 | 7 | {{ Session::get('success') }} 8 |
9 | @endif -------------------------------------------------------------------------------- /resources/views/admin/post/_form.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 7 |
8 | 9 |
10 |
11 |
12 | 15 |
16 | 17 |
18 |
19 |
20 | 23 |
24 |
25 |
26 | 27 |
28 | 45 |
46 |
47 | 48 |
49 |
50 |
51 |
52 |
53 | 56 |
57 | 58 |
59 |
60 |
61 |
62 |
63 | 66 |
67 | 68 |
69 |
70 |
71 | 74 |
75 | 76 |
77 |
78 |
79 |
80 |
81 | 85 |
86 |
87 |
88 |
89 | 92 |
93 | 100 |
101 |
102 |
103 | 106 |
107 | 108 |
109 |
110 |
111 | 114 |
115 | 118 |
119 |
120 | 121 |
122 |
-------------------------------------------------------------------------------- /resources/views/admin/post/create.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('styles') 4 | 5 | 6 | @stop 7 | 8 | @section('content') 9 |
10 |
11 |
12 |

文章 » 创建新文章

13 |
14 |
15 | 16 |
17 |
18 |
19 |
20 |

创建新文章表单

21 |
22 |
23 | 24 | @include('admin.partials.errors') 25 | 26 |
27 | 28 | 29 | @include('admin.post._form') 30 | 31 |
32 |
33 |
34 |
35 | 39 |
40 |
41 |
42 |
43 | 44 |
45 | 46 |
47 |
48 |
49 |
50 |
51 | 52 | @stop 53 | 54 | @section('scripts') 55 | 56 | 57 | 70 | @stop -------------------------------------------------------------------------------- /resources/views/admin/post/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('styles') 4 | 5 | 6 | @stop 7 | 8 | @section('content') 9 |
10 |
11 |
12 |

文章 » 编辑文章

13 |
14 |
15 | 16 |
17 |
18 |
19 |
20 |

文章编辑表单

21 |
22 |
23 | 24 | @include('admin.partials.errors') 25 | @include('admin.partials.success') 26 | 27 |
28 | 29 | 30 | 31 | @include('admin.post._form') 32 | 33 |
34 |
35 |
36 |
37 | 41 | 45 | 49 |
50 |
51 |
52 |
53 | 54 |
55 | 56 |
57 |
58 |
59 |
60 | 61 | {{-- 确认删除 --}} 62 | 90 |
91 | 92 | @stop 93 | 94 | @section('scripts') 95 | 96 | 97 | 110 | @stop -------------------------------------------------------------------------------- /resources/views/admin/post/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |

文章 » 列表

8 |
9 | 14 |
15 | 16 |
17 |
18 | 19 | @include('admin.partials.errors') 20 | @include('admin.partials.success') 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | @foreach ($posts as $post) 33 | 34 | 37 | 38 | 39 | 47 | 48 | @endforeach 49 | 50 |
发布时间标题副标题操作
35 | {{ $post->published_at->format('Y-m-d g:ia') }} 36 | {{ $post->title }}{{ $post->subtitle }} 40 | 41 | 编辑 42 | 43 | 44 | 查看 45 | 46 |
51 |
52 |
53 | 54 |
55 | @stop 56 | 57 | @section('scripts') 58 | 65 | @stop -------------------------------------------------------------------------------- /resources/views/admin/tag/_form.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 5 |
6 | 7 |
8 |
9 | 10 |
11 | 14 |
15 | 16 |
17 |
18 | 19 |
20 | 23 |
24 | 27 |
28 |
29 | 30 |
31 | 34 |
35 | 36 |
37 |
38 | 39 |
40 | 43 |
44 | 45 |
46 |
47 | 48 |
49 | 52 |
53 | 61 | 69 |
70 |
-------------------------------------------------------------------------------- /resources/views/admin/tag/create.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |

标签 8 | » 新增标签表单 9 |

10 |
11 |
12 | 13 |
14 |
15 |
16 |
17 |

新增标签表单

18 |
19 |
20 | 21 | @include('admin.partials.errors') 22 | 23 |
24 | 25 | 26 |
27 | 28 |
29 | 31 |
32 |
33 | 34 | @include('admin.tag._form') 35 | 36 |
37 |
38 | 42 |
43 |
44 | 45 |
46 | 47 |
48 |
49 |
50 |
51 |
52 | 53 | @stop -------------------------------------------------------------------------------- /resources/views/admin/tag/edit.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |

标签 8 | » 编辑标签 9 |

10 |
11 |
12 | 13 |
14 |
15 |
16 |
17 |

标签编辑表单

18 |
19 |
20 | 21 | @include('admin.partials.errors') 22 | @include('admin.partials.success') 23 | 24 |
25 | 26 | 27 | 28 | 29 |
30 | 31 |
32 |

{{ $tag }}

33 |
34 |
35 | 36 | @include('admin.tag._form') 37 | 38 |
39 |
40 | 44 | 49 |
50 |
51 | 52 |
53 | 54 |
55 |
56 |
57 |
58 |
59 | 60 | {{-- 确认删除 --}} 61 | 89 | 90 | @stop -------------------------------------------------------------------------------- /resources/views/admin/tag/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |

标签 8 | » 列表 9 |

10 |
11 | 16 |
17 | 18 |
19 |
20 | 21 | @include('admin.partials.errors') 22 | @include('admin.partials.success') 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | @foreach ($tags as $tag) 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | 58 | 59 | @endforeach 60 | 61 |
标签标题页面图片描述信息布局操作
{{ $tag->tag }}{{ $tag->title }}{{ $tag->page_image }}{{ $tag->meta_description }}{{ $tag->layout }} 54 | 55 | 编辑 56 | 57 |
62 |
63 |
64 |
65 | @stop 66 | 67 | @section('scripts') 68 | 73 | @stop -------------------------------------------------------------------------------- /resources/views/admin/upload/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('admin.layout') 2 | 3 | @section('content') 4 |
5 | 6 | {{-- 顶部工具栏 --}} 7 |
8 |
9 |

上传

10 |
11 | 17 |
18 |
19 |
20 | 23 | 26 |
27 |
28 | 29 |
30 |
31 | 32 | @include('admin.partials.errors') 33 | @include('admin.partials.success') 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | {{-- 子目录 --}} 48 | @foreach ($subfolders as $path => $name) 49 | 50 | 56 | 57 | 58 | 59 | 65 | 66 | @endforeach 67 | 68 | {{-- 所有文件 --}} 69 | @foreach ($files as $file) 70 | 71 | 81 | 82 | 83 | 84 | 96 | 97 | @endforeach 98 | 99 | 100 |
名称类型日期尺寸操作
51 | 52 | 53 | {{ $name }} 54 | 55 | 目录-- 60 | 64 |
72 | 73 | @if (is_image($file['mimeType'])) 74 | 75 | @else 76 | 77 | @endif 78 | {{ $file['name'] }} 79 | 80 | {{ $file['mimeType'] ? : 'Unknown' }}{{ $file['modified']->format('Y-m-d g:ia') }}{{ human_filesize($file['size']) }} 85 | 89 | @if (is_image($file['mimeType'])) 90 | 94 | @endif 95 |
101 | 102 |
103 |
104 |
105 | 106 | @include('admin.upload._modals') 107 | 108 | @stop 109 | 110 | @section('scripts') 111 | 138 | @stop -------------------------------------------------------------------------------- /resources/views/blog/contact.blade.php: -------------------------------------------------------------------------------- 1 | @extends('blog.layouts.master', ['meta_description' => '联系我们']) 2 | 3 | @section('page-header') 4 |
5 |
6 |
7 |
8 |
9 |
10 |

联系我们

11 | 你有问题?我有答案。 12 |
13 |
14 |
15 |
16 |
17 | @stop 18 | 19 | @section('content') 20 |
21 |
22 |
23 | @include('admin.partials.errors') 24 | @include('admin.partials.success') 25 |

26 | 想与我联系?填写下面的表单给我发消息,我会尽快给你回复! 27 |

28 |
29 | 30 |
31 |
32 | 33 | 34 |

35 |
36 |
37 |
38 |
39 | 40 | 41 |

42 |
43 |
44 |
45 |
46 | 47 | 48 |

49 |
50 |
51 |
52 |
53 | 54 | 55 |

56 |
57 |
58 |
59 |
60 |
61 | 62 |
63 |
64 |
65 |
66 |
67 | @endsection -------------------------------------------------------------------------------- /resources/views/blog/layouts/index.blade.php: -------------------------------------------------------------------------------- 1 | @extends('blog.layouts.master') 2 | 3 | @section('page-header') 4 |
5 |
6 |
7 |
8 |
9 |
10 |

{{ $title }}

11 | {{ $subtitle }} 12 |
13 |
14 |
15 |
16 |
17 | @stop 18 | 19 | @section('content') 20 |
21 |
22 |
23 | {{-- 文章列表 --}} 24 | @foreach ($posts as $post) 25 |
26 | 27 |

{{ $post->title }}

28 | @if ($post->subtitle) 29 |

{{ $post->subtitle }}

30 | @endif 31 |
32 | 39 |
40 |
41 | @endforeach 42 | 43 | {{-- 分页 --}} 44 |
45 | {{-- Reverse direction --}} 46 | @if ($reverse_direction) 47 | @if ($posts->currentPage() > 1) 48 | 49 | ← 50 | Previous {{ $tag->tag }} Posts 51 | 52 | @endif 53 | @if ($posts->hasMorePages()) 54 | 55 | Next {{ $tag->tag }} Posts 56 | → 57 | 58 | @endif 59 | @else 60 | @if ($posts->currentPage() > 1) 61 | 62 | ← 63 | Newer {{ $tag ? $tag->tag : '' }} Posts 64 | 65 | @endif 66 | @if ($posts->hasMorePages()) 67 | 68 | Older {{ $tag ? $tag->tag : '' }} Posts 69 | → 70 | 71 | @endif 72 | @endif 73 |
74 |
75 |
76 |
77 | @stop -------------------------------------------------------------------------------- /resources/views/blog/layouts/master.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | {{ $title ?? config('blog.title') }} 12 | 14 | 15 | {{-- Styles --}} 16 | 17 | @yield('styles') 18 | 19 | 20 | @include('blog.partials.page-nav') 21 | 22 | @yield('page-header') 23 | 24 | @yield('content') 25 | 26 | @yield('comments') 27 | 28 | @include('blog.partials.page-footer') 29 | 30 | {{-- Scripts --}} 31 | 32 | @yield('scripts') 33 | 34 | 35 | -------------------------------------------------------------------------------- /resources/views/blog/layouts/post.blade.php: -------------------------------------------------------------------------------- 1 | @extends('blog.layouts.master', [ 2 | 'title' => $post->title, 3 | 'meta_description' => $post->meta_description ?? config('blog.description'), 4 | ]) 5 | 6 | @section('page-header') 7 |
8 |
9 |
10 |
11 |
12 |
13 |

{{ $post->title }}

14 |

{{ $post->subtitle }}

15 | 16 | Posted on {{ $post->published_at->format('Y-m-d') }} 17 | @if ($post->tags->count()) 18 | in 19 | {!! join(', ', $post->tagLinks()) !!} 20 | @endif 21 | 22 |
23 |
24 |
25 |
26 |
27 | @stop 28 | 29 | @section('content') 30 | 31 |
32 |
33 |
34 | {{-- 文章详情 --}} 35 |
36 | {!! $post->content_html !!} 37 |
38 | 39 |
40 | 41 | {{-- 上一篇、下一篇导航 --}} 42 |
43 | {{-- Reverse direction --}} 44 | @if ($tag && $tag->reverse_direction) 45 | @if ($post->olderPost($tag)) 46 | 47 | ← 48 | Previous {{ $tag->tag }} Post 49 | 50 | @endif 51 | @if ($post->newerPost($tag)) 52 | 53 | Next {{ $tag->tag }} Post 54 | → 55 | 56 | @endif 57 | @else 58 | @if ($post->newerPost($tag)) 59 | 60 | ← 61 | Newer {{ $tag ? $tag->tag : '' }} Post 62 | 63 | @endif 64 | @if ($post->olderPost($tag)) 65 | 66 | Older {{ $tag ? $tag->tag : '' }} Post 67 | → 68 | 69 | @endif 70 | @endif 71 |
72 |
73 |
74 |
75 | @stop 76 | 77 | @section('comments') 78 |
79 |
80 |
81 |
82 | @include('blog.partials.disqus') 83 |
84 |
85 |
86 | @stop -------------------------------------------------------------------------------- /resources/views/blog/partials/disqus.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 14 | 17 | -------------------------------------------------------------------------------- /resources/views/blog/partials/page-footer.blade.php: -------------------------------------------------------------------------------- 1 |
2 | -------------------------------------------------------------------------------- /resources/views/blog/partials/page-nav.blade.php: -------------------------------------------------------------------------------- 1 | {{-- Navigation --}} 2 | -------------------------------------------------------------------------------- /resources/views/emails/contact.blade.php: -------------------------------------------------------------------------------- 1 |

2 | 收到来自博客网站联系表单的新消息。 3 |

4 |

5 | 下面是消息明细: 6 |

7 |
    8 |
  • 姓名: {{ $data['name'] }}
  • 9 |
  • 邮箱: {{ $data['email'] }}
  • 10 |
  • 手机: {{ $data['phone'] }}
  • 11 |
12 |
13 |

14 | @foreach ($data['messageLines'] as $messageLine) 15 | {{ $messageLine }}
16 | @endforeach 17 |

18 |
19 | -------------------------------------------------------------------------------- /resources/views/emails/test.blade.php: -------------------------------------------------------------------------------- 1 | 一封来自Laravel学院的测试邮件! -------------------------------------------------------------------------------- /resources/views/welcome.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Laravel 8 | 9 | 10 | 11 | 12 | 13 | 65 | 66 | 67 |
68 | @if (Route::has('login')) 69 | 80 | @endif 81 | 82 |
83 |
84 | Laravel 85 |
86 | 87 | 95 |
96 |
97 | 98 | 99 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | prefix('v1')->group(function() { 16 | // 文章首页 17 | Route::get('/articles', 'API\PostController@index'); 18 | // 文章详情页 19 | Route::get('/article/{id}', 'API\PostController@detail')->where(['id' => '[1-9]{1}[0-9]*']); 20 | }); 21 | 22 | Route::middleware('auth:api')->get('/user', function (Request $request) { 23 | return $request->user(); 24 | }); 25 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 16 | }); 17 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 18 | })->describe('Display an inspiring quote'); 19 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | name('blog.home'); 19 | Route::get('/blog/{slug}', 'BlogController@showPost')->name('blog.detail'); 20 | 21 | // 后台路由 22 | Route::get('/admin', function () { 23 | return redirect('/admin/post'); 24 | }); 25 | Route::middleware('auth')->namespace('Admin')->group(function () { 26 | Route::resource('admin/post', 'PostController'); 27 | Route::resource('admin/tag', 'TagController', ['except' => 'show']); 28 | Route::get('admin/upload', 'UploadController@index'); 29 | Route::post('admin/upload/file', 'UploadController@uploadFile'); 30 | Route::delete('admin/upload/file', 'UploadController@deleteFile'); 31 | Route::post('admin/upload/folder', 'UploadController@createFolder'); 32 | Route::delete('admin/upload/folder', 'UploadController@deleteFolder'); 33 | }); 34 | 35 | // 登录退出 36 | Route::get('/login', 'Auth\LoginController@showLoginForm')->name('login'); 37 | Route::post('/login', 'Auth\LoginController@login'); 38 | Route::get('/logout', 'Auth\LoginController@logout')->name('logout'); 39 | 40 | // 联系表单 41 | Route::get('contact', 'ContactController@showForm'); 42 | Route::post('contact', 'ContactController@sendContactInfo'); 43 | 44 | // RSS 订阅 45 | Route::get('rss', 'BlogController@rss'); 46 | 47 | // 站点地图 48 | Route::get('sitemap.xml', 'BlogController@siteMap'); 49 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel application. By default, we are compiling the Sass 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js') 15 | .sass('resources/sass/app.scss', 'public/css'); 16 | 17 | mix.combine([ 18 | 'node_modules/selectize/dist/css/selectize.css', 19 | 'node_modules/selectize/dist/css/selectize.bootstrap3.css' 20 | ], 'public/css/selectize.default.css'); 21 | 22 | mix.combine([ 23 | 'node_modules/pickadate/lib/compressed/themes/default.css', 24 | 'node_modules/pickadate/lib/compressed/themes/default.date.css', 25 | 'node_modules/pickadate/lib/compressed/themes/default.time.css', 26 | ], 'public/css/pickadate.min.css'); 27 | 28 | mix.copy('node_modules/selectize/dist/js/standalone/selectize.min.js', 29 | 'public/js/selectize.min.js'); 30 | 31 | mix.combine([ 32 | 'node_modules/pickadate/lib/compressed/picker.js', 33 | 'node_modules/pickadate/lib/compressed/picker.date.js', 34 | 'node_modules/pickadate/lib/compressed/picker.time.js' 35 | ], 'public/js/pickadate.min.js'); 36 | --------------------------------------------------------------------------------