/**
* Get the book this page sits in.
- * @return BelongsTo
*/
public function book(): BelongsTo
{
- return $this->belongsTo(Book::class);
+ return $this->belongsTo(Book::class)->withTrashed();
}
/**
*/
public function forJsonDisplay(): Page
{
- $refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy']);
+ $refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy', 'ownedBy']);
$refreshed->setHidden(array_diff($refreshed->getHidden(), ['html', 'markdown']));
$refreshed->html = (new PageContent($refreshed))->render();
return $refreshed;
{
$books = Book::visible();
return $this->apiListingResponse($books, [
- 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'image_id',
+ 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
]);
}
*/
public function read(string $id)
{
- $book = Book::visible()->with(['tags', 'cover', 'createdBy', 'updatedBy'])->findOrFail($id);
+ $book = Book::visible()->with(['tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy'])->findOrFail($id);
return response()->json($book);
}
{
$shelves = Bookshelf::visible();
return $this->apiListingResponse($shelves, [
- 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'image_id',
+ 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
]);
}
public function read(string $id)
{
$shelf = Bookshelf::visible()->with([
- 'tags', 'cover', 'createdBy', 'updatedBy',
+ 'tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy',
'books' => function (BelongsToMany $query) {
$query->visible()->get(['id', 'name', 'slug']);
}
$chapters = Chapter::visible();
return $this->apiListingResponse($chapters, [
'id', 'book_id', 'name', 'slug', 'description', 'priority',
- 'created_at', 'updated_at', 'created_by', 'updated_by',
+ 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by',
]);
}
*/
public function read(string $id)
{
- $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'pages' => function (HasMany $query) {
+ $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'ownedBy', 'pages' => function (HasMany $query) {
$query->visible()->get(['id', 'name', 'slug']);
}])->findOrFail($id);
return response()->json($chapter);
return $this->apiListingResponse($pages, [
'id', 'book_id', 'chapter_id', 'name', 'slug', 'priority',
'draft', 'template',
- 'created_at', 'updated_at', 'created_by', 'updated_by',
+ 'created_at', 'updated_at',
+ 'created_by', 'updated_by', 'owned_by',
]);
}
"description": "This is a book created via the API",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"slug": "my-new-book",
"updated_at": "2020-01-12 14:05:11",
"created_at": "2020-01-12 14:05:11",
"updated_at": "2019-12-11 20:57:31",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"image_id": 3
},
{
"updated_at": "2019-12-11 20:57:23",
"created_by": 4,
"updated_by": 3,
+ "owned_by": 3,
"image_id": 34
}
],
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"tags": [
{
"id": 13,
"updated_at": "2020-01-12 14:16:10",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"image_id": 452
}
\ No newline at end of file
"description": "This is a great new chapter that I've created via the API",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"slug": "my-fantastic-new-chapter",
"updated_at": "2020-05-22 22:59:55",
"created_at": "2020-05-22 22:59:55",
"created_at": "2019-05-05 21:49:56",
"updated_at": "2019-09-28 11:24:23",
"created_by": 1,
- "updated_by": 1
+ "updated_by": 1,
+ "owned_by": 1
},
{
"id": 2,
"created_at": "2019-05-05 21:58:07",
"updated_at": "2019-10-17 15:05:34",
"created_by": 3,
- "updated_by": 3
+ "updated_by": 3,
+ "owned_by": 3
}
],
"total": 40
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"tags": [
{
"name": "Category",
"updated_at": "2020-05-22 23:07:20",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"book": {
"id": 1,
"name": "BookStack User Guide",
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"draft": false,
"markdown": "",
"revision_count": 1,
"created_at": "2019-05-05 21:49:58",
"updated_at": "2020-07-04 15:50:58",
"created_by": 1,
- "updated_by": 1
+ "updated_by": 1,
+ "owned_by": 1
},
{
"id": 2,
"created_at": "2019-05-05 21:53:30",
"updated_at": "2019-06-06 12:03:04",
"created_by": 1,
- "updated_by": 1
+ "updated_by": 1,
+ "owned_by": 1
},
{
"id": 3,
"created_at": "2019-05-05 21:53:49",
"updated_at": "2019-12-18 21:56:52",
"created_by": 1,
- "updated_by": 1
+ "updated_by": 1,
+ "owned_by": 1
}
],
"total": 322
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"draft": false,
"markdown": "# How this is built\r\n\r\nThis page is written in markdown. BookStack stores the page data in HTML.\r\n\r\nHere's a cute picture of my cat:\r\n\r\n[](http://example.com/uploads/images/gallery/2020-04/yXSrubes.jpg)",
"revision_count": 5,
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"draft": false,
"markdown": "",
"revision_count": 5,
"description": "This is my shelf with some books",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"slug": "my-shelf",
"updated_at": "2020-04-10 13:24:09",
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:00:45",
"created_by": 4,
"updated_by": 1,
+ "owned_by": 1,
"image_id": 31
},
{
"updated_at": "2020-04-10 13:00:58",
"created_by": 4,
"updated_by": 1,
+ "owned_by": 1,
"image_id": 28
},
{
"updated_at": "2020-04-10 13:00:53",
"created_by": 4,
"updated_by": 1,
+ "owned_by": 4,
"image_id": 30
}
],
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:31:04",
"tags": [
"description": "This is my update shelf with some books",
"created_by": 1,
"updated_by": 1,
+ "owned_by": 1,
"image_id": 501,
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:48:22"
this.editorType = this.$opts.editorType;
this.pageId = Number(this.$opts.pageId);
this.isNewDraft = this.$opts.pageNewDraft === 'true';
- this.hasDefaultTitle = this.$opts.isDefaultTitle || false;
+ this.hasDefaultTitle = this.$opts.hasDefaultTitle || false;
// Elements
this.container = this.$el;
}
setInitialFocus() {
+ console.log({'HAS': this.hasDefaultTitle});
if (this.hasDefaultTitle) {
return this.titleElem.select();
}
],
'updated_by' => [
'name' => $book->createdBy->name,
- ]
+ ],
+ 'owned_by' => [
+ 'name' => $book->ownedBy->name
+ ],
]);
}
'updated_by' => [
'name' => $chapter->createdBy->name,
],
+ 'owned_by' => [
+ 'name' => $chapter->ownedBy->name
+ ],
'pages' => [
[
'id' => $page->id,
'updated_by' => [
'name' => $page->createdBy->name,
],
+ 'owned_by' => [
+ 'name' => $page->ownedBy->name
+ ],
]);
}
],
'updated_by' => [
'name' => $shelf->createdBy->name,
- ]
+ ],
+ 'owned_by' => [
+ 'name' => $shelf->ownedBy->name
+ ],
]);
}