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 reference compatibility issues #67

Merged
merged 1 commit into from
Dec 28, 2020
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
2 changes: 1 addition & 1 deletion src/Feature/SetupModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function setupUserModel()
// all AccessRules for all user roles
// @TODO in future when there can be multiple, then merge them together
$this->hasMany('AccessRules', [
function ($m) {
'model' => function ($m) {
return $m->ref('role_id')->ref('AccessRules');
},
'our_field' => 'role_id',
Expand Down
2 changes: 1 addition & 1 deletion src/Model/AccessRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function init(): void
{
parent::init();

$this->hasOne('role_id', [Role::class, 'our_field' => 'role_id', 'their_field' => 'id', 'caption' => 'Role'])->withTitle();
$this->hasOne('role_id', ['model' => [Role::class], 'our_field' => 'role_id', 'their_field' => 'id', 'caption' => 'Role'])->withTitle();

$this->addField('model'); // model class name

Expand Down
4 changes: 2 additions & 2 deletions src/Model/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ protected function init(): void

$this->addField('name');

$this->hasMany('Users', [User::class, 'our_field' => 'id', 'their_field' => 'role_id']);
$this->hasMany('AccessRules', [AccessRule::class, 'our_field' => 'id', 'their_field' => 'role_id']);
$this->hasMany('Users', ['model' => [User::class], 'our_field' => 'id', 'their_field' => 'role_id']);
$this->hasMany('AccessRules', ['model' => [AccessRule::class], 'our_field' => 'id', 'their_field' => 'role_id']);

// traits
$this->setupRoleModel();
Expand Down
2 changes: 1 addition & 1 deletion src/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function init(): void
$this->addField('password', [Password::class]);

// currently user can have only one role. In future it should be n:n relation
$this->hasOne('role_id', [Role::class, 'our_field' => 'role_id', 'their_field' => 'id', 'caption' => 'Role'])->withTitle();
$this->hasOne('role_id', ['model' => [Role::class], 'our_field' => 'role_id', 'their_field' => 'id', 'caption' => 'Role'])->withTitle();

// traits
$this->setupUserModel();
Expand Down
6 changes: 3 additions & 3 deletions tests/Generic.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ protected function setupDefaultDb()

protected function getUserModel()
{
return new User($this->db, 'login_user');
return new User($this->db, ['table' => 'login_user']);
}

protected function getRoleModel()
{
return new Role($this->db, 'login_role');
return new Role($this->db, ['table' => 'login_role']);
}

protected function getAccessRuleModel()
{
return new AccessRule($this->db, 'login_access_rule');
return new AccessRule($this->db, ['table' => 'login_access_rule']);
}
}