2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
2016-07-06 20:35:16 +02:00
|
|
|
|
|
|
|
use App\Ninja\Datatables\ExpenseCategoryDatatable;
|
2017-01-30 20:40:43 +01:00
|
|
|
use App\Ninja\Repositories\ExpenseCategoryRepository;
|
2016-07-06 20:35:16 +02:00
|
|
|
|
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class ExpenseCategoryService.
|
2016-07-06 20:35:16 +02:00
|
|
|
*/
|
|
|
|
class ExpenseCategoryService extends BaseService
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ExpenseCategoryRepository
|
|
|
|
*/
|
|
|
|
protected $categoryRepo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var DatatableService
|
|
|
|
*/
|
|
|
|
protected $datatableService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CreditService constructor.
|
|
|
|
*
|
|
|
|
* @param ExpenseCategoryRepository $creditRepo
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param DatatableService $datatableService
|
2016-07-06 20:35:16 +02:00
|
|
|
*/
|
|
|
|
public function __construct(ExpenseCategoryRepository $categoryRepo, DatatableService $datatableService)
|
|
|
|
{
|
|
|
|
$this->categoryRepo = $categoryRepo;
|
|
|
|
$this->datatableService = $datatableService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return CreditRepository
|
|
|
|
*/
|
|
|
|
protected function getRepo()
|
|
|
|
{
|
|
|
|
return $this->categoryRepo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $data
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-06 20:35:16 +02:00
|
|
|
* @return mixed|null
|
|
|
|
*/
|
|
|
|
public function save($data)
|
|
|
|
{
|
|
|
|
return $this->categoryRepo->save($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $clientPublicId
|
|
|
|
* @param $search
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-06 20:35:16 +02:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
|
|
|
public function getDatatable($search)
|
|
|
|
{
|
|
|
|
// we don't support bulk edit and hide the client on the individual client page
|
|
|
|
$datatable = new ExpenseCategoryDatatable();
|
|
|
|
|
|
|
|
$query = $this->categoryRepo->find($search);
|
|
|
|
|
|
|
|
return $this->datatableService->createDatatable($datatable, $query);
|
|
|
|
}
|
|
|
|
}
|