Skip to content

Commit 7ea8c42

Browse files
committed
Bug Fix
1 parent 767843c commit 7ea8c42

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

src/Darryldecode/Backend/Base/Registrar/Registrar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Registrar {
1313
/**
1414
* the laravel backend version
1515
*/
16-
const VERSION = '1.0.17';
16+
const VERSION = '1.0.18';
1717
const VERSION_NAME = 'Alpha';
1818

1919
/**

src/Darryldecode/Backend/Components/User/Commands/CreateUserCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function handle(User $user, Factory $validator, Dispatcher $dispatcher, G
9494
'last_name' => $this->lastName,
9595
'email' => $this->email,
9696
'password' => $this->password,
97-
), $this->user->getValidationRules());
97+
), $user->getValidationRules());
9898

9999
if( $validationResult->fails() )
100100
{
@@ -170,7 +170,11 @@ protected function transform($permissions)
170170
*/
171171
protected function createUserModel($user, $config)
172172
{
173-
$userModelUsed = $config->get('backend.backend.user_model');
173+
if( ! $userModelUsed = $config->get('backend.backend.user_model') )
174+
{
175+
return $user;
176+
}
177+
174178
$userModelUsed = new $userModelUsed();
175179

176180
if( $userModelUsed instanceof User )

src/Darryldecode/Backend/Components/User/Commands/DeleteUserCommand.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Darryldecode\Backend\Components\User\Models\Group;
1515
use Illuminate\Contracts\Bus\SelfHandling;
1616
use Illuminate\Contracts\Events\Dispatcher;
17+
use Illuminate\Config\Repository;
1718

1819
class DeleteUserCommand extends Command implements SelfHandling {
1920
/**
@@ -41,9 +42,10 @@ public function __construct($id = null, $disablePermissionChecking = false)
4142
* @param User $user
4243
* @param Group $group
4344
* @param Dispatcher $dispatcher
45+
* @param Repository $config
4446
* @return CommandResult
4547
*/
46-
public function handle(User $user, Group $group, Dispatcher $dispatcher)
48+
public function handle(User $user, Group $group, Dispatcher $dispatcher, Repository $config)
4749
{
4850
// check user permission
4951
if( ! $this->disablePermissionChecking )
@@ -58,6 +60,9 @@ public function handle(User $user, Group $group, Dispatcher $dispatcher)
5860
}
5961
}
6062

63+
// prepare the user model
64+
$user = $this->createUserModel($user, $config);
65+
6166
// find the user
6267
if( ! $userToBeDelete = $user->find($this->id) )
6368
{
@@ -77,4 +82,26 @@ public function handle(User $user, Group $group, Dispatcher $dispatcher)
7782
// all good
7883
return new CommandResult(true, "User successfully deleted.", null, 200);
7984
}
85+
86+
/**
87+
* @param $user \Darryldecode\Backend\Components\User\Models\User
88+
* @param $config \Illuminate\Config\Repository
89+
* @return mixed
90+
*/
91+
protected function createUserModel($user, $config)
92+
{
93+
if( ! $userModelUsed = $config->get('backend.backend.user_model') )
94+
{
95+
return $user;
96+
}
97+
98+
$userModelUsed = new $userModelUsed();
99+
100+
if( $userModelUsed instanceof User )
101+
{
102+
return $userModelUsed;
103+
}
104+
105+
return $user;
106+
}
80107
}

src/Darryldecode/Backend/Components/User/Commands/QueryUsersCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,11 @@ public function handle(User $user, Group $group, Dispatcher $dispatcher, Reposit
183183
*/
184184
protected function createUserModel($user, $config)
185185
{
186-
$userModelUsed = $config->get('backend.backend.user_model');
186+
if( ! $userModelUsed = $config->get('backend.backend.user_model') )
187+
{
188+
return $user;
189+
}
190+
187191
$userModelUsed = new $userModelUsed();
188192

189193
if( $userModelUsed instanceof User )

0 commit comments

Comments
 (0)