1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00
invoiceninja/app/Services/ProjectService.php

76 lines
1.7 KiB
PHP
Raw Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Services;
2016-11-29 18:47:26 +01:00
use App\Models\Client;
use App\Ninja\Datatables\ProjectDatatable;
2017-01-30 20:40:43 +01:00
use App\Ninja\Repositories\ProjectRepository;
2016-11-29 18:47:26 +01:00
/**
2017-01-30 20:40:43 +01:00
* Class ProjectService.
2016-11-29 18:47:26 +01:00
*/
class ProjectService extends BaseService
{
/**
* @var ProjectRepository
*/
protected $projectRepo;
/**
* @var DatatableService
*/
protected $datatableService;
/**
* CreditService constructor.
*
* @param ProjectRepository $creditRepo
2017-01-30 20:40:43 +01:00
* @param DatatableService $datatableService
2016-11-29 18:47:26 +01:00
*/
public function __construct(ProjectRepository $projectRepo, DatatableService $datatableService)
{
$this->projectRepo = $projectRepo;
$this->datatableService = $datatableService;
}
/**
* @return CreditRepository
*/
protected function getRepo()
{
return $this->projectRepo;
}
/**
* @param $data
2017-01-30 20:49:42 +01:00
* @param mixed $project
2017-01-30 20:40:43 +01:00
*
2016-11-29 18:47:26 +01:00
* @return mixed|null
*/
2016-12-15 14:11:04 +01:00
public function save($data, $project = false)
2016-11-29 18:47:26 +01:00
{
if (isset($data['client_id']) && $data['client_id']) {
$data['client_id'] = Client::getPrivateId($data['client_id']);
}
2016-12-15 13:17:10 +01:00
return $this->projectRepo->save($data, $project);
2016-11-29 18:47:26 +01:00
}
/**
* @param $clientPublicId
* @param $search
2017-01-30 20:49:42 +01:00
* @param mixed $userId
2017-01-30 20:40:43 +01:00
*
2016-11-29 18:47:26 +01:00
* @return \Illuminate\Http\JsonResponse
*/
public function getDatatable($search, $userId)
{
// we don't support bulk edit and hide the client on the individual client page
$datatable = new ProjectDatatable();
$query = $this->projectRepo->find($search, $userId);
return $this->datatableService->createDatatable($datatable, $query);
}
}