|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
4
|
|
|
* file that was distributed with this source code. |
|
5
|
|
|
* |
|
6
|
|
|
* @modified 8/11/20, 8:06 PM |
|
7
|
|
|
* @name toko |
|
8
|
|
|
* @author Wachid |
|
9
|
|
|
* @copyright Copyright (c) 2019-2020. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Turahe\Master\Models; |
|
13
|
|
|
|
|
14
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany; |
|
15
|
|
|
use Illuminate\Support\Facades\Cache; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Turahe\Master\Country. |
|
19
|
|
|
* |
|
20
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Turahe\Master\Models\State[] $states |
|
21
|
|
|
* @property-read null|int $states_count |
|
22
|
|
|
* |
|
23
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country newModelQuery() |
|
24
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country newQuery() |
|
25
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country query() |
|
26
|
|
|
* |
|
27
|
|
|
* @property int $id |
|
28
|
|
|
* @property null|string $capital |
|
29
|
|
|
* @property null|string $citizenship |
|
30
|
|
|
* @property string $country_code |
|
31
|
|
|
* @property null|string $currency |
|
32
|
|
|
* @property null|string $currency_code |
|
33
|
|
|
* @property null|string $currency_sub_unit |
|
34
|
|
|
* @property null|string $currency_symbol |
|
35
|
|
|
* @property null|string $full_name |
|
36
|
|
|
* @property string $iso_3166_2 |
|
37
|
|
|
* @property string $iso_3166_3 |
|
38
|
|
|
* @property string $name |
|
39
|
|
|
* @property null|string $region_code |
|
40
|
|
|
* @property null|string $sub_region_code |
|
41
|
|
|
* @property int $eea |
|
42
|
|
|
* @property string $calling_code |
|
43
|
|
|
* @property null|string $flag |
|
44
|
|
|
* @property int $active |
|
45
|
|
|
* @property null|\Illuminate\Support\Carbon $created_at |
|
46
|
|
|
* @property null|\Illuminate\Support\Carbon $updated_at |
|
47
|
|
|
* |
|
48
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereActive($value) |
|
49
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCallingCode($value) |
|
50
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCapital($value) |
|
51
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCitizenship($value) |
|
52
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCountryCode($value) |
|
53
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCreatedAt($value) |
|
54
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCurrency($value) |
|
55
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCurrencyCode($value) |
|
56
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCurrencySubUnit($value) |
|
57
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereCurrencySymbol($value) |
|
58
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereEea($value) |
|
59
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereFlag($value) |
|
60
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereFullName($value) |
|
61
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereId($value) |
|
62
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereIso31662($value) |
|
63
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereIso31663($value) |
|
64
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereName($value) |
|
65
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereRegionCode($value) |
|
66
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereSubRegionCode($value) |
|
67
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|Country whereUpdatedAt($value) |
|
68
|
|
|
* @mixin \Eloquent |
|
69
|
|
|
*/ |
|
70
|
|
|
class Country extends Model |
|
71
|
|
|
{ |
|
72
|
|
|
protected $table = 'tm_countries'; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Bootstrap the model and its traits. |
|
76
|
|
|
* |
|
77
|
|
|
* Caching model when updating and |
|
78
|
|
|
* delete cache when delete models |
|
79
|
|
|
* |
|
80
|
|
|
* @return void |
|
81
|
|
|
*/ |
|
82
|
|
|
protected static function boot() |
|
83
|
|
|
{ |
|
84
|
|
|
parent::boot(); // TODO: Change the autogenerated stub |
|
85
|
|
|
static::updating(function ($instance) { |
|
86
|
|
|
Cache::put('countries.'.$instance->slug, $instance); |
|
87
|
|
|
}); |
|
88
|
|
|
static::deleting(function ($instance) { |
|
89
|
|
|
Cache::delete('countries.'.$instance->slug); |
|
90
|
|
|
}); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return HasMany |
|
95
|
|
|
*/ |
|
96
|
|
|
public function states(): HasMany |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->hasMany(State::class); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|