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

Fix for company filtering

This commit is contained in:
David Bomba 2019-09-29 18:46:53 +10:00
parent 441d52523d
commit 85de581fac
3 changed files with 10 additions and 4 deletions

View File

@ -11,6 +11,7 @@
namespace App\Http\Controllers;
use App\Models\Company;
use App\Models\User;
use App\Transformers\ArraySerializer;
use App\Transformers\EntityTransformer;
@ -146,12 +147,16 @@ class BaseController extends Controller
$query->with($includes);
if (auth()->user()->cannot('view_'.$this->entity_type))
{
if ($this->entity_type == User::class) {
if($this->entity_type == Company::class){
//no user keys exist on the company table, so we need to skip
}
else if ($this->entity_type == User::class) {
$query->where('id', '=', auth()->user()->id);
} else {
}
else {
$query->where('user_id', '=', auth()->user()->id);
}
}

View File

@ -16,6 +16,7 @@ use App\Events\Invoice\InvoiceWasUpdated;
use App\Factory\InvoiceInvitationFactory;
use App\Helpers\Invoice\InvoiceCalc;
use App\Jobs\Company\UpdateCompanyLedgerWithInvoice;
use App\Listeners\Invoice\CreateInvoiceInvitation;
use App\Models\ClientContact;
use App\Models\Invoice;
use App\Models\InvoiceInvitation;

View File

@ -47,7 +47,7 @@ class CompanyTest extends TestCase
$data = [
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'name' => $this->faker->company,
'name' => $this->faker->company,
'email' => $this->faker->unique()->safeEmail,
'password' => 'ALongAndBrilliantPassword123',
'_token' => csrf_token(),