Skip to content

Commit 155e117

Browse files
committed
Resolve laravel-portugal#31 - An authenticated user can post an answer to a question (Rename Table name)
1 parent a9adae2 commit 155e117

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

domains/Discussions/Database/Migrations/2020_10_19_175943_create_questions_answers_table.php renamed to domains/Discussions/Database/Migrations/2020_10_19_175943_create_question_answers_table.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\Schema;
88

9-
class CreateQuestionsAnswersTable extends Migration
9+
class CreateQuestionAnswersTable extends Migration
1010
{
1111
/**
1212
* Run the migrations.
@@ -15,7 +15,7 @@ class CreateQuestionsAnswersTable extends Migration
1515
*/
1616
public function up()
1717
{
18-
Schema::create('questions_answers', function (Blueprint $table) {
18+
Schema::create('question_answers', function (Blueprint $table) {
1919
$table->id();
2020
$table->foreignIdFor(User::class, 'author_id');
2121
$table->foreignIdFor(Question::class, 'question_id');

domains/Discussions/Models/Answer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Answer extends Model
1111
{
1212
use SoftDeletes;
1313

14-
protected $table = 'questions_answers';
14+
protected $table = 'question_answers';
1515

1616
public function author(): BelongsTo
1717
{

domains/Discussions/Tests/Feature/AnswersStoreTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function it_stores_answer(): void
4242

4343
self::assertTrue($response->isEmpty());
4444

45-
$this->seeInDatabase('questions_answers', [
45+
$this->seeInDatabase('question_answers', [
4646
'author_id' => $this->user->id,
4747
'question_id' => $this->question->id,
4848
'content' => $payload['content']

domains/Discussions/Tests/Unit/AnswerModelTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function it_contains_required_properties(): void
3737
/** @test */
3838
public function it_uses_correct_table_name(): void
3939
{
40-
self::assertEquals('questions_answers', $this->model->getTable());
40+
self::assertEquals('question_answers', $this->model->getTable());
4141
}
4242

4343
/** @test */

0 commit comments

Comments
 (0)