diff --git a/config/laravel_ticket.php b/config/laravel_ticket.php index 4f5c6ac..429083e 100644 --- a/config/laravel_ticket.php +++ b/config/laravel_ticket.php @@ -31,7 +31,7 @@ '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" @@ -39,8 +39,8 @@ * @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', ], ], /** diff --git a/database/migrations/create_messages_table.php.stub b/database/migrations/create_messages_table.php.stub index 0a75417..b09515c 100644 --- a/database/migrations/create_messages_table.php.stub +++ b/database/migrations/create_messages_table.php.stub @@ -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(); }); diff --git a/src/Models/Message.php b/src/Models/Message.php index 6ed9a4a..7b62db1 100644 --- a/src/Models/Message.php +++ b/src/Models/Message.php @@ -32,7 +32,7 @@ public function ticket(): BelongsTo return $this->belongsTo( Ticket::class, - $tableName['columns']['ticket_foreing_id'] + $tableName['columns']['ticket_foreign_id'] ); } @@ -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'] ); } diff --git a/src/Models/Ticket.php b/src/Models/Ticket.php index 1609ad2..316c76f 100644 --- a/src/Models/Ticket.php +++ b/src/Models/Ticket.php @@ -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'], ); } diff --git a/tests/Database/Factories/MessageFactory.php b/tests/Database/Factories/MessageFactory.php index 40e176a..9a1fb7c 100644 --- a/tests/Database/Factories/MessageFactory.php +++ b/tests/Database/Factories/MessageFactory.php @@ -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), ]; } diff --git a/tests/Unit/MessageTest.php b/tests/Unit/MessageTest.php index 4b6cbf2..52fe3f1 100644 --- a/tests/Unit/MessageTest.php +++ b/tests/Unit/MessageTest.php @@ -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', ]);