Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo in foreign #50

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/laravel_ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
'messages' => [
'table' => 'messages',
/**
* This is the foreing key for associated to the ticket
* This is the foreign key for associated to the ticket
* If you renamed the ticket table, you should consider
* changing this column as well to follow the laravel
* convention, "table_id"
*
* @see https://laravel.com/docs/9.x/eloquent-relationships#one-to-many
*/
'columns' => [
'user_foreing_id' => 'user_id',
'ticket_foreing_id' => 'ticket_id',
'user_foreign_id' => 'user_id',
'ticket_foreign_id' => 'ticket_id',
],
],
/**
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/create_messages_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ return new class extends Migration

Schema::create($tableName['table'], function (Blueprint $table) use ($tableName) {
$table->id();
$table->foreignId($tableName['columns']['user_foreing_id']);
$table->foreignId($tableName['columns']['ticket_foreing_id']);
$table->foreignId($tableName['columns']['user_foreign_id']);
$table->foreignId($tableName['columns']['ticket_foreign_id']);
$table->text('message');
$table->timestamps();
});
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function ticket(): BelongsTo

return $this->belongsTo(
Ticket::class,
$tableName['columns']['ticket_foreing_id']
$tableName['columns']['ticket_foreign_id']
);
}

Expand All @@ -45,7 +45,7 @@ public function user(): BelongsTo

return $this->belongsTo(
config('auth.providers.users.model'),
$tableName['columns']['user_foreing_id']
$tableName['columns']['user_foreign_id']
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function messages(): HasMany

return $this->hasMany(
Message::class,
(string) $tableName['columns']['ticket_foreing_id'],
(string) $tableName['columns']['ticket_foreign_id'],
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Database/Factories/MessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function definition()

return [
'user_id' => User::factory(),
$tableName['columns']['ticket_foreing_id'] => Ticket::factory(),
$tableName['columns']['ticket_foreign_id'] => Ticket::factory(),
'message' => $this->faker->paragraph(2),
];
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

$message = Message::factory()
->create([
$tableName['columns']['ticket_foreing_id'] => $ticket->id,
$tableName['columns']['ticket_foreign_id'] => $ticket->id,
'message' => 'Message from a ticket',
]);

$this->assertDatabaseHas($tableName['table'], [
$tableName['columns']['ticket_foreing_id'] => $ticket->id,
$tableName['columns']['ticket_foreign_id'] => $ticket->id,
'message' => 'Message from a ticket',
]);

Expand Down
Loading