mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 12:34:35 -04:00
Fix for company filtering
This commit is contained in:
parent
441d52523d
commit
85de581fac
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Transformers\ArraySerializer;
|
use App\Transformers\ArraySerializer;
|
||||||
use App\Transformers\EntityTransformer;
|
use App\Transformers\EntityTransformer;
|
||||||
@ -146,12 +147,16 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
$query->with($includes);
|
$query->with($includes);
|
||||||
|
|
||||||
|
|
||||||
if (auth()->user()->cannot('view_'.$this->entity_type))
|
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);
|
$query->where('id', '=', auth()->user()->id);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$query->where('user_id', '=', auth()->user()->id);
|
$query->where('user_id', '=', auth()->user()->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ use App\Events\Invoice\InvoiceWasUpdated;
|
|||||||
use App\Factory\InvoiceInvitationFactory;
|
use App\Factory\InvoiceInvitationFactory;
|
||||||
use App\Helpers\Invoice\InvoiceCalc;
|
use App\Helpers\Invoice\InvoiceCalc;
|
||||||
use App\Jobs\Company\UpdateCompanyLedgerWithInvoice;
|
use App\Jobs\Company\UpdateCompanyLedgerWithInvoice;
|
||||||
|
use App\Listeners\Invoice\CreateInvoiceInvitation;
|
||||||
use App\Models\ClientContact;
|
use App\Models\ClientContact;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\InvoiceInvitation;
|
use App\Models\InvoiceInvitation;
|
||||||
|
@ -47,7 +47,7 @@ class CompanyTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'name' => $this->faker->company,
|
'name' => $this->faker->company,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user