Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.
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 app/Classes/Repositories/ArticleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(Article $model)
*/
public function all()
{
return $this->model->withoutGlobalScope('public')->all();
return $this->model->all();
}

public function whereSitemappable()
Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function all()
*/
public function allDescendingOrder()
{
return $this->model->withoutGlobalScopes()->orderBy('created_at', 'desc')->get();
return $this->model->whereNull('deleted_at')->orderBy('created_at', 'desc')->get();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Roles/Administrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Administrator implements RoleInterface
*/
public function apply(Account $account)
{
return $account->update(['role_id' => self::$key]);
return $account->setAttribute('role_id', self::$key);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Roles/Developer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Developer implements RoleInterface
*/
public function apply(Account $account)
{
return $account->update(['role_id' => self::$key]);
return $account->setAttribute('role_id', self::$key);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Roles/Disabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Disabled implements RoleInterface
*/
public function apply(Account $account)
{
return $account->update(['role_id' => self::$key]);
return $account->setAttribute('role_id', self::$key);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Classes/Roles/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Publisher implements RoleInterface
*/
public function apply(Account $account)
{
return $account->update(['role_id' => self::$key]);
return $account->setAttribute('role_id', self::$key);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ public function setRole($role)
}

if ($role instanceof RoleInterface) {
$role->apply($this);

return $role->apply($this);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Modules/Accounts/Blade/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

<div class="stats">
<div class="timestamp">
Last Logged IP: {{ optional(AccessLog::latestAttemptFrom($account))->ip_address ?? 'Never' }}
Last Logged IP: {{ optional(\App\Model\AccessLog::latestAttemptFrom($account))->ip_address ?? 'Never' }}
</div>
<div class="views">
Last Login: {{ optional($account->last_login)->diffForHumans() ?? 'Never' }}
Expand Down
5 changes: 3 additions & 2 deletions app/Modules/Accounts/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ public function storeDataFrom(Request $request, Account $account)
$account->password = $request->input('password');
}

$account->save();

// assign the role from the request.
$account->setRole($request->input('role'));

// save the new account.
$account->save();

// return the data that was created.
return $account;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Account/AccountRoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class AccountRoleTest extends TestCase
*/
public function a_developer_obtains_role_of_administrator()
{
$developer = factory('App\Model\Account')->make();
$account = factory('App\Model\Account')->make();

$developer->setRole(new Developer);
$account->setRole(new Developer);

$this->assertTrue($developer->hasRole(new Administrator));
$this->assertTrue($account->hasRole(new Administrator));
}
}