2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
2015-11-05 23:37:04 +01:00
|
|
|
|
2016-05-23 18:52:20 +02:00
|
|
|
use App\Ninja\Datatables\UserDatatable;
|
2017-01-30 20:40:43 +01:00
|
|
|
use App\Ninja\Repositories\UserRepository;
|
2015-11-05 23:37:04 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class UserService.
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
class UserService extends BaseService
|
|
|
|
{
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @var UserRepository
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
protected $userRepo;
|
2016-07-03 18:11:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var DatatableService
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
protected $datatableService;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* UserService constructor.
|
|
|
|
*
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param UserRepository $userRepo
|
2016-07-03 18:11:58 +02:00
|
|
|
* @param DatatableService $datatableService
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
public function __construct(UserRepository $userRepo, DatatableService $datatableService)
|
|
|
|
{
|
|
|
|
$this->userRepo = $userRepo;
|
|
|
|
$this->datatableService = $datatableService;
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @return UserRepository
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
protected function getRepo()
|
|
|
|
{
|
|
|
|
return $this->userRepo;
|
|
|
|
}
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @param $accountId
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
2015-11-05 23:37:04 +01:00
|
|
|
public function getDatatable($accountId)
|
|
|
|
{
|
2016-05-23 18:52:20 +02:00
|
|
|
$datatable = new UserDatatable(false);
|
2015-11-05 23:37:04 +01:00
|
|
|
$query = $this->userRepo->find($accountId);
|
|
|
|
|
2016-05-23 18:52:20 +02:00
|
|
|
return $this->datatableService->createDatatable($datatable, $query);
|
2015-11-21 22:10:26 +01:00
|
|
|
}
|
2016-05-23 18:52:20 +02:00
|
|
|
}
|