1 | <?php |
||
12 | class Geoip extends Model |
||
13 | { |
||
14 | use ValidatingTrait; |
||
15 | use CacheableEloquent; |
||
16 | |||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | protected $fillable = [ |
||
21 | 'client_ip', |
||
22 | 'latitude', |
||
23 | 'longitude', |
||
24 | 'country_code', |
||
25 | 'client_ips', |
||
26 | 'is_from_trusted_proxy', |
||
27 | 'division_code', |
||
28 | 'postal_code', |
||
29 | 'timezone', |
||
30 | 'city', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | protected $casts = [ |
||
37 | 'client_ip' => 'string', |
||
38 | 'latitude' => 'string', |
||
39 | 'longitude' => 'string', |
||
40 | 'country_code' => 'string', |
||
41 | 'client_ips' => 'json', |
||
42 | 'is_from_trusted_proxy' => 'boolean', |
||
43 | 'division_code' => 'string', |
||
44 | 'postal_code' => 'string', |
||
45 | 'timezone' => 'string', |
||
46 | 'city' => 'string', |
||
47 | ]; |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | public $timestamps = false; |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | protected $observables = [ |
||
58 | 'validating', |
||
59 | 'validated', |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * The default rules that the model will validate against. |
||
64 | * |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $rules = [ |
||
68 | 'client_ip' => 'required|string', |
||
69 | 'latitude' => 'required|string', |
||
70 | 'longitude' => 'required|string', |
||
71 | 'country_code' => 'required|alpha|size:2|country', |
||
72 | 'client_ips' => 'nullable|array', |
||
73 | 'is_from_trusted_proxy' => 'sometimes|boolean', |
||
74 | 'division_code' => 'nullable|string', |
||
75 | 'postal_code' => 'nullable|string', |
||
76 | 'timezone' => 'nullable|string|max:150|timezone', |
||
77 | 'city' => 'nullable|string', |
||
78 | ]; |
||
79 | |||
80 | /** |
||
81 | * Whether the model should throw a |
||
82 | * ValidationException if it fails validation. |
||
83 | * |
||
84 | * @var bool |
||
85 | */ |
||
86 | protected $throwValidationExceptions = true; |
||
87 | |||
88 | /** |
||
89 | * Create a new Eloquent model instance. |
||
90 | * |
||
91 | * @param array $attributes |
||
92 | */ |
||
93 | public function __construct(array $attributes = []) |
||
99 | |||
100 | /** |
||
101 | * The geoip may have many requests. |
||
102 | * |
||
103 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
104 | */ |
||
105 | public function requests(): HasMany |
||
109 | } |
||
110 |