1 | <?php |
||
2 | |||
3 | namespace MaksimM\CompositePrimaryKeys\Tests\Stubs; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Model; |
||
6 | |||
7 | class TestUser extends Model |
||
8 | { |
||
9 | use \MaksimM\CompositePrimaryKeys\Http\Traits\HasCompositePrimaryKey; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
10 | |||
11 | protected $table = 'users'; |
||
12 | |||
13 | protected $primaryKey = [ |
||
14 | 'user_id', |
||
15 | 'organization_id', |
||
16 | ]; |
||
17 | |||
18 | protected $fillable = [ |
||
19 | 'name', 'counter', 'organization_id', 'referred_by_user_id', 'referred_by_organization_id', |
||
20 | ]; |
||
21 | |||
22 | public function organization() |
||
23 | { |
||
24 | return $this->belongsTo(TestOrganization::class, 'organization_id', 'organization_id'); |
||
25 | } |
||
26 | |||
27 | public function referrer() |
||
28 | { |
||
29 | return $this->belongsTo(self::class, [ |
||
30 | 'referred_by_user_id', |
||
31 | 'referred_by_organization_id', |
||
32 | ], [ |
||
33 | 'user_id', |
||
34 | 'organization_id', |
||
35 | ]); |
||
36 | } |
||
37 | |||
38 | public function wrongConfiguredReferrer() |
||
39 | { |
||
40 | return $this->belongsTo(self::class, [ |
||
41 | 'referred_by_user_id', |
||
42 | 'referred_by_organization_id', |
||
43 | ], [ |
||
44 | 'user_id', |
||
45 | ]); |
||
46 | } |
||
47 | |||
48 | public function automaticReferrer() |
||
49 | { |
||
50 | return $this->belongsTo(self::class); |
||
51 | } |
||
52 | } |
||
53 |