Skip to content

Implement 'belongs to' relations in models #93

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

Merged
merged 14 commits into from
Mar 12, 2025
Prev Previous commit
Next Next commit
Fix failing tests
  • Loading branch information
SOHELAHMED7 committed Mar 3, 2025
commit e69fc04d55f2e88844483872c8c2eb7d7bef46b5
5 changes: 0 additions & 5 deletions tests/specs/blog/models/base/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,4 @@ public function getPosts()
{
return $this->hasMany(\app\models\Post::class, ['category_id' => 'id'])->inverseOf('category');
}

public function getPost()
{
return $this->hasOne(\app\models\Post::class, ['category_id' => 'id'])->inverseOf('category');
}
}
5 changes: 0 additions & 5 deletions tests/specs/blog/models/base/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,4 @@ public function getComments()
{
return $this->hasMany(\app\models\Comment::class, ['post_id' => 'uid'])->inverseOf('post');
}

public function getComment()
{
return $this->hasOne(\app\models\Comment::class, ['post_id' => 'uid'])->inverseOf('post');
}
}
10 changes: 0 additions & 10 deletions tests/specs/blog/models/base/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,4 @@ public function rules()
'email_unique' => [['email'], 'unique'],
];
}

public function getPost()
{
return $this->hasOne(\app\models\Post::class, ['created_by_id' => 'id'])->inverseOf('created_by');
}

public function getComment2()
{
return $this->hasOne(\app\models\Comment::class, ['author_id' => 'id'])->inverseOf('author');
}
}
5 changes: 0 additions & 5 deletions tests/specs/blog_v2/models/base/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,4 @@ public function getPosts()
{
return $this->hasMany(\app\models\Post::class, ['category_id' => 'id'])->inverseOf('category');
}

public function getPost()
{
return $this->hasOne(\app\models\Post::class, ['category_id' => 'id'])->inverseOf('category');
}
}
5 changes: 0 additions & 5 deletions tests/specs/blog_v2/models/base/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,4 @@ public function getTags()
return $this->hasMany(\app\models\Tag::class, ['id' => 'tag_id'])
->viaTable('posts2tags', ['post_id' => 'id']);
}

public function getComment()
{
return $this->hasOne(\app\models\Comment::class, ['post_id' => 'id'])->inverseOf('post');
}
}
10 changes: 0 additions & 10 deletions tests/specs/blog_v2/models/base/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,4 @@ public function rules()
'email_unique' => [['email'], 'unique'],
];
}

public function getPost()
{
return $this->hasOne(\app\models\Post::class, ['created_by_id' => 'id'])->inverseOf('created_by');
}

public function getComment2()
{
return $this->hasOne(\app\models\Comment::class, ['user_id' => 'id'])->inverseOf('user');
}
}
5 changes: 0 additions & 5 deletions tests/specs/fk_col_name/app/models/base/Delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ public function rules()
'title_string' => [['title'], 'string'],
];
}

public function getWebhook()
{
return $this->hasOne(\app\models\Webhook::class, ['redelivery_of' => 'id'])->inverseOf('redelivery_of');
}
}
5 changes: 0 additions & 5 deletions tests/specs/fk_col_name/app/models/base/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getWebhook()
{
return $this->hasOne(\app\models\Webhook::class, ['user_id' => 'id'])->inverseOf('user');
}
}
10 changes: 0 additions & 10 deletions tests/specs/fk_col_name_index/app/models/base/Delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,4 @@ public function rules()
'title_string' => [['title'], 'string'],
];
}

public function getWebhook()
{
return $this->hasOne(\app\models\Webhook::class, ['redelivery_of' => 'id'])->inverseOf('redelivery_of');
}

public function getWebhook2()
{
return $this->hasOne(\app\models\Webhook::class, ['rd_abc_2' => 'id'])->inverseOf('rd2');
}
}
5 changes: 0 additions & 5 deletions tests/specs/fk_col_name_index/app/models/base/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getWebhook()
{
return $this->hasOne(\app\models\Webhook::class, ['user_id' => 'id'])->inverseOf('user');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,4 @@ public function rules()
'paymentMethodName_string' => [['paymentMethodName'], 'string'],
];
}

public function getContact()
{
return $this->hasOne(\app\models\Contact::class, ['mailing_id' => 'id'])->inverseOf('mailing');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,4 @@ public function rules()
{
return [];
}

public function getOrder()
{
return $this->hasOne(\app\models\Order::class, ['invoice_id' => 'id'])->inverseOf('invoice');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,4 @@ public function rules()
'paymentMethodName_string' => [['paymentMethodName'], 'string'],
];
}

