mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for Project Filters
This commit is contained in:
parent
9910e4f997
commit
b9cb231773
@ -112,7 +112,8 @@ class PaymentTermFilters extends QueryFilters
|
||||
*/
|
||||
public function entityFilter()
|
||||
{
|
||||
return $this->builder->company();
|
||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||
return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null);
|
||||
// return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,6 @@ class ProjectFilters extends QueryFilters
|
||||
$query = DB::table('projects')
|
||||
->join('companies', 'companies.id', '=', 'projects.company_id')
|
||||
->where('projects.company_id', '=', $company_id)
|
||||
//->whereRaw('(projects.name != "" or contacts.first_name != "" or contacts.last_name != "" or contacts.email != "")') // filter out buy now invoices
|
||||
->select(
|
||||
'projects.id',
|
||||
'projects.name',
|
||||
@ -140,6 +139,8 @@ class ProjectFilters extends QueryFilters
|
||||
public function entityFilter()
|
||||
{
|
||||
//return $this->builder->whereCompanyId(auth()->user()->company()->id);
|
||||
return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null);
|
||||
// return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null);
|
||||
return $this->builder->company();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,8 @@ abstract class QueryFilters
|
||||
}
|
||||
}
|
||||
|
||||
// nlog('[Search] SQL: ' . $this->builder->toSql() . " Bindings: " . implode(', ', $this->builder->getBindings()));
|
||||
|
||||
return $this->builder->withTrashed();
|
||||
}
|
||||
|
||||
|
@ -84,10 +84,35 @@ class ProjectApiTest extends TestCase
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function testProjectPostFilters()
|
||||
{
|
||||
$data = [
|
||||
'name' => "Sherlock",
|
||||
'client_id' => $this->client->hashed_id,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/projects', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->get('/api/v1/projects?filter=Sherlock');
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$this->assertEquals(1, count($arr['data']));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testProjectPut()
|
||||
{
|
||||
$data = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user