-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PivotConsumer.php
41 lines (35 loc) · 1.28 KB
/
PivotConsumer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace romanzipp\ProjectableAggregates\Tests\Support;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use romanzipp\ProjectableAggregates\Attributes\ConsumesProjectableAggregate;
use romanzipp\ProjectableAggregates\Contracts\ConsumesProjectableAggregatesContract;
use romanzipp\ProjectableAggregates\ProjectionAggregateType;
/**
* @property int $id
* @property int $projection_providers_count
*/
class PivotConsumer extends Model implements ConsumesProjectableAggregatesContract
{
public $table = 'pivot_consumers';
public $timestamps = false;
protected $guarded = [];
/**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough<\romanzipp\ProjectableAggregates\Tests\Support\PivotProvider, \romanzipp\ProjectableAggregates\Tests\Support\PivotProviderConsumerPivot, $this>
*/
#[ConsumesProjectableAggregate(
projectionAttribute: 'projection_providers_count',
type: ProjectionAggregateType::TYPE_COUNT,
)]
public function providers(): HasManyThrough
{
return $this->hasManyThrough(
PivotProvider::class,
PivotProviderConsumerPivot::class,
'provider_id',
'id',
'id',
'provider_id'
);
}
}