質問編集履歴

2

HrUserモデルの追加

2021/04/04 17:24

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -382,6 +382,104 @@
382
382
 
383
383
  }
384
384
 
385
- コード
385
+
386
386
 
387
387
  ```
388
+
389
+
390
+
391
+ <HrUser.php>
392
+
393
+ ```php
394
+
395
+ <?php
396
+
397
+
398
+
399
+ namespace App\Models;
400
+
401
+
402
+
403
+ use Illuminate\Database\Eloquent\Factories\HasFactory;
404
+
405
+ use Illuminate\Database\Eloquent\Model;
406
+
407
+ use Illuminate\Notifications\Notifiable;
408
+
409
+
410
+
411
+ class HrUser extends Model
412
+
413
+ {
414
+
415
+ use HasFactory, Notifiable;
416
+
417
+
418
+
419
+ /**
420
+
421
+ * The attributes that are mass assignable.
422
+
423
+ *
424
+
425
+ * @var array
426
+
427
+ */
428
+
429
+
430
+
431
+ //$guarded は変更できないカラム
432
+
433
+ protected $guarded = [
434
+
435
+ 'details_id',
436
+
437
+ ];
438
+
439
+
440
+
441
+ /**
442
+
443
+ * The attributes that should be hidden for arrays.
444
+
445
+ *
446
+
447
+ * @var array
448
+
449
+ */
450
+
451
+ protected $hidden = [
452
+
453
+ 'password',
454
+
455
+ 'remember_token',
456
+
457
+ ];
458
+
459
+
460
+
461
+ /**
462
+
463
+ * The attributes that should be cast to native types.
464
+
465
+ *
466
+
467
+ * @var array
468
+
469
+ */
470
+
471
+ protected $casts = [
472
+
473
+ 'email_verified_at' => 'datetime',
474
+
475
+ ];
476
+
477
+
478
+
479
+ protected $table = 'hr_users';
480
+
481
+ }
482
+
483
+
484
+
485
+ ```

1

vendor\laravel\ui\auth-backend\RegistersUsers.phpの追記

2021/04/04 17:24

投稿

Yuu412
Yuu412

スコア37

test CHANGED
File without changes
test CHANGED
@@ -255,3 +255,133 @@
255
255
 
256
256
 
257
257
  ```
258
+
259
+
260
+
261
+ <vendor\laravel\ui\auth-backend\RegistersUsers.php>
262
+
263
+ ```php
264
+
265
+
266
+
267
+ trait RegistersUsers
268
+
269
+ {
270
+
271
+ use RedirectsUsers;
272
+
273
+
274
+
275
+ /**
276
+
277
+ * Show the application registration form.
278
+
279
+ *
280
+
281
+ * @return \Illuminate\View\View
282
+
283
+ */
284
+
285
+ public function showRegistrationForm()
286
+
287
+ {
288
+
289
+ return view('auth.register');
290
+
291
+ }
292
+
293
+
294
+
295
+ /**
296
+
297
+ * Handle a registration request for the application.
298
+
299
+ *
300
+
301
+ * @param \Illuminate\Http\Request $request
302
+
303
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
304
+
305
+ */
306
+
307
+ public function register(Request $request)
308
+
309
+ {
310
+
311
+ $this->validator($request->all())->validate();
312
+
313
+
314
+
315
+ event(new Registered($user = $this->create($request->all())));
316
+
317
+
318
+
319
+ $this->guard()->login($user);
320
+
321
+
322
+
323
+ if ($response = $this->registered($request, $user)) {
324
+
325
+ return $response;
326
+
327
+ }
328
+
329
+
330
+
331
+ return $request->wantsJson()
332
+
333
+ ? new JsonResponse([], 201)
334
+
335
+ : redirect($this->redirectPath());
336
+
337
+ }
338
+
339
+
340
+
341
+ /**
342
+
343
+ * Get the guard to be used during registration.
344
+
345
+ *
346
+
347
+ * @return \Illuminate\Contracts\Auth\StatefulGuard
348
+
349
+ */
350
+
351
+ protected function guard()
352
+
353
+ {
354
+
355
+ return Auth::guard();
356
+
357
+ }
358
+
359
+
360
+
361
+ /**
362
+
363
+ * The user has been registered.
364
+
365
+ *
366
+
367
+ * @param \Illuminate\Http\Request $request
368
+
369
+ * @param mixed $user
370
+
371
+ * @return mixed
372
+
373
+ */
374
+
375
+ protected function registered(Request $request, $user)
376
+
377
+ {
378
+
379
+ //
380
+
381
+ }
382
+
383
+ }
384
+
385
+ コード
386
+
387
+ ```