mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fix for company filtering
This commit is contained in:
parent
441d52523d
commit
85de581fac
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user