Commit ee136503 authored by cygnet's avatar cygnet

refacter users to create new controller for deactivated and deleted users

parent c6c1e4c7
<?php
namespace App\Http\Controllers\Api\V1;
use App\Events\Backend\Access\User\UserCreated;
use App\Events\Backend\Access\User\UserUpdated;
use App\Http\Resources\UserResource;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request;
use Validator;
class DeactivatedUsersController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the deactivated users.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getForDataTable(0, false)->paginate($limit)
);
}
}
<?php
namespace App\Http\Controllers\Api\V1;
use App\Events\Backend\Access\User\UserCreated;
use App\Events\Backend\Access\User\UserUpdated;
use App\Http\Resources\UserResource;
use App\Models\Access\User\User;
use App\Repositories\Backend\Access\User\UserRepository;
use Illuminate\Http\Request;
use Validator;
class DeletedUsersController extends APIController
{
protected $repository;
/**
* __construct.
*
* @param $repository
*/
public function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
/**
* Return the deleted users.
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getForDataTable(0, true)->paginate($limit)
);
}
}
......@@ -80,7 +80,7 @@ class UsersController extends APIController
* @param Request $request
* @param User $user
*
* @return \Illuminate\Http\JsonResponse
* @return Validator object
*/
public function update(Request $request, User $user)
{
......@@ -114,38 +114,6 @@ class UsersController extends APIController
]);
}
/**
* Return the deactivate users.
*
* @param Request
*
* @return \Illuminate\Http\JsonResponse
*/
public function deactivatedUserList(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getForDataTable(0, false)->paginate($limit)
);
}
/**
* Return the deleted users.
*
* @param User $user
*
* @return \Illuminate\Http\JsonResponse
*/
public function deleteUserList(Request $request)
{
$limit = $request->get('paginate') ? $request->get('paginate') : 25;
return UserResource::collection(
$this->repository->getForDataTable(0, true)->paginate($limit)
);
}
/**
* validateUser User.
*
......
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