tinker使用時の単数系と複数形に関して教えて下さい

どのように名前が決まるか、その仕組みを説明していきます。
2022年5月31日
ユーザー
./vendor/bin/sail tinker

を使用した時の複数形と単数系の使い分けに関しての質問です。

tinkerの中で$postのデータを取得して、紐づくコメントを表示させる際に、$post->comments;comments と複数形なっています。

>>> $post = App\Models\Post::find(1);
=> App\Models\Post {#4264
     id: 1,
     title: "title 1",
     body: "body 1",
     created_at: "2022-05-30 18:54:42",
     updated_at: "2022-05-30 18:54:42",
   }

>>> $post->comments;
=> Illuminate\Database\Eloquent\Collection {#4474
     all: [
       App\Models\Comment {#4476
         id: 1,
         post_id: 1,
         body: "comment 1",
         created_at: "2022-05-31 08:16:16",
         updated_at: "2022-05-31 08:16:16",
       },
       App\Models\Comment {#4263
         id: 2,
         post_id: 1,
         body: "comment 2",
         created_at: "2022-05-31 08:16:20",
         updated_at: "2022-05-31 08:16:20",
       },
     ],
   }

しかし、$comment を取得して、表示させる際は$comment->postpost は単数系になっている理由をお伺いしたいです。

>>> $comment = App\Models\Comment::find(1);
=> App\Models\Comment {#3866
     id: 1,
     post_id: 1,
     body: "comment 1",
     created_at: "2022-05-31 08:16:16",
     updated_at: "2022-05-31 08:16:16",
   }

>>> $comment->post;
=> App\Models\Post {#4476
     id: 1,
     title: "title 1",
     body: "body 1",
     created_at: "2022-05-30 18:54:42",
     updated_at: "2022-05-30 18:54:42",
   }

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?