1 | <?php |
||
2 | |||
3 | namespace Signifly\Addresses\Traits; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\Relations\MorphOne; |
||
6 | |||
7 | trait HasAddress |
||
8 | { |
||
9 | /** |
||
10 | * Boot the `HasAddress` trait for the model. |
||
11 | * |
||
12 | * @return void |
||
13 | */ |
||
14 | public static function bootHasAddress() |
||
15 | { |
||
16 | static::deleting(function ($model) { |
||
17 | $model->address()->delete(); |
||
18 | }); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * The associated address relation. |
||
23 | * |
||
24 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||
25 | */ |
||
26 | public function address(): MorphOne |
||
27 | { |
||
28 | return $this->morphOne(config('addresses.address_model'), 'addressable'); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
29 | } |
||
30 | } |
||
31 |