From 0834266bddfacaf24aa18770c26d51eece2dfff3 Mon Sep 17 00:00:00 2001 From: ro4 Date: Thu, 10 May 2018 14:17:36 +0800 Subject: [PATCH 01/12] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2018_05_10_105015_create_tags_table.php | 32 +++++++++++++++++ ...018_05_10_105629_create_page_tag_table.php | 34 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 database/migrations/2018_05_10_105015_create_tags_table.php create mode 100644 database/migrations/2018_05_10_105629_create_page_tag_table.php diff --git a/database/migrations/2018_05_10_105015_create_tags_table.php b/database/migrations/2018_05_10_105015_create_tags_table.php new file mode 100644 index 00000000..11d0250f --- /dev/null +++ b/database/migrations/2018_05_10_105015_create_tags_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('name', 255)->comment('用户ID')->unique(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('wz_tags'); + } +} diff --git a/database/migrations/2018_05_10_105629_create_page_tag_table.php b/database/migrations/2018_05_10_105629_create_page_tag_table.php new file mode 100644 index 00000000..8deae320 --- /dev/null +++ b/database/migrations/2018_05_10_105629_create_page_tag_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->unsignedInteger('page_id')->comment('页面 ID'); + $table->unsignedInteger('tag_id')->comment('标签 ID'); + $table->index('page_id', 'idx_page_id'); + $table->index('tag_id', 'idx_tag_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('wz_page_tag'); + } +} From 6a8529e45c248254a21c7ef3355f840a2a85143c Mon Sep 17 00:00:00 2001 From: ro4 Date: Fri, 11 May 2018 17:41:17 +0800 Subject: [PATCH 02/12] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E6=80=A7=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Repositories/Document.php | 10 ++++++++ app/Repositories/PageTag.php | 19 ++++++++++++++ app/Repositories/Tag.php | 31 +++++++++++++++++++++++ resources/views/components/tags.blade.php | 5 ++++ resources/views/project/project.blade.php | 4 +-- 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 app/Repositories/PageTag.php create mode 100644 app/Repositories/Tag.php create mode 100644 resources/views/components/tags.blade.php diff --git a/app/Repositories/Document.php b/app/Repositories/Document.php index 52676d96..613be8a0 100644 --- a/app/Repositories/Document.php +++ b/app/Repositories/Document.php @@ -147,4 +147,14 @@ public function attachments() { return $this->hasMany(Attachment::class, 'page_id', 'id'); } + + /** + * 页面的标签 + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function tags() + { + return $this->belongsToMany(Tag::class, 'wz_page_tag', 'page_id', 'tag_id'); + } } \ No newline at end of file diff --git a/app/Repositories/PageTag.php b/app/Repositories/PageTag.php new file mode 100644 index 00000000..f286d4b9 --- /dev/null +++ b/app/Repositories/PageTag.php @@ -0,0 +1,19 @@ +belongsToMany(Document::class, 'wz_page_tag', 'tag_id', 'page_id'); + } +} \ No newline at end of file diff --git a/resources/views/components/tags.blade.php b/resources/views/components/tags.blade.php new file mode 100644 index 00000000..b8520efc --- /dev/null +++ b/resources/views/components/tags.blade.php @@ -0,0 +1,5 @@ +

+ @foreach($pageItem->tags as $tag) + {{$tag->name}} + @endforeach +

\ No newline at end of file diff --git a/resources/views/project/project.blade.php b/resources/views/project/project.blade.php index 2e569064..c3645d81 100644 --- a/resources/views/project/project.blade.php +++ b/resources/views/project/project.blade.php @@ -45,9 +45,9 @@ @endif - + @include('components.tags') @include('components.document-info') - +
@if($type == 'markdown') From f120e889cb97ad51b35dbd799c137a103bb0ec0a Mon Sep 17 00:00:00 2001 From: ro4 Date: Tue, 15 May 2018 17:42:11 +0800 Subject: [PATCH 03/12] =?UTF-8?q?=E6=A0=87=E7=AD=BE=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E6=80=A7=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/TagController.php | 24 +++++++++++++++++++++++ resources/views/project/project.blade.php | 2 +- routes/web.php | 4 ++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/TagController.php diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php new file mode 100644 index 00000000..74b2073c --- /dev/null +++ b/app/Http/Controllers/TagController.php @@ -0,0 +1,24 @@ +input('p')); + + $names = $request->input('tags'); + + $tags = Tag::whereIn('name', $names)->get(); + + dd($tags); + } + +} \ No newline at end of file diff --git a/resources/views/project/project.blade.php b/resources/views/project/project.blade.php index c3645d81..5c480c23 100644 --- a/resources/views/project/project.blade.php +++ b/resources/views/project/project.blade.php @@ -45,7 +45,6 @@ @endif - @include('components.tags') @include('components.document-info')
@@ -76,6 +75,7 @@
@endif + @include('components.tags') @else
@endif - @include('components.tags') @else
\ No newline at end of file +
diff --git a/resources/views/layouts/project-setting.blade.php b/resources/views/layouts/project-setting.blade.php index 2052535f..e2304081 100644 --- a/resources/views/layouts/project-setting.blade.php +++ b/resources/views/layouts/project-setting.blade.php @@ -1,7 +1,7 @@ @extends('layouts.default') @section('title', $project->name) -@section('container-style', 'container container-small') +@section('container-style', 'container container-medium') @section('content')
diff --git a/resources/views/layouts/single.blade.php b/resources/views/layouts/single.blade.php index 61128e9e..fe610553 100644 --- a/resources/views/layouts/single.blade.php +++ b/resources/views/layouts/single.blade.php @@ -1,5 +1,5 @@ @extends('layouts.default') -@section('container-style', 'container container-small') +@section('container-style', 'container container-medium') @section('content')
diff --git a/resources/views/layouts/user.blade.php b/resources/views/layouts/user.blade.php index 74793a32..88e0c7f1 100644 --- a/resources/views/layouts/user.blade.php +++ b/resources/views/layouts/user.blade.php @@ -1,6 +1,6 @@ @extends('layouts.default') -@section('container-style', 'container container-small') +@section('container-style', 'container container-medium') @section('content')
diff --git a/resources/views/project/project.blade.php b/resources/views/project/project.blade.php index a50e3af1..3588ae60 100644 --- a/resources/views/project/project.blade.php +++ b/resources/views/project/project.blade.php @@ -156,4 +156,4 @@ }); @endif -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/search.blade.php b/resources/views/search.blade.php index 3136ecb6..b5a6fe80 100644 --- a/resources/views/search.blade.php +++ b/resources/views/search.blade.php @@ -68,4 +68,4 @@ }); -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/share-show.blade.php b/resources/views/share-show.blade.php index e177f530..070e5941 100644 --- a/resources/views/share-show.blade.php +++ b/resources/views/share-show.blade.php @@ -12,6 +12,8 @@ @endif
+ +
~ END ~
@endsection -@includeIf("components.{$type}-show") \ No newline at end of file +@includeIf("components.{$type}-show")