mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 00:37:31 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			68 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * Invoice Ninja (https://invoiceninja.com).
 | 
						|
 *
 | 
						|
 * @link https://github.com/invoiceninja/invoiceninja source repository
 | 
						|
 *
 | 
						|
 * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
 | 
						|
 *
 | 
						|
 * @license https://www.elastic.co/licensing/elastic-license
 | 
						|
 */
 | 
						|
 | 
						|
namespace App\Filters;
 | 
						|
 | 
						|
use App\Models\Project;
 | 
						|
use App\Models\User;
 | 
						|
use Illuminate\Database\Eloquent\Builder;
 | 
						|
use Illuminate\Support\Facades\DB;
 | 
						|
use Illuminate\Support\Facades\Gate;
 | 
						|
 | 
						|
/**
 | 
						|
 * ProjectFilters.
 | 
						|
 */
 | 
						|
class ProjectFilters extends QueryFilters
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Filter based on search text.
 | 
						|
     *
 | 
						|
     * @param string query filter
 | 
						|
     * @return Builder
 | 
						|
     * @deprecated
 | 
						|
     */
 | 
						|
    public function filter(string $filter = '') : Builder
 | 
						|
    {
 | 
						|
        if (strlen($filter) == 0) {
 | 
						|
            return $this->builder;
 | 
						|
        }
 | 
						|
 | 
						|
        return  $this->builder->where(function ($query) use ($filter) {
 | 
						|
            $query->where('projects.name', 'like', '%'.$filter.'%')
 | 
						|
                  ->orWhere('projects.public_notes', 'like', '%'.$filter.'%')
 | 
						|
                  ->orWhere('projects.private_notes', 'like', '%'.$filter.'%');
 | 
						|
        });
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Sorts the list based on $sort.
 | 
						|
     *
 | 
						|
     * @param string sort formatted as column|asc
 | 
						|
     * @return Builder
 | 
						|
     */
 | 
						|
    public function sort(string $sort) : Builder
 | 
						|
    {
 | 
						|
        $sort_col = explode('|', $sort);
 | 
						|
 | 
						|
        return $this->builder->orderBy($sort_col[0], $sort_col[1]);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Filters the query by the users company ID.
 | 
						|
     *
 | 
						|
     * @return Illuminate\Database\Query\Builder
 | 
						|
     */
 | 
						|
    public function entityFilter()
 | 
						|
    {
 | 
						|
        return $this->builder->company();
 | 
						|
    }
 | 
						|
}
 |