Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 2 |
UserAttributionTrait | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
companyIsAttributedToUser | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
1 | <?php |
2 | |
3 | namespace Qmp\Laravel\Compta\Controllers; |
4 | |
5 | use Qmp\Laravel\Compta\Models\Company; |
6 | |
7 | trait UserAttributionTrait |
8 | { |
9 | protected $USER_NOT_ATTRIBUTED_MESSAGE = 'user is not attributed to this company'; |
10 | |
11 | /** |
12 | * @param $companyId |
13 | * @return bool |
14 | */ |
15 | protected function companyIsAttributedToUser($companyId) |
16 | { |
17 | $company = Company::where('id', $companyId)->with('users')->wherePivot('user_id', $this->userId)->firstOrFail(); |
18 | |
19 | return !empty($company); |
20 | } |
21 | } |