Commit bd48f1b3 authored by Viral Solani's avatar Viral Solani

wip delete all api

parent 55bfeb5e
...@@ -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.
* *
......
...@@ -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
* *
......
...@@ -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']]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment