Skip to content

Commit bdbaed4

Browse files
committed
Pluralise table names
1 parent 67c1e76 commit bdbaed4

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

user_guide_src/source/guides/api/code/007.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class AuthorModel extends Model
88
{
9-
protected $table = 'author';
9+
protected $table = 'authors';
1010
protected $primaryKey = 'id';
1111
protected $allowedFields = ['name'];
1212
protected $useTimestamps = true;

user_guide_src/source/guides/api/code/008.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class BookModel extends Model
88
{
9-
protected $table = 'book';
9+
protected $table = 'books';
1010
protected $primaryKey = 'id';
1111
protected $allowedFields = ['title', 'author_id', 'year'];
1212
protected $useTimestamps = true;

user_guide_src/source/guides/api/code/013.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class BookModel extends Model
88
{
9-
protected $table = 'book';
9+
protected $table = 'books';
1010
protected $allowedFields = ['title', 'author_id', 'year'];
1111

1212
/**

user_guide_src/source/guides/api/database-setup.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Creating the Database and Model
77
:local:
88
:depth: 2
99

10-
In this section, we set up the data layer by creating a SQLite database table for our ``books`` resource, seeding it with sample data, and defining a model to access it. By the end, you'll have a working ``book`` table populated with example rows.
10+
In this section, we set up the data layer by creating a SQLite database table for our ``books`` resource, seeding it with sample data, and defining a model to access it. By the end, you'll have a working ``books`` table populated with example rows.
1111

1212
Create the Migrations
1313
=====================
1414

15-
Migrations let you version-control your database schema by defining what to apply and how to roll it back. Let's make ones for simple ``author`` and ``book`` tables.
15+
Migrations let you version-control your database schema by defining what to apply and how to roll it back. Let's make ones for simple ``authors`` and ``books`` tables.
1616

1717
Run the Spark command:
1818

@@ -33,7 +33,7 @@ Now, edit **app/Database/Migrations/CreateBooksTable.php** to look like this:
3333

3434
.. literalinclude:: code/005.php
3535

36-
This contains a foreign key reference to the ``author`` table. It lets us associate each book with an author and keep author names in one place.
36+
This contains a foreign key reference to the ``authors`` table. It lets us associate each book with an author and keep author names in one place.
3737

3838
Now run the migration:
3939

@@ -58,7 +58,7 @@ Edit the file at **app/Database/Seeds/BookSeeder.php**:
5858

5959
.. literalinclude:: code/006.php
6060

61-
This seeder first inserts authors into the ``author`` table, captures their IDs, and then uses those IDs to insert books into the ``book`` table.
61+
This seeder first inserts authors into the ``authors`` table, captures their IDs, and then uses those IDs to insert books into the ``books`` table.
6262

6363
Then run the seeder:
6464

@@ -71,7 +71,7 @@ You should see confirmation messages indicating the rows were inserted.
7171
Create the Book model
7272
=====================
7373

74-
Models make database access simple and reusable by providing an object-oriented interface to your tables and a fluent query API. Let's create models for the ``author`` and ``book`` tables.
74+
Models make database access simple and reusable by providing an object-oriented interface to your tables and a fluent query API. Let's create models for the ``authors`` and ``books`` tables.
7575

7676
Generate one:
7777

user_guide_src/source/guides/api/first-endpoint.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ The ``respond()`` method can return additional data:
115115

116116
.. literalinclude:: code/003.php
117117

118-
You now have a working endpoint tested in both the browser and cURL. In the next section, we'll create our first real database resource. You'll define a **migration**, **seeder**, and **model** for a simple ``book`` table that powers the API's CRUD endpoints.
118+
You now have a working endpoint tested in both the browser and cURL. In the next section, we'll create our first real database resource. You'll define a **migration**, **seeder**, and **model** for a simple ``books`` table that powers the API's CRUD endpoints.

0 commit comments

Comments
 (0)