1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00
invoiceninja/app/Services/TaskService.php

53 lines
1.2 KiB
PHP
Raw Normal View History

2015-11-05 23:37:04 +01:00
<?php namespace App\Services;
2016-03-16 00:08:00 +01:00
use Auth;
2015-11-05 23:37:04 +01:00
use Utils;
use App\Ninja\Repositories\TaskRepository;
2016-05-23 18:52:20 +02:00
use App\Ninja\Datatables\TaskDatatable;
2015-11-05 23:37:04 +01:00
/**
* Class TaskService
*/
2015-11-05 23:37:04 +01:00
class TaskService extends BaseService
{
protected $datatableService;
protected $taskRepo;
/**
* TaskService constructor.
*
* @param TaskRepository $taskRepo
* @param DatatableService $datatableService
*/
2015-11-05 23:37:04 +01:00
public function __construct(TaskRepository $taskRepo, DatatableService $datatableService)
{
$this->taskRepo = $taskRepo;
$this->datatableService = $datatableService;
}
/**
* @return TaskRepository
*/
2015-11-05 23:37:04 +01:00
protected function getRepo()
{
return $this->taskRepo;
}
/**
* @param $clientPublicId
* @param $search
* @return \Illuminate\Http\JsonResponse
*/
2015-11-05 23:37:04 +01:00
public function getDatatable($clientPublicId, $search)
{
2016-05-23 18:52:20 +02:00
$datatable = new TaskDatatable( ! $clientPublicId, $clientPublicId);
2015-11-05 23:37:04 +01:00
$query = $this->taskRepo->find($clientPublicId, $search);
2016-03-16 00:08:00 +01:00
if(!Utils::hasPermission('view_all')){
$query->where('tasks.user_id', '=', Auth::user()->id);
}
2016-05-23 18:52:20 +02:00
return $this->datatableService->createDatatable($datatable, $query);
2015-11-05 23:37:04 +01:00
}
2016-05-23 18:52:20 +02:00
}