Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag update #6

Merged
merged 16 commits into from
May 30, 2018
Prev Previous commit
Next Next commit
标签阶段性提交
  • Loading branch information
ro4 committed May 11, 2018
commit 6a8529e45c248254a21c7ef3355f840a2a85143c
10 changes: 10 additions & 0 deletions app/Repositories/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
19 changes: 19 additions & 0 deletions app/Repositories/PageTag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Repositories;

/**
* Class Tag
*
* @property integer $id
* @property integer $page_id
* @property integer $tag_id
*
* @package App\Repositories
*/
class PageTag extends Repository
{
protected $table = 'wz_page_tag';
public $timestamps = false;
protected $fillable = ['page_id', 'tag_id'];
}
31 changes: 31 additions & 0 deletions app/Repositories/Tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Repositories;

use Carbon\Carbon;

/**
* Class Tag
*
* @property integer $id
* @property string $name
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Repositories
*/
class Tag extends Repository
{
protected $table = 'wz_tags';
protected $fillable = ['name'];

/**
* 标签的页面
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function pages()
{
return $this->belongsToMany(Document::class, 'wz_page_tag', 'tag_id', 'page_id');
}
}
5 changes: 5 additions & 0 deletions resources/views/components/tags.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p class="wz-document-header">
@foreach($pageItem->tags as $tag)
<span class="badge badge-pill badge-primary">{{$tag->name}}</span>
@endforeach
</p>
4 changes: 2 additions & 2 deletions resources/views/project/project.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
@endif
</h1>
</nav>

@include('components.tags')
@include('components.document-info')

<hr>
<div class="markdown-body wz-panel-limit {{ $type == 'markdown' ? 'wz-markdown-style-fix' : '' }}" id="markdown-body">
@if($type == 'markdown')
<textarea id="append-test" class="d-none">{{ $pageItem->content }}</textarea>
Expand Down