Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
laravel-adminpanel
Commits
bd48f1b3
Commit
bd48f1b3
authored
Mar 14, 2018
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip delete all api
parent
55bfeb5e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
2 deletions
+45
-2
UsersController.php
app/Http/Controllers/Api/V1/UsersController.php
+18
-0
UserRepository.php
app/Repositories/Backend/Access/User/UserRepository.php
+23
-0
api.php
routes/api.php
+4
-2
No files found.
app/Http/Controllers/Api/V1/UsersController.php
View file @
bd48f1b3
...
@@ -110,6 +110,24 @@ class UsersController extends APIController
...
@@ -110,6 +110,24 @@ class UsersController extends APIController
]);
]);
}
}
/**
* Delete All User.
*
* @param Request $request
*
* @return mixed
*/
public
function
delteAll
(
Request
$request
)
{
$ids
=
$request
->
get
(
'ids'
);
if
(
isset
(
$ids
)
&&
!
empty
(
$ids
))
{
$this
->
repository
->
deleteAll
(
$ids
);
}
}
/**
/**
* validateUser User.
* validateUser User.
*
*
...
...
app/Repositories/Backend/Access/User/UserRepository.php
View file @
bd48f1b3
...
@@ -189,6 +189,8 @@ class UserRepository extends BaseRepository
...
@@ -189,6 +189,8 @@ class UserRepository extends BaseRepository
}
}
/**
/**
* Delete User
*
* @param Model $user
* @param Model $user
*
*
* @throws GeneralException
* @throws GeneralException
...
@@ -210,6 +212,27 @@ class UserRepository extends BaseRepository
...
@@ -210,6 +212,27 @@ class UserRepository extends BaseRepository
throw
new
GeneralException
(
trans
(
'exceptions.backend.access.users.delete_error'
));
throw
new
GeneralException
(
trans
(
'exceptions.backend.access.users.delete_error'
));
}
}
/**
* Delete All User
*
* @param $ids
*
* @throws GeneralException
*
* @return bool
*/
public
function
deleteAll
(
$ids
)
{
if
(
in_array
(
access
()
->
id
(),
$ids
))
{
throw
new
GeneralException
(
trans
(
'exceptions.backend.access.users.cant_delete_self'
));
}
$result
=
DB
::
table
(
"users"
)
->
whereIn
(
'id'
,
explode
(
","
,
$ids
))
->
delete
();
dd
(
$result
);
}
/**
/**
* @param $user
* @param $user
*
*
...
...
routes/api.php
View file @
bd48f1b3
...
@@ -29,8 +29,10 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
...
@@ -29,8 +29,10 @@ Route::group(['namespace' => 'Api\V1', 'prefix' => 'v1', 'as' => 'v1.'], functio
});
});
// Users
// Users
Route
::
resource
(
'users'
,
'UsersController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
Route
::
resource
(
'users'
,
'UsersController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
Route
::
get
(
'deactivatedUsers'
,
'DeactivatedUsersController@index'
);
Route
::
post
(
'users/delete-all'
,
'UsersController@delteAll'
);
Route
::
get
(
'deletedUsers'
,
'DeletedUsersController@index'
);
//@todo need to change the route name and related changes
/*Route::get('deactivatedUsers', 'DeactivatedUsersController@index');
Route::get('deletedUsers', 'DeletedUsersController@index');*/
// Roles
// Roles
Route
::
resource
(
'roles'
,
'RolesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
Route
::
resource
(
'roles'
,
'RolesController'
,
[
'except'
=>
[
'create'
,
'edit'
]]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment