質問編集履歴

2

画像の追加

2020/10/18 12:05

投稿

kur3
kur3

スコア8

test CHANGED
File without changes
test CHANGED
@@ -243,3 +243,11 @@
243
243
  }
244
244
 
245
245
  ```
246
+
247
+ dd($this->request->getData());のアップロードした場合
248
+
249
+ ![dd($this->request->getData());のアップロードした場合](cd3cc8bd5849f6cce0074376623b085d.png)
250
+
251
+ dd($this->request->getData());のアップロードしない場合
252
+
253
+ ![dd($this->request->getData());のアップロードしない場合](6e8d6b7878f96d7d11a318f2c5f546b9.png)

1

PatchEntityの追加

2020/10/18 12:05

投稿

kur3
kur3

スコア8

test CHANGED
File without changes
test CHANGED
@@ -123,3 +123,123 @@
123
123
  }
124
124
 
125
125
  ```
126
+
127
+ ```
128
+
129
+ <?php
130
+
131
+ declare(strict_types=1);
132
+
133
+
134
+
135
+ namespace App\Model\Entity;
136
+
137
+
138
+
139
+ use Cake\ORM\Entity;
140
+
141
+ use Cake\Auth\DefaultPasswordHasher;
142
+
143
+
144
+
145
+ /**
146
+
147
+ * Employee Entity
148
+
149
+ *
150
+
151
+ * @property int $id
152
+
153
+ * @property string $name
154
+
155
+ * @property string $password
156
+
157
+ * @property string|null $image
158
+
159
+ * @property string $email
160
+
161
+ * @property int $role
162
+
163
+ * @property \Cake\I18n\FrozenTime $created
164
+
165
+ * @property \Cake\I18n\FrozenTime $modified
166
+
167
+ */
168
+
169
+ class Employee extends Entity
170
+
171
+ {
172
+
173
+ /**
174
+
175
+ * Fields that can be mass assigned using newEntity() or patchEntity().
176
+
177
+ *
178
+
179
+ * Note that when '*' is set to true, this allows all unspecified fields to
180
+
181
+ * be mass assigned. For security purposes, it is advised to set '*' to false
182
+
183
+ * (or remove it), and explicitly make individual fields accessible as needed.
184
+
185
+ *
186
+
187
+ * @var array
188
+
189
+ */
190
+
191
+ protected $_accessible = [
192
+
193
+ 'name' => true,
194
+
195
+ 'password' => true,
196
+
197
+ 'image' => true,
198
+
199
+ 'email' => true,
200
+
201
+ 'role' => true,
202
+
203
+ 'created' => true,
204
+
205
+ 'modified' => true,
206
+
207
+ ];
208
+
209
+
210
+
211
+ /**
212
+
213
+ * Fields that are excluded from JSON versions of the entity.
214
+
215
+ *
216
+
217
+ * @var array
218
+
219
+ */
220
+
221
+ protected $_hidden = [
222
+
223
+ 'password',
224
+
225
+ ];
226
+
227
+
228
+
229
+ protected function _setPassword($password)
230
+
231
+ {
232
+
233
+ if (strlen($password) > 0) {
234
+
235
+ return (new DefaultPasswordHasher)->hash($password);
236
+
237
+ }
238
+
239
+ }
240
+
241
+
242
+
243
+ }
244
+
245
+ ```