Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Contact extends Model |
||
11 | { |
||
12 | use HasFactory; |
||
13 | use HasUUID; |
||
14 | |||
15 | /** |
||
16 | * The attributes that are mass assignable. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $fillable = [ |
||
21 | 'name', |
||
22 | 'user_id', |
||
23 | 'source_type', |
||
24 | 'source_id', |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * Scope a query to only include active users. |
||
29 | * |
||
30 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
31 | * @param string $user_id |
||
32 | * @return \Illuminate\Database\Eloquent\Builder |
||
33 | */ |
||
34 | public function scopeForUser($query, $user_id) |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Get the user that owns the contact. |
||
41 | */ |
||
42 | public function user() |
||
43 | { |
||
44 | return $this->belongsTo(User::class); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get the owner model of the contact. |
||
49 | * |
||
50 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
51 | */ |
||
52 | public function source(): MorphTo |
||
55 | } |
||
56 | } |
||
57 |