{"id":11900,"date":"2023-08-27T07:00:32","date_gmt":"2023-08-26T22:00:32","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=11900"},"modified":"2023-08-05T02:35:03","modified_gmt":"2023-08-04T17:35:03","slug":"laravel-multi-auth-%e3%81%aa%e3%83%a6%e3%83%bc%e3%82%b6%e3%83%bc%e9%96%93%e3%81%a7%e3%83%a1%e3%83%83%e3%82%bb%e3%83%bc%e3%82%b8%e9%80%81%e4%bf%a1%e3%81%a7%e3%81%8d%e3%82%8b%e3%82%88%e3%81%86%e3%81%ab","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=11900","title":{"rendered":"Laravel Multi-Auth \u306a\u30e6\u30fc\u30b6\u30fc\u9593\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u9593\u3053\u306e\u30d6\u30ed\u30b0\u3067\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u516c\u958b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong>\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=11802\">Laravel Breeze\uff1a Multi Auth \u3057\u306a\u304c\u3089\u30ed\u30b0\u30a4\u30f3\u30fb\u767b\u9332\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u518d\u767a\u884c\u30fbEmail Verification \u306b\u5bfe\u5fdc\u3055\u305b\u308b<\/a><\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u3088\u3046\u306a<code>Multi-Auth<\/code>\uff08\u5c02\u7528\u306e\u30e6\u30fc\u30b6\u30fc\u30c6\u30fc\u30d6\u30eb\u3092\u5229\u7528\u3057\u305f\u30ed\u30b0\u30a4\u30f3\uff09\u3092\u4f7f\u3063\u305f\u3068\u304d\u306b\u300c<strong>\u3042\u3001\u3053\u308c\u3061\u3087\u3063\u3068\u96e3\u3057\u3044\u304b\u3082<\/strong>\u300d\u3068\u601d\u3063\u305f\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u30e1\u30c3\u30bb\u30fc\u30b8\u6a5f\u80fd<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3001\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u306e\u304c<code>users<\/code>\u3060\u3051\u306a\u3089<code>sender_id<\/code>, <code>receiver_id<\/code>\u3092\u30ab\u30e9\u30e0\u306b\u6301\u305f\u305b\u3066\u4fdd\u5b58\u3059\u308c\u3070\u30b7\u30f3\u30d7\u30eb\u3067\u3044\u3044\u306e\u3067\u3059\u304c\u3001<code>Multi-Auth<\/code>\u306e\u5834\u5408\u306f\u305d\u3046\u306f\u3044\u304d\u307e\u305b\u3093\u3088\u306d\u3002<\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f<code>Multi-Auth<\/code>\u3057\u3066\u308b<code>Laravel<\/code>\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5225\u30e6\u30fc\u30b6\u30fc\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3063\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u751f\u5f92 &#8211;&gt; \u5148\u751f \u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1<\/li>\n<li>\u5148\u751f &#8211;&gt; \u751f\u5f92\u3000\u3003<\/li>\n<li>\u751f\u5f92 &#8211;&gt; \u5225\u306e\u751f\u5f92\u3000\u3003<\/li>\n<li>\u5148\u751f &#8211;&gt; \u5225\u306e\u5148\u751f\u3000\u3003<\/li>\n<\/ul>\n<p>\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude04\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4445 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2.png\" alt=\"\" width=\"370\" height=\"310\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2-300x251.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n<p style=\"text-align: center;\">\u4ee4\u548c\u306e\u864e<br \/>\n\u300e\u30d0\u30ab\u306f\u6210\u529f\u306b\u5b66\u3093\u3067\u5931\u6557\u3057\u3001<br \/>\n\u5229\u53e3\u306f\u5931\u6557\u306b\u5b66\u3093\u3067\u6210\u529f\u3059\u308b\u300f<br \/>\n\u8033\u304c\u75db\u3044\u3067\u3059\u306a\u2026\ud83d\ude05<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a Laravel 10.x<\/strong><\/p>\n<h1>\u524d\u63d0\u3068\u3057\u3066<\/h1>\n<p><code>Laravel Breeze<\/code>\u3092\u4f7f\u3063\u305f<code>Multi-Auth<\/code>\u306b\u5bfe\u5fdc\u3067\u304d\u3066\u3044\u308b\u3053\u3068\uff08\u5c02\u7528\u30c6\u30fc\u30d6\u30eb\u3067\u30ed\u30b0\u30a4\u30f3\u304c\u3067\u304d\u308b\u3053\u3068\uff09\u304c\u524d\u63d0\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306f\u5fc5\u8981\u306a\u306e\u306f\u4ee5\u4e0b\uff12\u3064\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u4f7f\u3063\u305f\u30ed\u30b0\u30a4\u30f3\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u751f\u5f92\uff1a Student<\/li>\n<li>\u5148\u751f\uff1a Teacher<\/li>\n<\/ul>\n<p>\u203b \u30db\u30f3\u30c8\u306f<code>Parent<\/code>\u3082\u5165\u308c\u305f\u304b\u3063\u305f\u3067\u3059\u304c\u3001\u8907\u96d1\u306b\u306a\u308b\u306e\u3067\u4eca\u56de\u306f\uff12\u3064\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3082\u3057\u307e\u3060\u306e\u65b9\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3092\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a<\/strong>\u00a0<a href=\"https:\/\/blog.capilano-fw.com\/?p=11802\">Laravel Breeze\uff1a Multi Auth \u3057\u306a\u304c\u3089\u30ed\u30b0\u30a4\u30f3\u30fb\u767b\u9332\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u518d\u767a\u884c\u30fbEmail Verification \u306b\u5bfe\u5fdc\u3055\u305b\u308b<\/a><\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u305d\u3057\u3066\u3001\u5148\u307b\u3069\u6319\u3052\u305f\uff12\u3064\u306e\u30e6\u30fc\u30b6\u30fc\u9593\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u300cStudent\u300d\u304b\u3089\u300cTeacher\u300d\u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1<\/li>\n<li>\u300cTeacher\u300d\u304b\u3089\u300cStudent\u300d\u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1<\/li>\n<li>\u300cStudent\u300d\u304b\u3089\u300cStudent\u300d\u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1<\/li>\n<li>\u300cTeacher\u300d\u304b\u3089\u300cTeacher\u300d\u3078\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001\u81ea\u5206\u4ee5\u5916\u306e\u30e6\u30fc\u30b6\u30fc\u306a\u3089\u300c\u751f\u5f92\u300d\u300c\u5148\u751f\u300d\u95a2\u4fc2\u306a\u304f\u8ab0\u306b\u3067\u3082\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u9001\u308c\u308b\u3088\u3046\u3057\u307e\u3059\u3002<\/p>\n<h1>\u4e8b\u524d\u77e5\u8b58\u3068\u3057\u3066<\/h1>\n<p>\u79c1\u3082\u8907\u96d1\u306aDB\u69cb\u6210\u306f\u305d\u308c\u307b\u3069\u5f97\u610f\u3058\u3083\u306a\u3044\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u300c<strong>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u95a2\u9023<\/strong>\u300d\u3068\u547c\u3070\u308c\u308b\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3092\u907f\u3051\u305f\u69cb\u6210\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u95a2\u9023\u3068\u306f\u3001\u30b7\u30f3\u30d7\u30eb\u306b\u8a00\u3046\u3068\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u304c\u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u53c2\u7167\u3059\u308b\u69cb\u9020\u306e\u3053\u3068\u3067\u3001\u4f8b\u3048\u3070\u3001<\/p>\n<ul>\n<li>\u3053\u306e\u30b3\u30e1\u30f3\u30c8\u306f\u300cteachers\u300d\u306e ID: 3 \u306e\u4eba\u304c\u66f8\u3044\u305f\u3082\u306e<\/li>\n<li>\u3053\u3063\u3061\u306e\u30b3\u30e1\u30f3\u30c8\u306f\u300cstudents\u300d\u306e ID: 5 \u306e\u4eba\u304c\u66f8\u3044\u305f\u3082\u306e<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u3088\u3046\u306b\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u5148\u304c\u53ef\u5909\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u3053\u308c\u3092\u3059\u308b\u3068<strong>\u5916\u90e8\u30ad\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u30a2\u30f3\u30c1\u30d1\u30bf\u30fc\u30f3\u3068\u3055\u308c\u3066\u3044\u308b<\/strong>\u3088\u3046\u3067\u3059\u3002\uff08\u500b\u4eba\u7684\u306b\u306f<code>Laravel<\/code>\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u3064\u3051\u3066\u304a\u3051\u3070\u5927\u4e08\u592b\u306a\u3093\u3058\u3083\u306a\u3044\u304b\u306a\u3068\u3082\u601d\u3046\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u3082\u7d76\u5bfe\u3067\u306f\u3042\u308a\u307e\u305b\u3093\uff09<\/p>\n<p>\u5b9f\u969b\u306e\u30c6\u30fc\u30d6\u30eb\u3067\u8a00\u3046\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11901\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_1.png\" alt=\"\" width=\"596\" height=\"301\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_1.png 596w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_1-300x152.png 300w\" sizes=\"auto, (max-width: 596px) 100vw, 596px\" \/><\/p>\n<p>\u3067\u306f\u3001\uff08\u4eca\u56de\u306f\u4f7f\u3044\u307e\u305b\u3093\u304c\uff09\u3053\u308c\u3082\u8e0f\u307e\u3048\u3064\u3064\u3001\u697d\u3057\u3093\u3067\u3084\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>DB\u307e\u308f\u308a\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u30e2\u30c7\u30eb\uff06\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3001<code>Seeder<\/code>\u306a\u3069\u306e<code>DB<\/code>\u95a2\u9023\u306e\u90e8\u5206\u304b\u3089\u306f\u3058\u3081\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4ee5\u4e0b\uff14\u3064\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:model MultiAuthUser -m \r\nphp artisan make:model Student -ms\r\nphp artisan make:model Teacher -ms\r\nphp artisan make:model Message -m\r\n<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u3001\u516810\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u4e2d\u8eab\u3092\u305d\u308c\u305e\u308c\u5909\u66f4\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u203b \u306a\u304a\u3001\u69cb\u9020\u3068\u3057\u3066\u306f\u3001<code>MultiAuthUser<\/code>\u304c<code>Student<\/code>\u3068<code>Teacher<\/code>\u306e\u89aa\u30c6\u30fc\u30d6\u30eb\u306b\u306a\u308a\u3001<code>Message<\/code>\u306b\u767b\u9332\u3059\u308b\u306e\u306f\u5168\u3066<code>MultiAuthUser<\/code>\u306eID\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h1>\u30e2\u30c7\u30eb\u306e\u4e2d\u8eab<\/h1>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f\u30e2\u30c7\u30eb\u3067\u3059\u3002<\/p>\n<p><strong>app\/Models\/Student.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse App\\Traits\\MessageTrait;\r\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\r\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\r\n\r\nclass Student extends Authenticatable\r\n{\r\n    use HasFactory, MessageTrait;\r\n\r\n    \/\/ Relationship\r\n    public function multi_auth_user()\r\n    {\r\n        return $this-&gt;belongsTo(MultiAuthUser::class, 'multi_auth_user_id', 'id');\r\n    }\r\n}<\/strong><\/pre>\n<p><strong>app\/Models\/Teacher.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse App\\Traits\\MessageTrait;\r\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\r\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\r\n\r\nclass Teacher extends Authenticatable\r\n{\r\n    use HasFactory, MessageTrait;\r\n\r\n    \/\/ Relationship\r\n    public function multi_auth_user()\r\n    {\r\n        return $this-&gt;belongsTo(MultiAuthUser::class, 'multi_auth_user_id', 'id');\r\n    }\r\n}\r\n<\/strong><\/pre>\n<p><span style=\"font-size: 1.5rem;\">Trait \u3067\u5171\u901a\u90e8\u5206\u3092\u3064\u304f\u308b<\/span><\/p>\n<p>\u5148\u307b\u3069\u306e<code>Student<\/code>\u3068<code>Teacher<\/code>\u30e2\u30c7\u30eb\u306b\u306f\u3069\u3061\u3089\u306b\u3082\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u304c\u3067\u304d\u308b<code>sendMessage()<\/code>\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u30b7\u30f3\u30d7\u30eb\u306b\u4e21\u65b9\u306b\u540c\u3058\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3057\u307e\u3046\u3068\u5f8c\u3067\u5909\u66f4\u304c\u3042\u3063\u305f\u3068\u304d\u5168\u3066\u3092\u5909\u66f4\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u304f\u306a\u308b\u306e\u3067\u3001\u30e1\u30f3\u30c6\u30f3\u30ca\u30f3\u30b9\u304c\u3057\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u4eca\u56de\u306f<code>Trait<\/code>\u3067\u5171\u901a\u5316\u3057\u3001\u30b3\u30fc\u30c9\u304c\uff11\u304b\u6240\u3060\u3051\u3067\u6e08\u3080\u3088\u3046\u306b\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>app\/Traits\/MessageTrait.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace App\\Traits;\r\n\r\nuse App\\Models\\Message;\r\n\r\ntrait MessageTrait\r\n{\r\n    public function sendMessage($message_body, $receiver)\r\n    {\r\n        $message = new Message();\r\n        $message-&gt;sender_id = $this-&gt;multi_auth_user-&gt;id;\r\n        $message-&gt;receiver_id = $receiver-&gt;multi_auth_user-&gt;id;\r\n        $message-&gt;body = $message_body;\r\n\r\n        $message-&gt;save();\r\n\r\n        return $message;\r\n    }\r\n} <\/strong><\/pre>\n<p>\u306a\u304a\u3001\u3053\u306e\u30c8\u30ec\u30a4\u30c8\u306f\u3059\u3067\u306b<code>Student<\/code>\u3068<code>Teacher<\/code>\u30e2\u30c7\u30eb\u306b\u30bb\u30c3\u30c8\u6e08\u3067\u3059\u3002<\/p>\n<h1>Enum \u3067\u30e6\u30fc\u30b6\u30fc\u30bf\u30a4\u30d7\u3092\u7ba1\u7406\u3057\u3084\u3059\u304f\u3059\u308b<\/h1>\n<p>\u3053\u308c\u3082\u5148\u307b\u3069\u3068\u540c\u3058\u304f\u300c<strong>\u5171\u901a\u5316\uff08\u30c7\u30fc\u30bf\u306e\u4e00\u5143\u7ba1\u7406\uff09<\/strong>\u300d\u3059\u308b\u30c6\u30af\u30cb\u30c3\u30af\u306a\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u4f7f\u3046\u4ee5\u4e0b\uff12\u3064\u306e\u300c\u30e6\u30fc\u30b6\u30fc\u30bf\u30a4\u30d7\u300d\u3092\u7ba1\u7406\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u751f\u5f92\uff1a Student<\/li>\n<li>\u5148\u751f\uff1a Teacher<\/li>\n<\/ul>\n<p>\u5b9f\u969b\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>app\/Enums\/MultiAuthUserEnum.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace App\\Enums;\r\n\r\nuse Illuminate\\Support\\Arr;\r\n\r\nenum MultiAuthUserEnum: string\r\n{\r\n    case Student = 'student';\r\n    case Teacher = 'teacher';\r\n\r\n    public function label()\r\n    {\r\n        return match ($this) {\r\n            self::Student =&gt; '\u751f\u5f92',\r\n            self::Teacher =&gt; '\u5148\u751f',\r\n        };\r\n    }\r\n\r\n    public static function values()\r\n    {\r\n        $cases = self::cases();\r\n\r\n        return Arr::map($cases, fn($case) =&gt; $case-&gt;value);\r\n    }\r\n}<\/strong><\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b<code>Enum<\/code>\u306f<code>PHP 8.1<\/code>\u304b\u3089\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<h1>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u4e2d\u8eab<\/h1>\n<p>\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30fb\u30c6\u30fc\u30d6\u30eb\u306e\u8a2d\u8a08\u56f3\u3068\u3082\u8a00\u3048\u308b\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><strong>database\/migrations\/****_**_**_******_create_multi_auth_users_table.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function up(): void\r\n{\r\n    Schema::create('<strong>multi_auth_users<\/strong>', function (Blueprint $table) {\r\n        <strong>$table-&gt;id();\r\n        $table-&gt;timestamps();<\/strong>\r\n    });\r\n}\r\n\r\n\/\/ \u7701\u7565\r\n<\/pre>\n<p><strong>database\/migrations\/****_**_**_******_create_students_table.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function up(): void\r\n{\r\n    Schema::create('<strong>students<\/strong>', function (Blueprint $table) {\r\n        <strong>$table-&gt;id();\r\n        $table-&gt;unsignedBigInteger('multi_auth_user_id')-&gt;comment('Multi-Auth\u30e6\u30fc\u30b6\u30fcID');\r\n        $table-&gt;string('email')-&gt;unique()-&gt;comment('\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9');\r\n        $table-&gt;string('password')-&gt;comment('\u30d1\u30b9\u30ef\u30fc\u30c9');\r\n        $table-&gt;string('name')-&gt;comment('\u540d\u524d');\r\n        $table-&gt;timestamps();\r\n\r\n        $table-&gt;foreign('multi_auth_user_id')-&gt;references('id')-&gt;on('multi_auth_users')-&gt;onDelete('cascade');<\/strong>\r\n    });\r\n}\r\n\r\n\/\/ \u7701\u7565\r\n<\/pre>\n<p><strong>database\/migrations\/****_**_**_******_create_teachers_table.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function up(): void\r\n{\r\n    Schema::create('<strong>teachers<\/strong>', function (Blueprint $table) {\r\n        <strong>$table-&gt;id();\r\n        $table-&gt;unsignedBigInteger('multi_auth_user_id')-&gt;comment('Multi-Auth\u30e6\u30fc\u30b6\u30fcID');\r\n        $table-&gt;string('email')-&gt;unique()-&gt;comment('\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9');\r\n        $table-&gt;string('password')-&gt;comment('\u30d1\u30b9\u30ef\u30fc\u30c9');\r\n        $table-&gt;string('name')-&gt;comment('\u540d\u524d');\r\n        $table-&gt;timestamps();\r\n\r\n        $table-&gt;foreign('multi_auth_user_id')-&gt;references('id')-&gt;on('multi_auth_users')-&gt;onDelete('cascade');<\/strong>\r\n    });\r\n}\r\n\r\n\/\/ \u7701\u7565\r\n<\/pre>\n<p><strong>database\/migrations\/****_**_**_******_create_messages_table.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function up(): void\r\n{\r\n    Schema::create('<strong>messages<\/strong>', function (Blueprint $table) {\r\n        <strong>$table-&gt;id();\r\n        $table-&gt;unsignedBigInteger('sender_id')-&gt;comment('\u9001\u4fe1\u8005ID');\r\n        $table-&gt;unsignedBigInteger('receiver_id')-&gt;comment('\u53d7\u4fe1\u8005ID');\r\n        $table-&gt;text('body')-&gt;comment('\u30e1\u30c3\u30bb\u30fc\u30b8\u5185\u5bb9');\r\n        $table-&gt;timestamps();\r\n\r\n        $table-&gt;foreign('sender_id')-&gt;references('id')-&gt;on('multi_auth_users')-&gt;onDelete('cascade');\r\n        $table-&gt;foreign('receiver_id')-&gt;references('id')-&gt;on('multi_auth_users')-&gt;onDelete('cascade');<\/strong>\r\n    });\r\n}\r\n\r\n\/\/ \u7701\u7565\r\n<\/pre>\n<h1>Seeder \u306e\u4e2d\u8eab<\/h1>\n<p>\u3067\u306f\u3001\u81ea\u52d5\u3067<code>Student<\/code>\u3068<code>Teacher<\/code>\u306e\u300c<strong>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf<\/strong>\u300d\u304c\u4f5c\u308c\u308b\u3088\u3046\u306b<code>Seeder<\/code>\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>database\/seeders\/StudentSeeder.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\nuse App\\Models\\MultiAuthUser;\r\nuse App\\Models\\Student;\r\nuse Database\\Factories\\StudentFactory;\r\nuse Illuminate\\Database\\Console\\Seeds\\WithoutModelEvents;\r\nuse Illuminate\\Database\\Seeder;\r\nuse Illuminate\\Support\\Facades\\Hash;\r\n\r\nclass StudentSeeder extends Seeder\r\n{\r\n    \/**\r\n     * Run the database seeds.\r\n     *\/\r\n    public function run(): void\r\n    {\r\n        for($i = 1; $i &lt;= 10; $i++) {\r\n\r\n            \/\/ Multi-Auth\r\n            $multi_auth_user = new MultiAuthUser();\r\n            $multi_auth_user-&gt;save();\r\n\r\n            \/\/ Student\r\n            $email = 'student' . $i . '@example.com';\r\n            $student = new Student([\r\n                'multi_auth_user_id' =&gt; $multi_auth_user-&gt;id,\r\n                'email' =&gt; $email,\r\n                'password' =&gt; Hash::make('password'),\r\n                'name' =&gt; '\u751f\u5f92 ' . $i,\r\n            ]);\r\n            $student-&gt;save();\r\n\r\n        }\r\n    }\r\n}\r\n<\/strong><\/pre>\n<p><strong>database\/seeders\/TeacherSeeder.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\nuse App\\Models\\MultiAuthUser;\r\nuse App\\Models\\Teacher;\r\nuse Illuminate\\Database\\Console\\Seeds\\WithoutModelEvents;\r\nuse Illuminate\\Database\\Seeder;\r\nuse Illuminate\\Support\\Facades\\Hash;\r\n\r\nclass TeacherSeeder extends Seeder\r\n{\r\n    \/**\r\n     * Run the database seeds.\r\n     *\/\r\n    public function run(): void\r\n    {\r\n        for($i = 1; $i &lt;= 10; $i++) {\r\n\r\n            \/\/ Multi-Auth\r\n            $multi_auth_user = new MultiAuthUser();\r\n            $multi_auth_user-&gt;save();\r\n\r\n            \/\/ Teacher\r\n            $email = 'teacher' . $i . '@example.com';\r\n            $teacher = new Teacher([\r\n                'multi_auth_user_id' =&gt; $multi_auth_user-&gt;id,\r\n                'email' =&gt; $email,\r\n                'password' =&gt; Hash::make('password'),\r\n                'name' =&gt; '\u5148\u751f ' . $i,\r\n            ]);\r\n            $teacher-&gt;save();\r\n\r\n        }\r\n    }\r\n}\r\n<\/strong><\/pre>\n<p>\u306a\u304a\u3001<code>Seeder<\/code>\u306f\u4f5c\u6210\u3057\u305f\u3060\u3051\u3067\u306f\u6709\u52b9\u306b\u306a\u308a\u307e\u305b\u3093\u306e\u3067\u3001<code>Laravel<\/code>\u3078\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<p><strong>database\/seeders\/DatabaseSeeder.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\n<strong>public function run(): void\r\n{\r\n    $this-&gt;call([\r\n        StudentSeeder::class, \/\/ \ud83d\udc48 \u3053\u3053 &amp;\r\n        TeacherSeeder::class, \/\/ \ud83d\udc48 \u3053\u3053\r\n    ]);\r\n}<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n<\/pre>\n<p>\u3067\u306f\u3001\u3053\u306e\u72b6\u614b\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u521d\u671f\u5316\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan migrate:fresh --seed\r\n<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u5b9f\u969b\u306e\u30c6\u30fc\u30d6\u30eb\u306f\u3053\u3046\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11904\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_2.png\" alt=\"\" width=\"570\" height=\"400\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_2.png 570w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_2-300x211.png 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11905\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_3.png\" alt=\"\" width=\"570\" height=\"400\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_3.png 570w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_3-300x211.png 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/p>\n<p>\u3067\u306f\u4eca\u56de\u306f\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f\u57fa\u672c\u7684\u306a<code>CRUD<\/code>\u3067OK\u306a\u306e\u3067\u7701\u7565\u3057\u307e\u3059\u3002<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\ud83d\ude04\ud83d\udc4d<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<\/p>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306f<code>PhpUnit<\/code>\u3092\u4f7f\u3063\u3066\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002\uff08<code>Pest<\/code>\u304c\u4e3b\u6d41\u3068\u306e\u5642\u3067\u3059\u304c\u307e\u3060\u624b\u3092\u51fa\u3057\u3066\u3044\u307e\u305b\u3093\u3001\u305d\u306e\u3046\u3061\u3053\u3063\u305d\u308a\u59cb\u3081\u307e\u3057\u3087\u3046\u306d\u2026\ud83d\ude05\uff09<\/p>\n<pre><strong>php artisan make:test MessageTest\r\n<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>tests\/Feature\/MessageTest.php<\/strong><\/p>\n<pre><strong>&lt;?php\r\n\r\nnamespace Tests\\Feature;\r\n\r\nuse App\\Models\\Message;\r\nuse App\\Models\\Student;\r\nuse App\\Models\\Teacher;\r\nuse Illuminate\\Foundation\\Testing\\RefreshDatabase;\r\nuse Illuminate\\Foundation\\Testing\\WithFaker;\r\nuse Illuminate\\Support\\Str;\r\nuse Tests\\TestCase;\r\n\r\nclass MessageTest extends TestCase\r\n{\r\n    public function test_can_send_messages()\r\n    {\r\n        $keys = [\r\n            'student --&gt; teacher',\r\n            'teacher --&gt; student',\r\n            'student --&gt; student',\r\n            'teacher --&gt; teacher',\r\n        ];\r\n\r\n        foreach ($keys as $key) {\r\n\r\n            $sender = null;\r\n            $receiver = null;\r\n\r\n            if(Str::startsWith($key, 'student')) {\r\n\r\n                $sender = Student::inRandomOrder()-&gt;first();\r\n\r\n            } else if(Str::startsWith($key, 'teacher')) {\r\n\r\n                $sender = Teacher::inRandomOrder()-&gt;first();\r\n\r\n            }\r\n\r\n            if(Str::endsWith($key, 'student')) {\r\n\r\n                $receiver = Student::inRandomOrder()-&gt;first();\r\n\r\n            } else if(Str::endsWith($key, 'teacher')) {\r\n\r\n                $receiver = Teacher::inRandomOrder()-&gt;first();\r\n\r\n            }\r\n\r\n            $message_body = $key .': '. Str::random(); \/\/ \u30e9\u30f3\u30c0\u30e0\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u751f\u6210\r\n            $message = $sender-&gt;sendMessage($message_body, $receiver);\r\n\r\n            $this-&gt;assertEquals($message-&gt;sender_id, $sender-&gt;multi_auth_user-&gt;id);     \/\/ \u9001\u4fe1\u8005\u304c\u6b63\u3057\u3044\u3053\u3068\u3092\u78ba\u8a8d\r\n            $this-&gt;assertEquals($message-&gt;receiver_id, $receiver-&gt;multi_auth_user-&gt;id); \/\/ \u53d7\u4fe1\u8005\u304c\u6b63\u3057\u3044\u3053\u3068\u3092\u78ba\u8a8d\r\n            $this-&gt;assertEquals($message-&gt;body, $message_body);                         \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u6b63\u3057\u3044\u3053\u3068\u3092\u78ba\u8a8d\r\n\r\n            $messages = Message::query()\r\n                -&gt;where('sender_id', $sender-&gt;multi_auth_user-&gt;id)\r\n                -&gt;where('receiver_id', $receiver-&gt;multi_auth_user-&gt;id)\r\n                -&gt;get();\r\n\r\n            $this-&gt;assertGreaterThan(0, $messages-&gt;count()); \/\/ \u30e1\u30c3\u30bb\u30fc\u30b8\u304c1\u4ef6\u4ee5\u4e0a\u5b58\u5728\u3059\u308b\u3053\u3068\u3092\u78ba\u8a8d\r\n        }\r\n    }\r\n}\r\n<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u3001\u4ee5\u4e0b\u306e\uff14\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u3057\u3001\u305d\u306e\u5185\u5bb9\u304c\u3042\u3063\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u306e\u30c1\u30a7\u30c3\u30af\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u751f\u5f92 &#8211;&gt; \u5148\u751f \u3078\u9001\u4fe1<\/li>\n<li>\u5148\u751f &#8211;&gt; \u751f\u5f92 \u3078\u9001\u4fe1<\/li>\n<li>\u751f\u5f92 &#8211;&gt; \u751f\u5f92 \u3078\u9001\u4fe1<\/li>\n<li>\u5148\u751f &#8211;&gt; \u5148\u751f \u3078\u9001\u4fe1<\/li>\n<\/ul>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan test --filter MessageTest\r\n<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11906\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_4.png\" alt=\"\" width=\"481\" height=\"228\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_4.png 481w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_4-300x142.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u3046\u307e\u304f\u30c6\u30b9\u30c8\u3092\u901a\u904e\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u6210\u529f\u3067\u3059\u3002\ud83d\ude04\u2728<\/p>\n<p>\u3067\u306f\u3001\u5ff5\u306e\u305f\u3081<code>messages<\/code>\u30c6\u30fc\u30d6\u30eb\u304c\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u304b\u3082\u30c1\u30a7\u30c3\u30af\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3046\u307e\u304f\u3044\u3063\u3066\u3044\u308b\u3067\u3057\u3087\u3046\u304b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11907\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_5.png\" alt=\"\" width=\"570\" height=\"350\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_5.png 570w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2023\/08\/laravel_multi_auth_messaging_5-300x184.png 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><\/p>\n<p>\u306f\u3044\u2757<br \/>\n\u3059\u3079\u3066\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u9001\u4fe1\uff08\u4fdd\u5b58\uff09\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u5168\u3066\u6210\u529f\u3067\u3059\u3002\ud83d\ude04\ud83d\udc4d\u2728<\/p>\n<p>\u5f8c\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u5185\u3067\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u306b\u95a2\u9023\u3059\u308b\u3082\u306e\u3092\u5f15\u3063\u5f35\u3063\u3066\u304f\u308c\u3070\u3001\u305d\u306e\u4eba\u7528\u306e\u30c7\u30fc\u30bf\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<div>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse App\\Models\\Message;\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass MessageController extends Controller\r\n{\r\n    public function index(Request $request)\r\n    {\r\n        <strong>$user = $request-&gt;user();<\/strong>\r\n\r\n<strong>        $messages = Message::query()<\/strong>\r\n<strong>            -&gt;where('sender_id', $user-&gt;multi_auth_user_id)<\/strong>\r\n<strong>            -&gt;orWhere('receiver_id', $user-&gt;multi_auth_user_id)<\/strong>\r\n<strong>            -&gt;get();<\/strong>\r\n\r\n<strong>        dd($messages-&gt;toArray());<\/strong>\r\n    }\r\n}<\/pre>\n<\/div>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u3088\u3046\u306b<code>Multi\u2212Auth<\/code>\u3092\u7528\u3044\u3066\u3044\u3066\u3082<code>DB<\/code>\u69cb\u9020\u306e\u3082\u305f\u305b\u65b9\u6b21\u7b2c\u3067\u4eca\u56de\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u3088\u3046\u306a\u300c<strong>\u76f8\u4e92\u306b\u4f5c\u7528\u3059\u308b\u3088\u3046\u306a\u6a5f\u80fd<\/strong>\u300d\u3092\u6301\u305f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u5fa1\u793e\u306e\u30b7\u30b9\u30c6\u30e0\u306b\u8907\u6570\u30bf\u30a4\u30d7\u306e\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u304c\u5fc5\u8981\u3067\u3001\u3055\u3089\u306b\u305d\u306e\u4eba\u305f\u3061\u3092\u9023\u643a\u3055\u305b\u305f\u3044\u3068\u304a\u8003\u3048\u306e\u5834\u5408\u306f\u3001\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\ud83d\ude04\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Multi-Auth<\/code>\u3092\u4f7f\u3063\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><code>Multi-Auth<\/code>\u306f\u30c6\u30fc\u30d6\u30eb\u3092\u5206\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306a\u3069\u3001\u3088\u308a\u660e\u78ba\u306a<code>DB<\/code>\u69cb\u9020\u3092\u3064\u304f\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u53cd\u9762\u3001\u305d\u3046\u306a\u308b\u3068\u9023\u643a\u304c\u8907\u96d1\u306b\u306a\u3063\u305f\u308a\u3082\u3057\u307e\u3059\u304c\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u89aa\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u3046\u3053\u3068\u3067\u5b9f\u88c5\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u4f8b\u306e\u300c<strong>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u95a2\u9023<\/strong>\u300d\u306b\u3064\u3044\u3066\u306f\u3042\u307e\u308a\u7d4c\u9a13\u304c\u306a\u3044\u306e\u3067\u4e00\u6982\u306b\u306f\u8a00\u3048\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u8a18\u4e8b\u306e\u6700\u521d\u3042\u305f\u308a\u3067\u66f8\u3044\u305f\u3088\u3046\u306b\u5404\u30e6\u30fc\u30b6\u30fc\u306b<code>Deleting<\/code>\u30a4\u30d9\u30f3\u30c8\u3092\u3064\u3051\u3066\u304a\u3044\u3066\u3001\u5404\u30e6\u30fc\u30b6\u30fc\u304c\u524a\u9664\u3055\u308c\u308b\u76f4\u524d\u306b\u3059\u3079\u3066\u306e\u30c7\u30fc\u30bf\u3092\u524a\u9664\u3057\u3066\u3057\u307e\u3046\u3001\u3068\u3044\u3046\u6d41\u308c\u3067\u306f\u30c0\u30e1\u306a\u306e\u304b\u306a\u3068\u6700\u671f\u306b\u306a\u3063\u3066\u3082\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306f<code>Laravel<\/code>\u306b\u3082\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308a\u307e\u3059\u3057\u3001<code>ChatGPT<\/code>\u306b\u805e\u3044\u3066\u307f\u305f\u3089\u4e00\u756a\u6700\u521d\u306b\u8fd4\u3063\u3066\u304d\u305f\u7b54\u3048\u306f\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3057\u305f\u3002\uff08\u3057\u304b\u3082\u3001\u4eca\u56de\u306e\u5834\u5408\u3060\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u6d88\u3048\u3066\u3082\u76f8\u624b\u65b9\u306f\u904e\u53bb\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u898b\u3089\u308c\u308b\u3088\u3046\u306b\u3057\u305f\u65b9\u304c\u3044\u3044\u3068\u3082\u8a00\u3048\u3001\u3046\u30fc\u3093\u3068\u3044\u3063\u305f\u30ab\u30f3\u30b8\u3067\u3059\ud83e\udd14\uff09<\/p>\n<p>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u95a2\u9023\u3063\u3066\u3001\u3082\u3057\u65b0\u5165\u793e\u54e1\u304c\u3084\u3063\u3066\u305f\u3089\u6ce8\u610f\u3055\u308c\u3061\u3083\u3063\u305f\u308a\u3059\u308b\u3093\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u3068\u3001\u7b54\u3048\u306e\u51fa\u306a\u3044\u8003\u5bdf\u3067\u3057\u305f\u3002\uff08\u305c\u3072\u8a73\u3057\u3044\u65b9\u3044\u3044\u60c5\u5831\u304c\u3042\u308a\u307e\u3057\u305f\u3089\u3001\u6559\u3048\u3066\u304f\u3060\u3055\u3044m(_ _)m\uff09<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11002 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/09\/no_10.png\" alt=\"\" width=\"370\" height=\"290\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/09\/no_10.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2022\/09\/no_10-300x235.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/>\u300c\u697d\u5929\u3068\u304b\u306e\u6b32\u3057\u3044\u7269\u30ea\u30b9\u30c8\u3063\u3066\u3001<br \/>\n\u6c17\u304c\u3064\u3044\u305f\u3089\u5fd8\u308c\u3066\u3066\u3001<br \/>\n\u58f2\u308a\u5207\u308c\u306b\u306a\u3063\u3066\u307e\u305b\u3093\uff1f\uff1f\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u9593\u3053\u306e\u30d6\u30ed\u30b0\u3067\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u516c\u958b\u3057\u307e\u3057\u305f\u3002 \ud83d\udcdd \u53c2\u8003\u30da\u30fc\u30b8\uff1a\u00a0Laravel Breeze\uff1a Multi Auth \u3057\u306a\u304c\u3089\u30ed\u30b0\u30a4\u30f3\u30fb\u767b\u9332\u30fb\u30d1\u30b9\u30ef\u30fc &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=11900\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel Multi-Auth \u306a\u30e6\u30fc\u30b6\u30fc\u9593\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":11910,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-11900","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/11900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11900"}],"version-history":[{"count":3,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/11900\/revisions"}],"predecessor-version":[{"id":11909,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/11900\/revisions\/11909"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/11910"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}