mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:47:34 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php namespace App\Services;
 | 
						|
 | 
						|
use Auth;
 | 
						|
use Utils;
 | 
						|
use App\Ninja\Repositories\TaskRepository;
 | 
						|
use App\Ninja\Datatables\TaskDatatable;
 | 
						|
 | 
						|
/**
 | 
						|
 * Class TaskService
 | 
						|
 */
 | 
						|
class TaskService extends BaseService
 | 
						|
{
 | 
						|
    protected $datatableService;
 | 
						|
    protected $taskRepo;
 | 
						|
 | 
						|
    /**
 | 
						|
     * TaskService constructor.
 | 
						|
     *
 | 
						|
     * @param TaskRepository $taskRepo
 | 
						|
     * @param DatatableService $datatableService
 | 
						|
     */
 | 
						|
    public function __construct(TaskRepository $taskRepo, DatatableService $datatableService)
 | 
						|
    {
 | 
						|
        $this->taskRepo = $taskRepo;
 | 
						|
        $this->datatableService = $datatableService;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * @return TaskRepository
 | 
						|
     */
 | 
						|
    protected function getRepo()
 | 
						|
    {
 | 
						|
        return $this->taskRepo;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param $clientPublicId
 | 
						|
     * @param $search
 | 
						|
     * @return \Illuminate\Http\JsonResponse
 | 
						|
     */
 | 
						|
    public function getDatatable($clientPublicId, $search)
 | 
						|
    {
 | 
						|
        $datatable = new TaskDatatable(true, $clientPublicId);
 | 
						|
        $query = $this->taskRepo->find($clientPublicId, $search);
 | 
						|
 | 
						|
        if(!Utils::hasPermission('view_all')){
 | 
						|
            $query->where('tasks.user_id', '=', Auth::user()->id);
 | 
						|
        }
 | 
						|
 | 
						|
        return $this->datatableService->createDatatable($datatable, $query);
 | 
						|
    }
 | 
						|
}
 |