public function getContact()
{
return $this->hasOne(\app\models\Contact::class, ['account_id' => 'id'])->inverseOf('account');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,4 @@ public function getAccounts()
{
return $this->hasMany(\app\models\Account::class, ['user_id' => 'id'])->inverseOf('user');
}

public function getAccount()
{
return $this->hasOne(\app\models\Account::class, ['user_id' => 'id'])->inverseOf('user');
}

public function getAccount2()
{
return $this->hasOne(\app\models\Account::class, ['user2_id' => 'id'])->inverseOf('user2');
}

public function getAccount3()
{
return $this->hasOne(\app\models\Account::class, ['user3' => 'id'])->inverseOf('user3');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getPost()
{
return $this->hasOne(\app\models\Post::class, ['user' => 'id'])->inverseOf('user');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getInvoice()
{
return $this->hasOne(\app\models\Invoice::class, ['animal_id' => 'id'])->inverseOf('animal');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getInvoice()
{
return $this->hasOne(\app\models\Invoice::class, ['fruit_id' => 'id'])->inverseOf('fruit');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getInvoice()
{
return $this->hasOne(\app\models\Invoice::class, ['user_id' => 'id'])->inverseOf('user');
}

public function getInvoice2()
{
return $this->hasOne(\app\models\Invoice::class, ['user_2_id' => 'id'])->inverseOf('user_2');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,4 @@ public function rules()
'name_string' => [['name'], 'string', 'max' => 40],
];
}

public function getE123()
{
return $this->hasOne(\app\models\E123::class, ['account_id' => 'id'])->inverseOf('account');
}

public function getE1232()
{
return $this->hasOne(\app\models\E123::class, ['account_2_id' => 'id'])->inverseOf('account_2');
}

public function getE1233()
{
return $this->hasOne(\app\models\E123::class, ['account_3_id' => 'id'])->inverseOf('account_3');
}
}
5 changes: 0 additions & 5 deletions tests/specs/petstore/models/base/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getPet()
{
return $this->hasOne(\app\models\Pet::class, ['store_id' => 'id'])->inverseOf('store');
}
}
5 changes: 0 additions & 5 deletions tests/specs/petstore_jsonapi/models/base/Pet.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,4 @@ public function getDuplicates()
{
return $this->hasMany(\app\models\Pet::class, ['tag' => 'tag']);
}

public function getPetStatistic()
{
return $this->hasOne(\app\models\PetStatistic::class, ['parentPet_id' => 'id'])->inverseOf('parentPet');
}
}
5 changes: 0 additions & 5 deletions tests/specs/petstore_namespace/mymodels/base/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getPet()
{
return $this->hasOne(\app\mymodels\Pet::class, ['store_id' => 'id'])->inverseOf('store');
}
}
5 changes: 0 additions & 5 deletions tests/specs/relations_in_faker/app/models/base/A123.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,4 @@ public function getB123()
{
return $this->hasOne(\app\models\B123::class, ['id' => 'b123_id']);
}

public function getRouting()
{
return $this->hasOne(\app\models\Routing::class, ['a123_id' => 'id'])->inverseOf('a123');
}
}
5 changes: 0 additions & 5 deletions tests/specs/relations_in_faker/app/models/base/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ public function rules()
'name_string' => [['name'], 'string', 'max' => 40],
];
}

public function getDomain()
{
return $this->hasOne(\app\models\Domain::class, ['account_id' => 'id'])->inverseOf('account');
}
}
10 changes: 0 additions & 10 deletions tests/specs/relations_in_faker/app/models/base/B123.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,4 @@ public function getC123()
{
return $this->hasOne(\app\models\C123::class, ['id' => 'c123_id']);
}

public function getA123()
{
return $this->hasOne(\app\models\A123::class, ['b123_id' => 'id'])->inverseOf('b123');
}

public function getE1232()
{
return $this->hasOne(\app\models\E123::class, ['b123_id' => 'id'])->inverseOf('b123');
}
}
5 changes: 0 additions & 5 deletions tests/specs/relations_in_faker/app/models/base/C123.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getB123()
{
return $this->hasOne(\app\models\B123::class, ['c123_id' => 'id'])->inverseOf('c123');
}
}
5 changes: 0 additions & 5 deletions tests/specs/relations_in_faker/app/models/base/D123.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ public function rules()
'name_string' => [['name'], 'string'],
];
}

public function getRouting()
{
return $this->hasOne(\app\models\Routing::class, ['d123_id' => 'id'])->inverseOf('d123');
}
}
5 changes: 0 additions & 5 deletions tests/specs/relations_in_faker/app/models/base/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,4 @@ public function getRoutings()
{
return $this->hasMany(\app\models\Routing::class, ['domain_id' => 'id'])->inverseOf('domain');
}

public function getRouting()
{
return $this->hasOne(\app\models\Routing::class, ['domain_id' => 'id'])->inverseOf('domain');
}
}