Was removed during previous changes, but reflected in response examples.
This adds into all standard single chapter responses.
For #4765
$chapter->unsetRelations()->refresh();
$chapter->load(['tags']);
$chapter->unsetRelations()->refresh();
$chapter->load(['tags']);
- $chapter->makeVisible('description_html')
- ->setAttribute('description_html', $chapter->descriptionHtml());
+ $chapter->makeVisible('description_html');
+ $chapter->setAttribute('description_html', $chapter->descriptionHtml());
+ $chapter->setAttribute('book_slug', $chapter->book()->first()->slug);
"updated_by": 1,
"owned_by": 1,
"description_html": "<p>This is a <strong>great new chapter<\/strong> that I've created via the API<\/p>",
"updated_by": 1,
"owned_by": 1,
"description_html": "<p>This is a <strong>great new chapter<\/strong> that I've created via the API<\/p>",
+ "book_slug": "example-book",
"tags": [
{
"name": "Category",
"tags": [
{
"name": "Category",
"updated_by": 1,
"owned_by": 1,
"description_html": "<p>This is an <strong>updated chapter<\/strong> that I've altered via the API<\/p>",
"updated_by": 1,
"owned_by": 1,
"description_html": "<p>This is an <strong>updated chapter<\/strong> that I've altered via the API<\/p>",
+ "book_slug": "example-book",
"tags": [
{
"name": "Category",
"tags": [
{
"name": "Category",
$resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
$resp->assertJson(['data' => [
[
$resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
$resp->assertJson(['data' => [
[
- 'id' => $firstChapter->id,
- 'name' => $firstChapter->name,
- 'slug' => $firstChapter->slug,
- 'book_id' => $firstChapter->book->id,
- 'priority' => $firstChapter->priority,
+ 'id' => $firstChapter->id,
+ 'name' => $firstChapter->name,
+ 'slug' => $firstChapter->slug,
+ 'book_id' => $firstChapter->book->id,
+ 'priority' => $firstChapter->priority,
+ 'book_slug' => $firstChapter->book->slug,
$resp->assertJson([
'id' => $chapter->id,
'slug' => $chapter->slug,
$resp->assertJson([
'id' => $chapter->id,
'slug' => $chapter->slug,
+ 'book_slug' => $chapter->book->slug,
'created_by' => [
'name' => $chapter->createdBy->name,
],
'created_by' => [
'name' => $chapter->createdBy->name,
],
+ $resp->assertJsonMissingPath('book');
$resp->assertJsonCount($chapter->pages()->count(), 'pages');
}
$resp->assertJsonCount($chapter->pages()->count(), 'pages');
}