Skip to content

Commit

Permalink
Renamed foreign_key_col_in_this_models_table => relationship_col_in_m…
Browse files Browse the repository at this point in the history
…y_table
  • Loading branch information
rotimi committed Jul 22, 2024
1 parent fc69f20 commit ada977c
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 85 deletions.
6 changes: 3 additions & 3 deletions class-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ $authorsModel = new \LeanOrm\Model(

$authorsModel->hasMany(
relation_name: 'posts',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_table_name: 'posts',
primary_key_col_in_foreign_table: 'post_id'
Expand Down Expand Up @@ -1112,7 +1112,7 @@ class PostsModel extends \LeanOrm\Model {

$authorsModel->hasMany(
relation_name: 'posts',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_models_class_name: PostsModel::class
); // does the same thing as the previous call to hasMany above
Expand All @@ -1133,7 +1133,7 @@ $postsModel = new \LeanOrm\Model(

$postsModel->belongsTo(
relation_name: 'author',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_table_name: 'authors',
primary_key_col_in_foreign_table: 'author_id'
Expand Down Expand Up @@ -1177,7 +1177,7 @@ class AuthorsModel extends \LeanOrm\Model {

$postsModel->belongsTo(
relation_name: 'author',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_models_class_name: AuthorsModel::class
);
Expand Down Expand Up @@ -1267,7 +1267,7 @@ $postsModel = new \LeanOrm\Model (

$postsModel->hasOne(
relation_name: 'summary',
foreign_key_col_in_this_models_table: 'post_id',
relationship_col_in_my_table: 'post_id',
foreign_key_col_in_foreign_table: 'post_id',
foreign_table_name: 'summaries',
primary_key_col_in_foreign_table: 'summary_id'
Expand Down Expand Up @@ -1311,7 +1311,7 @@ class SummariesModel extends \LeanOrm\Model {

$postsModel->hasOne(
relation_name: 'summary',
foreign_key_col_in_this_models_table: 'post_id',
relationship_col_in_my_table: 'post_id',
foreign_key_col_in_foreign_table: 'post_id',
foreign_models_class_name: SummariesModel::class
); // Post has one Summary
Expand Down Expand Up @@ -1354,7 +1354,7 @@ class AuthorsModel extends \LeanOrm\Model {

$this->hasMany(
relation_name: 'posts',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_models_class_name: PostsModel::class
); // Author has Many Posts
Expand Down Expand Up @@ -1384,14 +1384,14 @@ class PostsModel extends \LeanOrm\Model {

$this->belongsTo(
relation_name: 'author',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_models_class_name: AuthorsModel::class
); // Post belongs to an Author

$this->hasOne(
relation_name: 'summary',
foreign_key_col_in_this_models_table: 'post_id',
relationship_col_in_my_table: 'post_id',
foreign_key_col_in_foreign_table: 'post_id',
foreign_models_class_name: SummariesModel::class
); // Post has one Summary
Expand Down Expand Up @@ -1508,7 +1508,7 @@ $authorsModel = new \LeanOrm\Model(

$authorsModel->hasMany(
relation_name: 'posts',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_key_col_in_foreign_table: 'author_id',
foreign_models_class_name: PostsModel::class,
sql_query_modifier: function(\Aura\SqlQuery\Common\Select $selectObj): \Aura\SqlQuery\Common\Select {
Expand Down
18 changes: 9 additions & 9 deletions src/LeanOrm/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@ public function hasOne(
// for the related data when data is fetched into arrays
// via this model

string $foreign_key_col_in_this_models_table,
string $relationship_col_in_my_table,

string $foreign_key_col_in_foreign_table,

Expand Down Expand Up @@ -2738,13 +2738,13 @@ public function hasOne(

$this->validateTableName($foreign_table_name);

$this->validateThatTableHasColumn($this->getTableName(), $foreign_key_col_in_this_models_table);
$this->validateThatTableHasColumn($this->getTableName(), $relationship_col_in_my_table);
$this->validateThatTableHasColumn($foreign_table_name, $foreign_key_col_in_foreign_table);
$this->validateThatTableHasColumn($foreign_table_name, $primary_key_col_in_foreign_table);

$this->relations[$relation_name] = [];
$this->relations[$relation_name]['relation_type'] = \GDAO\Model::RELATION_TYPE_HAS_ONE;
$this->relations[$relation_name]['foreign_key_col_in_my_table'] = $foreign_key_col_in_this_models_table;
$this->relations[$relation_name]['foreign_key_col_in_my_table'] = $relationship_col_in_my_table;
$this->relations[$relation_name]['foreign_table'] = $foreign_table_name;
$this->relations[$relation_name]['foreign_key_col_in_foreign_table'] = $foreign_key_col_in_foreign_table;
$this->relations[$relation_name]['primary_key_col_in_foreign_table'] = $primary_key_col_in_foreign_table;
Expand All @@ -2768,7 +2768,7 @@ public function belongsTo(
// for the related data when data is fetched into arrays
// via this model

string $foreign_key_col_in_this_models_table,
string $relationship_col_in_my_table,

string $foreign_key_col_in_foreign_table,

Expand Down Expand Up @@ -2816,13 +2816,13 @@ public function belongsTo(

$this->validateTableName($foreign_table_name);

$this->validateThatTableHasColumn($this->getTableName(), $foreign_key_col_in_this_models_table);
$this->validateThatTableHasColumn($this->getTableName(), $relationship_col_in_my_table);
$this->validateThatTableHasColumn($foreign_table_name, $foreign_key_col_in_foreign_table);
$this->validateThatTableHasColumn($foreign_table_name, $primary_key_col_in_foreign_table);

$this->relations[$relation_name] = [];
$this->relations[$relation_name]['relation_type'] = \GDAO\Model::RELATION_TYPE_BELONGS_TO;
$this->relations[$relation_name]['foreign_key_col_in_my_table'] = $foreign_key_col_in_this_models_table;
$this->relations[$relation_name]['foreign_key_col_in_my_table'] = $relationship_col_in_my_table;
$this->relations[$relation_name]['foreign_table'] = $foreign_table_name;
$this->relations[$relation_name]['foreign_key_col_in_foreign_table'] = $foreign_key_col_in_foreign_table;
$this->relations[$relation_name]['primary_key_col_in_foreign_table'] = $primary_key_col_in_foreign_table;
Expand All @@ -2847,7 +2847,7 @@ public function hasMany(
// for the related data when data is fetched into arrays
// via this model

string $foreign_key_col_in_this_models_table,
string $relationship_col_in_my_table,

string $foreign_key_col_in_foreign_table,

Expand Down Expand Up @@ -2896,13 +2896,13 @@ public function hasMany(

$this->validateTableName($foreign_table_name);

$this->validateThatTableHasColumn($this->getTableName(), $foreign_key_col_in_this_models_table);
$this->validateThatTableHasColumn($this->getTableName(), $relationship_col_in_my_table);
$this->validateThatTableHasColumn($foreign_table_name, $foreign_key_col_in_foreign_table);
$this->validateThatTableHasColumn($foreign_table_name, $primary_key_col_in_foreign_table);

$this->relations[$relation_name] = [];
$this->relations[$relation_name]['relation_type'] = \GDAO\Model::RELATION_TYPE_HAS_MANY;
$this->relations[$relation_name]['foreign_key_col_in_my_table'] = $foreign_key_col_in_this_models_table;
$this->relations[$relation_name]['foreign_key_col_in_my_table'] = $relationship_col_in_my_table;
$this->relations[$relation_name]['foreign_table'] = $foreign_table_name;
$this->relations[$relation_name]['foreign_key_col_in_foreign_table'] = $foreign_key_col_in_foreign_table;
$this->relations[$relation_name]['primary_key_col_in_foreign_table'] = $primary_key_col_in_foreign_table;
Expand Down
2 changes: 1 addition & 1 deletion tests/CommonPropertiesAndMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected function setUp(): void {
)
->hasMany(
relation_name: 'posts',
foreign_key_col_in_this_models_table: 'author_id',
relationship_col_in_my_table: 'author_id',
foreign_table_name: 'posts',
foreign_key_col_in_foreign_table: 'author_id',
primary_key_col_in_foreign_table: 'post_id',
Expand Down
Loading

0 comments on commit ada977c

Please sign in to comment.