質問編集履歴
3
解決内容の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -365,3 +365,65 @@
|
|
365
365
|
|
366
366
|
|
367
367
|
```
|
368
|
+
|
369
|
+
## 解決した詳細
|
370
|
+
|
371
|
+
## EmployeesController.php
|
372
|
+
|
373
|
+
```ここに言語を入力
|
374
|
+
|
375
|
+
<?php
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
namespace App\Http\Controllers;
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
use Illuminate\Http\Request;
|
384
|
+
|
385
|
+
use App\Employee;
|
386
|
+
|
387
|
+
use App\Goods;
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
class EmployeesController extends Controller
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
public function update(Request $request, $id)
|
396
|
+
|
397
|
+
{
|
398
|
+
|
399
|
+
$employee = Employee::find($id);
|
400
|
+
|
401
|
+
$employee->office = $request->office;
|
402
|
+
|
403
|
+
$employee->save();
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
$goods = $employee->goods()->latest()->first();//(修正後)
|
408
|
+
|
409
|
+
//(修正前)$goods = Goods::find($id);
|
410
|
+
|
411
|
+
$goods->uniform = $request->uniform;
|
412
|
+
|
413
|
+
$goods->winter_clothes = $request->winter_clothes;
|
414
|
+
|
415
|
+
$goods->shoes = $request->shoes;
|
416
|
+
|
417
|
+
$goods->other = $request->other;
|
418
|
+
|
419
|
+
$goods->memo = $request->memo;
|
420
|
+
|
421
|
+
$goods->save();
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
return view('employee_show', compact('employee'));
|
426
|
+
|
427
|
+
}
|
428
|
+
|
429
|
+
```
|
2
文章の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,12 @@
|
|
10
10
|
|
11
11
|
調べても見出せずにいますので何卒宜しくお願いいたします。
|
12
12
|
|
13
|
+
|
14
|
+
|
15
|
+
**__Laravel バージョン 6.20.8
|
16
|
+
|
17
|
+
__**
|
18
|
+
|
13
19
|
### EmployeesController.php
|
14
20
|
|
15
21
|
```ここに言語を入力
|
1
文章の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -269,3 +269,93 @@
|
|
269
269
|
@endsection
|
270
270
|
|
271
271
|
```
|
272
|
+
|
273
|
+
## Employee.php
|
274
|
+
|
275
|
+
```ここに言語を入力
|
276
|
+
|
277
|
+
<?php
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
namespace App;
|
282
|
+
|
283
|
+
use IlluminateSupportFacadesDB;
|
284
|
+
|
285
|
+
use Illuminate\Database\Eloquent\Model;
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
class Employee extends Model
|
290
|
+
|
291
|
+
{
|
292
|
+
|
293
|
+
protected $fillable = ['id','emlpoyee_id','employee_name','office'];
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
public function goods()
|
298
|
+
|
299
|
+
{
|
300
|
+
|
301
|
+
return $this->hasMany(Goods::class);
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
```
|
310
|
+
|
311
|
+
## Goods.php
|
312
|
+
|
313
|
+
```ここに言語を入力
|
314
|
+
|
315
|
+
<?php
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
namespace App;
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
use Illuminate\Database\Eloquent\Model;
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
class Goods extends Model
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
protected $fillable = ['employee_id','uniform','winter_clothes','shoes','other','memo'];
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
protected $guarded = array('id');
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
public function getDate()
|
340
|
+
|
341
|
+
{
|
342
|
+
|
343
|
+
return $this->belongsTo(Employee::class);
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
public function employee()
|
350
|
+
|
351
|
+
{
|
352
|
+
|
353
|
+
return $this->belongsTo(Employee::class);
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
```
|