1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Added comments controller, model, repo, and the database schema. Modified existing Page model to associate with comments.

This commit is contained in:
Abijeet
2017-01-13 21:45:48 +05:30
parent cd6572b61a
commit 397db04428
8 changed files with 143 additions and 2 deletions

35
app/Comment.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace BookStack;
class Comment extends Ownable
{
protected $fillable = ['text', 'html'];
/**
* Get the entity that this comment belongs to
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function entity()
{
return $this->morphTo('entity');
}
/**
* Get the page that this comment is in.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function page()
{
return $this->belongsTo(Page::class);
}
/**
* Get the owner of this comment.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace BookStack\Http\Controllers;
use Illuminate\Http\Request;
use BookStack\Http\Requests;
class CommentController extends Controller
{
public function add(Request $request, $pageId) {
// $this->checkOwnablePermission('page-view', $page);
}
public function update(Request $request, $id) {
// Check whether its an admin or the comment owner.
// $this->checkOwnablePermission('page-view', $page);
}
public function destroy($id) {
// Check whether its an admin or the comment owner.
// $this->checkOwnablePermission('page-view', $page);
}
public function getLastXComments($pageId) {
// $this->checkOwnablePermission('page-view', $page);
}
public function getChildComments($pageId, $id) {
// $this->checkOwnablePermission('page-view', $page);
}
}

View File

@@ -39,6 +39,15 @@ class Page extends Entity
{
return $this->belongsTo(Chapter::class);
}
/**
* Get the comments in the page.
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function comment()
{
return $this->hasMany(Comment::class);
}
/**
* Check if this page has a chapter.

17
app/Repos/CommentRepo.php Normal file
View File

@@ -0,0 +1,17 @@
<?php namespace BookStack\Repos;
use BookStack\Comment;
use BookStack\Entity;
/**
* Class TagRepo
* @package BookStack\Repos
*/
class CommentRepo {
/**
*
* @var Comment $comment
*/
protected $comment;
}