cleaniquecoders /
profile
| 1 | <?php |
||
| 2 | |||
| 3 | namespace CleaniqueCoders\Profile\Models; |
||
| 4 | |||
| 5 | use CleaniqueCoders\Traitify\Concerns\InteractsWithUuid; |
||
| 6 | use Illuminate\Database\Eloquent\Builder; |
||
| 7 | use Illuminate\Database\Eloquent\Model; |
||
| 8 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
||
| 9 | use Illuminate\Database\Eloquent\Relations\MorphTo; |
||
| 10 | |||
| 11 | class Phone extends Model |
||
| 12 | { |
||
| 13 | use InteractsWithUuid; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 14 | |||
| 15 | protected $guarded = [ |
||
| 16 | 'id', |
||
| 17 | ]; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Get all of the owning phoneable models. |
||
| 21 | */ |
||
| 22 | public function phoneable(): MorphTo |
||
| 23 | { |
||
| 24 | return $this->morphTo(); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Phone Type. |
||
| 29 | */ |
||
| 30 | public function type(): BelongsTo |
||
| 31 | { |
||
| 32 | return $this->belongsTo(PhoneType::class, 'phone_type_id')->withDefault(); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Get Home Phone Numbers. |
||
| 37 | */ |
||
| 38 | public function scopeHome(Builder $query): Builder |
||
| 39 | { |
||
| 40 | return $query->where('phone_type_id', PhoneType::HOME); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Get Mobile Phone Numbers. |
||
| 45 | */ |
||
| 46 | public function scopeMobile(Builder $query): Builder |
||
| 47 | { |
||
| 48 | return $query->where('phone_type_id', PhoneType::MOBILE); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Get Office Phone Numbers. |
||
| 53 | */ |
||
| 54 | public function scopeOffice(Builder $query): Builder |
||
| 55 | { |
||
| 56 | return $query->where('phone_type_id', PhoneType::OFFICE); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Get Other Phone Numbers. |
||
| 61 | */ |
||
| 62 | public function scopeOther(Builder $query): Builder |
||
| 63 | { |
||
| 64 | return $query->where('phone_type_id', PhoneType::OTHER); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Get Fax Phone Numbers. |
||
| 69 | */ |
||
| 70 | public function scopeFax(Builder $query): Builder |
||
| 71 | { |
||
| 72 | return $query->where('phone_type_id', PhoneType::FAX); |
||
| 73 | } |
||
| 74 | } |
||
| 75 |