Issues (5)

src/Dcim/Site.php (1 issue)

1
<?php
2
3
namespace CmdrSharp\NetBox\Dcim;
4
5
use CmdrSharp\NetBox\NetBox;
6
use CmdrSharp\NetBox\Tenancy\Tenant;
7
use CmdrSharp\NetBox\Traits\HandlesNetBoxResults;
8
use CmdrSharp\NetBox\Traits\RequiresSlugs;
9
10
class Site extends NetBox
11
{
12
    use HandlesNetBoxResults,
0 ignored issues
show
The trait CmdrSharp\NetBox\Traits\HandlesNetBoxResults requires some properties which are not provided by CmdrSharp\NetBox\Dcim\Site: $count, $results, $id
Loading history...
13
        RequiresSlugs;
14
15
    /** @var string */
16
    const API_PATH = parent::API_PATH . 'dcim/sites/';
17
18
    /** @var array|string[] */
19
    protected array $fillable = [
20
        'name',
21
        'slug',
22
        'status',
23
        'region',
24
        'tenant',
25
        'facility',
26
        'asn',
27
        'time_zone',
28
        'description',
29
        'physical_address',
30
        'shipping_address',
31
        'latitude',
32
        'longitude',
33
        'contact_name',
34
        'contact_phone',
35
        'contact_email',
36
        'comments',
37
    ];
38
39
    /**
40
     * @param string $name
41
     * @return $this
42
     */
43
    public function setName(string $name): Site
44
    {
45
        $this->setAttribute('name', $name);
46
47
        return $this;
48
    }
49
50
    /**
51
     * @param string $slug
52
     * @param bool $slugify
53
     * @return $this
54
     */
55
    public function setSlug(string $slug, bool $slugify = true): Site
56
    {
57
        if ($slugify) {
58
            $slug = $this->slugify($slug);
59
        }
60
61
        $this->setAttribute('slug', $slug);
62
63
        return $this;
64
    }
65
66
    /**
67
     * @param string $status
68
     * @return $this
69
     */
70
    public function setStatus(string $status): Site
71
    {
72
        $this->setAttribute('status', $status);
73
74
        return $this;
75
    }
76
77
    /**
78
     * @param int $region
79
     * @return $this
80
     */
81
    public function setRegion(int $region): Site
82
    {
83
        $this->setAttribute('region', $region);
84
85
        return $this;
86
    }
87
88
    /**
89
     * @param int $tenant
90
     * @return $this
91
     */
92
    public function setTenant(int $tenant): Site
93
    {
94
        $this->setAttribute('tenant', $tenant);
95
96
        return $this;
97
    }
98
99
    /**
100
     * @param string $tenant
101
     * @return $this
102
     */
103
    public function setTenantByName(string $tenant): Site
104
    {
105
        $tenantQuery = Tenant::whereName($tenant);
106
        $tenant = $this->getOnlyResult($tenantQuery);
107
108
        $this->setAttribute('tenant', $tenant->id);
109
110
        return $this;
111
    }
112
113
    /**
114
     * @param string $facility
115
     * @return $this
116
     */
117
    public function setFacility(string $facility): Site
118
    {
119
        $this->setAttribute('facility', $facility);
120
121
        return $this;
122
    }
123
124
    /**
125
     * @param int $asn
126
     * @return $this
127
     */
128
    public function setAsn(int $asn): Site
129
    {
130
        $this->setAttribute('asn', $asn);
131
132
        return $this;
133
    }
134
135
    /**
136
     * @param string $timezone
137
     * @return $this
138
     */
139
    public function setTimezone(string $timezone): Site
140
    {
141
        $this->setAttribute('time_zone', $timezone);
142
143
        return $this;
144
    }
145
146
    /**
147
     * @param string $description
148
     * @return $this
149
     */
150
    public function setDescription(string $description): Site
151
    {
152
        $this->setAttribute('description', $description);
153
154
        return $this;
155
    }
156
157
    /**
158
     * @param string $physicalAddress
159
     * @return $this
160
     */
161
    public function setPhyiscalAddress(string $physicalAddress): Site
162
    {
163
        $this->setAttribute('physical_address', $physicalAddress);
164
165
        return $this;
166
    }
167
168
    /**
169
     * @param string $shippingAddress
170
     * @return $this
171
     */
172
    public function setShippingAddress(string $shippingAddress): Site
173
    {
174
        $this->setAttribute('shipping_address', $shippingAddress);
175
176
        return $this;
177
    }
178
179
    /**
180
     * @param string $latitude
181
     * @return $this
182
     */
183
    public function setLatitude(string $latitude): Site
184
    {
185
        $this->setAttribute('latitude', $latitude);
186
187
        return $this;
188
    }
189
190
    /**
191
     * @param string $longitude
192
     * @return $this
193
     */
194
    public function setLongitude(string $longitude): Site
195
    {
196
        $this->setAttribute('longitude', $longitude);
197
198
        return $this;
199
    }
200
201
    /**
202
     * @param string $contactName
203
     * @return $this
204
     */
205
    public function setContactName(string $contactName): Site
206
    {
207
        $this->setAttribute('contact_name', $contactName);
208
209
        return $this;
210
    }
211
212
    /**
213
     * @param string $contactPhone
214
     * @return $this
215
     */
216
    public function setContactPhone(string $contactPhone): Site
217
    {
218
        $this->setAttribute('contact_phone', $contactPhone);
219
220
        return $this;
221
    }
222
223
    /**
224
     * @param string $contactEmail
225
     * @return $this
226
     */
227
    public function setContactEmail(string $contactEmail): Site
228
    {
229
        $this->setAttribute('contact_email', $contactEmail);
230
231
        return $this;
232
    }
233
234
    /**
235
     * @param string $comments
236
     * @return $this
237
     */
238
    public function setComments(string $comments): Site
239
    {
240
        $this->setAttribute('comments', $comments);
241
242
        return $this;
243
    }
244
}
245