We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4623dbb commit ac79321Copy full SHA for ac79321
src/Traits/HasCountry.php
@@ -10,6 +10,7 @@
10
* @package Lecturize\Addresses\Traits;
11
* @property int|null $country_id
12
* @property Countries|null $country
13
+ * @property string $country_code
14
*/
15
trait HasCountry
16
{
@@ -23,6 +24,19 @@ public function country(): BelongsTo
23
24
return $this->belongsTo(Countries::class);
25
}
26
27
+ /**
28
+ * Get the models country code.
29
+ *
30
+ * @return string
31
+ */
32
+ public function getCountryCodeAttribute(): string
33
+ {
34
+ if ($country = $this->country)
35
+ return $country->iso_3166_2;
36
+
37
+ return '';
38
+ }
39
40
/**
41
* Scope by country.
42
*
0 commit comments