{"id":46446,"date":"2023-11-26T02:15:47","date_gmt":"2023-11-25T17:15:47","guid":{"rendered":"https:\/\/kinsta.com\/jp\/?p=46446&#038;preview=true&#038;preview_id=46446"},"modified":"2023-11-30T17:49:32","modified_gmt":"2023-11-30T08:49:32","slug":"laravel-relationships","status":"publish","type":"post","link":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/","title":{"rendered":"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac"},"content":{"rendered":"<p>\u958b\u767a\u8005\u306f\u65e5\u3005\u306e\u696d\u52d9\u306e\u4e2d\u3067\u3057\u3070\u3057\u3070\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u306e\u901a\u4fe1\u3092\u6271\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u3093\u306a\u6642\u306b\u4fbf\u5229\u306a\u306e\u304c\u3001Laravel\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u95a2\u4fc2\uff08ORM\uff09\u30de\u30c3\u30d4\u30f3\u30b0\u3067\u3042\u308bEloquent\u3067\u3059\u3002\u3053\u308c\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u3068\u306e\u3084\u308a\u53d6\u308a\u304c\u76f4\u611f\u7684\u304b\u3064\u81ea\u7136\u306a\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u6271\u3046\u4e0a\u3067\u30016\u3064\u306e\u30bf\u30a4\u30d7\u306b\u3064\u3044\u3066\u7406\u89e3\u3092\u6df1\u3081\u3066\u304a\u304f\u3053\u3068\u304c\u6b20\u304b\u305b\u307e\u305b\u3093\u3002\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3067\u306f\u3001\u305d\u306e\u7a2e\u985e\u3092\u8a73\u3057\u304f\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div><\/div><kinsta-auto-toc heading=\"Table of Contents\" exclude=\"last\" list-style=\"arrow\" selector=\"h2\" count-number=\"-1\"><\/kinsta-auto-toc>\n<h2>Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3068\u306f<\/h2>\n<p>\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30b7\u30c3\u30d7\u3092\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u3068\u3057\u3066\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u6574\u7406\u30fb\u69cb\u9020\u5316\u3057\u3001\u512a\u308c\u305f\u53ef\u8aad\u6027\u3068\u30c7\u30fc\u30bf\u306e\u53d6\u308a\u6271\u3044\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306b\u306f\u3001\u5b9f\u969b\u306b\u306f3\u3064\u306e\u30bf\u30a4\u30d7\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>1\u5bfe1\u2500\u3042\u308b\u30c6\u30fc\u30d6\u30eb\u306e1\u3064\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u3001\u5225\u306e\u30c6\u30fc\u30d6\u30eb\u306e1\u3064\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u95a2\u9023\u4ed8\u3051\u3089\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u3042\u308b\u4eba\u7269\u3068\u793e\u4f1a\u4fdd\u969c\u756a\u53f7\u306a\u3069\u3067\u3059\u3002<\/li>\n<\/ul>\n<ul>\n<li>1\u5bfe\u591a\u25001\u3064\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u5225\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u8907\u6570\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u5bfe\u5fdc\u4ed8\u3051\u3089\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u30e9\u30a4\u30bf\u30fc\uff08\u57f7\u7b46\u8005\uff09\u3068\u8907\u6570\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u3059\u3002<\/li>\n<\/ul>\n<ul>\n<li>\u591a\u5bfe\u591a\u2500\u3042\u308b\u30c6\u30fc\u30d6\u30eb\u306e\u8907\u6570\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u3001\u5225\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u8907\u6570\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u95a2\u9023\u4ed8\u3051\u3089\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u5b66\u751f\u3068\u305d\u306e\u53d7\u8b1b\u30b3\u30fc\u30b9\u306a\u3069\u3067\u3059\u3002<\/li>\n<\/ul>\n<p>Laravel\u3067\u306f\u3001Eloquent\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u69cb\u6587\u3092\u4f7f\u7528\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3068\u306e\u901a\u4fe1\u3084\u7ba1\u7406\u3092\u30b7\u30fc\u30e0\u30ec\u30b9\u306b\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u57fa\u672c\u306b\u3042\u308f\u305b\u3066\u3001Laravel\u306b\u306f\u3055\u3089\u306a\u308b\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u5c0e\u5165\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u300chasManyThrough\u300d<\/li>\n<li>\u300cPolymorphic Relations\u300d<\/li>\n<li>\u300cMany-to-many Polymorphic\u300d<\/li>\n<\/ul>\n<p>\u4f8b\u3048\u3070\u3001\u5728\u5eab\u306b\u69d8\u3005\u306a\u5546\u54c1\u304c\u3042\u308a\u3001\u305d\u308c\u305e\u308c\u304c\u30ab\u30c6\u30b4\u30ea\u30fc\u306b\u5206\u3051\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u306a\u304a\u5e97\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u60c5\u5831\u6574\u7406\u306e\u89b3\u70b9\u304b\u3089\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u8907\u6570\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5206\u5272\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306a\u30b1\u30fc\u30b9\u3067\u3001\u4e00\u3064\u3072\u3068\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u30af\u30a8\u30ea\u3092\u304b\u3051\u308b\u306e\u306f\u8ce2\u3044\u3084\u308a\u65b9\u3068\u306f\u8a00\u3048\u307e\u305b\u3093\u3002<\/p>\n<p>Laravel\u3067\u306f\u3001\u5358\u7d14\u306a1\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u7c21\u5358\u306b\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u5546\u54c1\u3092\u30af\u30a8\u30ea\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u3001Product\u30e2\u30c7\u30eb\u3092\u4f7f\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<figure style=\"width: 1158px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kinsta.com\/wp-content\/uploads\/2023\/05\/pasted-image-0-6.png\" alt=\"\u591a\u76f8\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u8868\u3059\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30ad\u30fc\u30de\uff083\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u30681\u3064\u306e\u7d50\u5408\u30c6\u30fc\u30d6\u30eb\uff09\" width=\"1158\" height=\"610\"><figcaption class=\"wp-caption-text\">\u591a\u76f8\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u8868\u3059\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30ad\u30fc\u30de\uff083\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u30681\u3064\u306e\u7d50\u5408\u30c6\u30fc\u30d6\u30eb\uff09<\/figcaption><\/figure>\n<h2>1\u5bfe1\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>Laravel\u304c\u63d0\u4f9b\u3059\u308b\u6700\u521d\u306e\u57fa\u672c\u7684\u306a\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u3053\u3061\u3089\u3067\u3059\u30022\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308a\u307e\u3059\u30021\u3064\u76ee\u306e\u30c6\u30fc\u30d6\u30eb\u306e1\u884c\u304c\u3082\u30461\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u306e1\u884c\u3068\u76f8\u95a2\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u304c\u5b9f\u969b\u306b\u6a5f\u80fd\u3059\u308b\u3068\u3053\u308d\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u305d\u308c\u305e\u308c\u72ec\u81ea\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u6301\u30642\u3064\u306e\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"language-bash\">php artisan make:model Tenant \nPhp artisan make:model Rent<\/code><\/pre>\n<p>\u3053\u306e\u6642\u70b9\u3067\u30012\u3064\u306e\u30e2\u30c7\u30eb\u304c\u7528\u610f\u3067\u304d\u307e\u3057\u305f\u3002\u3072\u3068\u3064\u306f\u5c45\u4f4f\u8005\u3067\u3001\u3082\u3046\u3072\u3068\u3064\u306f\u5bb6\u8cc3\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Tenant extends Model\n{\n    \/**\n    * \u5c45\u4f4f\u8005\u306e\u5bb6\u8cc3\u3092\u53d6\u5f97\n    *\/\n    public function rent() \n    {\n        return $this-&gt;hasOne(Rent::class);\n    }\n}<\/code><\/pre>\n<p>Eloquent\u306f\u89aa\u30e2\u30c7\u30eb\u540d\uff08\u3053\u306e\u4f8b\u3067\u306fTenant\uff09\u306b\u57fa\u3065\u3044\u3066\u5916\u90e8\u30ad\u30fc\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u6c7a\u5b9a\u3059\u308b\u305f\u3081\u3001Rent\u30e2\u30c7\u30eb\u306f<strong>tenant_id<\/strong>\u5916\u90e8\u30ad\u30fc\u304c\u5b58\u5728\u3059\u308b\u3068\u4eee\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u5fc5\u8981\u3067\u3042\u308c\u3070\u3001\u3053\u308c\u3092<strong>hasOne<\/strong>\u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u7c21\u5358\u306b\u4e0a\u66f8\u304d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this- &gt;hasOne(Rent::class, \"custom_key\");<\/code><\/pre>\n<p>\u307e\u305f\u3001Eloquent\u306f\u5b9a\u7fa9\u3057\u305f\u5916\u90e8\u30ad\u30fc\u3068\u89aa\uff08Tenant\u30e2\u30c7\u30eb\uff09\u306e\u4e3b\u30ad\u30fc\u304c\u4e00\u81f4\u3059\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u3066\u3044\u307e\u3059\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001<strong>tenant_id<\/strong>\u3068Tenant\u30ec\u30b3\u30fc\u30c9\u306e<strong>id<\/strong>\u30ad\u30fc\u306e\u4e00\u81f4\u304c\u63a2\u3055\u308c\u307e\u3059\u3002<strong>hasOne<\/strong>\u30e1\u30bd\u30c3\u30c9\u306e3\u756a\u76ee\u306e\u5f15\u6570\u3067\u3053\u308c\u3092\u4e0a\u66f8\u304d\u3057\u3001\u5225\u306e\u30ad\u30fc\u306b\u30de\u30c3\u30c1\u3055\u305b\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;hasOne(Rent::class, \"custom_key\", \"other_key\"); <\/code><\/pre>\n<p>\u30e2\u30c7\u30eb\u9593\u306e1\u5bfe1\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9a\u7fa9\u3057\u305f\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">$rent = Tenant::find(10)-&gt;rent;<\/code><\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u3001\u5165\u5c45\u8005\u306e\u5bb6\u8cc3\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<h2>1\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>\u524d\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u3088\u3046\u306b\u3001\u3053\u3061\u3089\u306f\u5358\u4e00\u306e\u89aa\u30e2\u30c7\u30eb\u3068\u8907\u6570\u306e\u5b50\u30e2\u30c7\u30eb\u9593\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9a\u7fa9\u3059\u308b\u3082\u306e\u3067\u3059\u3002\u5bb6\u8cc3\u306f\u5b9a\u671f\u7684\u306a\u652f\u6255\u3044\u3067\u3042\u308b\u305f\u3081\u3001\u8acb\u6c42\u60c5\u5831\u304c1\u3064\u3060\u3051\u3068\u3044\u3046\u3053\u3068\u306f\u6050\u3089\u304f\u306a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u4ee5\u524d\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306b\u306f\u6b20\u70b9\u304c\u3042\u308a\u307e\u3059\u3002\u4fee\u6b63\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Tenant extends Model\n{\n    \/**\n    * \u5c45\u4f4f\u8005\u306e\u8cc3\u6599\u3092\u53d6\u5f97\n    *\/\n    public function rent() \n    {\n        return $this-&gt;hasMany(Rent::class);\n    }\n}<\/code><\/pre>\n<p>\u5bb6\u8cc3\u3092\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u524d\u306b\u77e5\u3063\u3066\u304a\u304f\u3079\u304d\u3053\u3068\u3068\u3057\u3066\u3001\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u30af\u30a8\u30ea\u30d3\u30eb\u30c0\u30fc\u306e\u5f79\u5272\u3092\u679c\u305f\u3059\u305f\u3081\u3001\u4ed6\u306b\u5236\u7d04\uff08\u7279\u5b9a\u306e\u671f\u9593\u306e\u5bb6\u8cc3\u3001\u6700\u4f4e\u652f\u6255\u984d\u306a\u3069\uff09\u3092\u8ffd\u52a0\u3057\u305d\u308c\u3089\u3092\u9023\u9396\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">$rents = Tenant::find(10)-&gt;rent()-&gt;where('payment', '&gt;', 500)-&gt;first();<\/code><\/pre>\n<p>\u307e\u305f\u3001\u5148\u307b\u3069\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u540c\u69d8\u3001\u8ffd\u52a0\u306e\u5f15\u6570\u3092\u6e21\u3059\u3053\u3068\u3067\u5916\u90e8\u30ad\u30fc\u3084\u30ed\u30fc\u30ab\u30eb\u30ad\u30fc\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;hasMany(Rent::class, \"foreign_key\");<\/code><\/pre>\n<pre><code class=\"language-php\">return $this-&gt;hasMany(Rent::class, \"foreign_key\", \"local_key\");<\/code><\/pre>\n<p>\u3053\u308c\u3067\u5bb6\u8cc3\u306f\u3059\u3079\u3066\u628a\u63e1\u3067\u304d\u307e\u3057\u305f\u3002\u305d\u308c\u3067\u306f\u3001\u5bb6\u8cc3\u304c\u5206\u304b\u3063\u3066\u3044\u3066\u305d\u308c\u304c\u8ab0\u306e\u3082\u306e\u304b\u3092\u77e5\u308a\u305f\u3044\u3068\u304d\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u304b\u3002<strong>belongsTo<\/strong>\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Rent extends Model\n{\n    \/**\n    * \u8cc3\u6599\u306b\u5bfe\u5fdc\u3059\u308b\u5c45\u4f4f\u8005\u3092\u8fd4\u3059\n    *\/\n    public function tenant() \n    {\n        return $this-&gt;belongsTo(Tenant::class);\n    }\n}<\/code><\/pre>\n<p>\u305d\u3057\u3066\u7c21\u5358\u306b\u5c45\u4f4f\u8005\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">$tenant = Rent::find(1)-&gt;tenant;<\/code><\/pre>\n<p><strong>belongsTo<\/strong>\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001\u5148\u307b\u3069\u3068\u540c\u3058\u3088\u3046\u306b\u5916\u90e8\u30ad\u30fc\u3068\u30ed\u30fc\u30ab\u30eb\u30ad\u30fc\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u300cHas-One-Of-Many\u300d\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>Tenant\u30e2\u30c7\u30eb\u306f\u591a\u304f\u306eRent\u30e2\u30c7\u30eb\u3068\u95a2\u9023\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u3001\u6700\u65b0\u307e\u305f\u306f\u6700\u3082\u53e4\u3044\u30e2\u30c7\u30eb\u3092\u7c21\u5358\u306b\u53d6\u5f97\u3067\u304d\u308b\u3068\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u884c\u3046\u4fbf\u5229\u306a\u65b9\u6cd5\u3068\u3057\u3066\u3001<strong>hasOne<\/strong>\u30e1\u30bd\u30c3\u30c9\u3068<strong>ofMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">public function latestRent() {\n    return $this-&gt;hasOne(Rent::class)-&gt;latestOfMany();\n}\n\npublic function oldestRent() {\n    return $this-&gt;hasOne(Rent::class)-&gt;oldestOfMany();\n}<\/code><\/pre>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u30bd\u30fc\u30c8\u53ef\u80fd\u306a\u4e3b\u30ad\u30fc\u306b\u57fa\u3065\u3044\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u304c\u3001<strong>ofMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u3067\u72ec\u81ea\u306e\u30d5\u30a3\u30eb\u30bf\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;hasOne(Rent::class)-&gt;ofMany('price', 'min');<\/code><\/pre>\n<h2>\u300cHasOneThrough\u300d\u3068\u300cHasManyThrough\u300d\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p><strong>Through<\/strong>\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u4ed6\u306e\u30e2\u30c7\u30eb\u3092\u7d4c\u7531\u3057\u3066\u3001\u76ee\u7684\u306e\u30e2\u30c7\u30eb\u3068\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u78ba\u7acb\u3059\u308b\u3053\u3068\u3092\u793a\u5506\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u5bb6\u8cc3\u3092\u5bb6\u4e3b\u306b\u95a2\u9023\u4ed8\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u5bb6\u8cc3\u304c\u5bb6\u4e3b\u306b\u5230\u9054\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u307e\u305a\u5c45\u4f4f\u8005\u3092\u7d4c\u7531\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u3044\u3063\u305f\u5177\u5408\u3067\u3059\u3002<\/p>\n<p>\u3053\u308c\u306b\u5fc5\u8981\u306a\u30c6\u30fc\u30d6\u30eb\u306e\u30ad\u30fc\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">rent\n    id - integer\n    name - string\n    value - double\n\ntenants\n    id - integer\n    name - string\n    rent_id - integer\n\nlandlord\n    id - integer\n    name - string\n    tenant_id - integer<\/code><\/pre>\n<p>\u30c6\u30fc\u30d6\u30eb\u306e\u69d8\u76f8\u3092\u8996\u899a\u5316\u3057\u305f\u5f8c\u3067\u3001\u30e2\u30c7\u30eb\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Rent extends Model\n{\n    \/**\n    * \u5bb6\u8cc3\u306b\u5bfe\u5fdc\u3057\u305f\u5bb6\u4e3b\u3092\u8fd4\u3059\n    *\/\n    public function rentLandlord() \n    {\n        return $this-&gt;hasOneThrough(Landlord::class, Tenant::class);\n    }\n}<\/code><\/pre>\n<p><strong>hasOneThrough<\/strong>\u30e1\u30bd\u30c3\u30c9\u306e\u7b2c\u4e00\u5f15\u6570\u306f\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u30e2\u30c7\u30eb\u3067\u3001\u7b2c\u4e8c\u5f15\u6570\u306f\u7d4c\u7531\u3059\u308b\u30e2\u30c7\u30eb\u3067\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u5148\u307b\u3069\u3068\u540c\u3058\u3088\u3046\u306b\u3001\u5916\u90e8\u30ad\u30fc\u3068\u30ed\u30fc\u30ab\u30eb\u30ad\u30fc\u3092\u4e0a\u66f8\u304d\u3057\u307e\u3059\u30022\u3064\u306e\u30e2\u30c7\u30eb\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u308c\u305e\u308c2\u3064\u305a\u3064\u4ee5\u4e0b\u306e\u9806\u756a\u3067\u4e0a\u66f8\u304d\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">public function rentLandlord() \n{\n    return $this-&gt;hasOneThrough(\n        Landlord::class,\n        Tenant::class,\n        \"rent_id\",    \/\/ Foreign key on the tenant table\n        \"tenant_id\",  \/\/ Foreign key on the landlord table\n        \"id\",         \/\/ Local key on the tenant class\n        \"id\"          \/\/ Local key on the tenant table\n    );\n}<\/code><\/pre>\n<p>\u540c\u69d8\u306b\u3001Laravel Eloquent\u306e\u300cHas Many Through\u300d\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u3092\u4ecb\u3057\u3066\u96e2\u308c\u305f\u30c6\u30fc\u30d6\u30eb\u306e\u30ec\u30b3\u30fc\u30c9\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3044\u5834\u5408\u306b\u4fbf\u5229\u3067\u3059\u3002\u4ee5\u4e0b\u306e3\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u304c\u3042\u308b\u4f8b\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<ul>\n<li>country<\/li>\n<li>users<\/li>\n<li>games<\/li>\n<\/ul>\n<p>\u305d\u308c\u305e\u308c\u306e\u56fd\uff08Country\uff09\u306b\u305f\u304f\u3055\u3093\u306e\u30e6\u30fc\u30b6\u30fc\uff08Users\uff09\u304c\u3044\u3066\u3001\u305d\u308c\u305e\u308c\u306e\u30e6\u30fc\u30b6\u30fc\uff08Users\uff09\u304c\u305f\u304f\u3055\u3093\u306e\u30b2\u30fc\u30e0\u3092\u6301\u3063\u3066\u3044\u308b\u3068\u3057\u307e\u3059\u3002\u3042\u308b\u56fd\uff08Country\uff09\u306b\u5c5e\u3059\u308b\u3059\u3079\u3066\u306e\u30b2\u30fc\u30e0\u3092User\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u53d6\u5f97\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u6b21\u306e\u3088\u3046\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">country\n    id - integer\n    name - string\n\nuser\n    id - integer\n    country_id - integer\n    name - string\n\ngames\n    id - integer\n    user_id - integer\n    title - string<\/code><\/pre>\n<p>\u6b21\u306b\u3001\u30c6\u30fc\u30d6\u30eb\u3054\u3068\u306bEloquent\u30e2\u30c7\u30eb\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Country extends Model\n{\n    protected $fillable = ['name'];\n\n    public function users()\n    {\n        return $this-&gt;hasMany(User::class);\n    }\n\n    public function games()\n    {\n        return $this-&gt;hasManyThrough(Games::class, User::class);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass User extends Model\n{\n    protected $fillable = [article_id, 'name'];\n\n    public function country()\n    {\n        return $this-&gt;belongsTo(Country::class);\n    }\n\n    public function posts()\n    {\n        return $this-&gt;hasMany(Post::class);\n    }\n}<\/code><\/pre>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Game extends Model\n{\n    protected $fillable = ['user_id', 'title'];\n\n    public function user()\n    {\n        return $this-&gt;belongsTo(User::class);\n    }\n}<\/code><\/pre>\n<p>\u300cHas Many Through\u300d\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092Country\u3068Game\u306e\u9593\u3067\uff08User\u30e2\u30c7\u30eb\u3092\u901a\u3058\u3066\uff09\u78ba\u7acb\u3057\u305f\u305f\u3081\u3001Country\u30e2\u30c7\u30eb\u306e<strong>games()<\/strong>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u3001\u3059\u3079\u3066\u306e\u30b2\u30fc\u30e0\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\n$country = Country::find(159);\n            \n\/\/ \u56fd\u306e\u3059\u3079\u3066\u306e\u30b2\u30fc\u30e0\u3092\u53d6\u5f97\u3059\u308b\n$games = $country-&gt;games;<\/code><\/pre>\n<h2>\u591a\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\u306f\u3088\u308a\u8907\u96d1\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u8907\u6570\u306e\u5f79\u5272\u3092\u6301\u3064\u5f93\u696d\u54e1\u3067\u3059\u3002\u540c\u3058\u5f79\u5272\u3092\u8907\u6570\u306e\u5f93\u696d\u54e1\u306b\u5272\u308a\u5f53\u3066\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u304c\u591a\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u57fa\u672c\u3067\u3059\u3002<\/p>\n<p>\u4e0a\u306e\u4f8b\u3092\u5b9f\u88c5\u3059\u308b\u306b\u306f\u3001<strong>employees<\/strong>\u30c6\u30fc\u30d6\u30eb\u3001<strong>roles<\/strong>\u30c6\u30fc\u30d6\u30eb\u3001<strong>role_employees<\/strong>\u30c6\u30fc\u30d6\u30eb\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">employees\n    id - integer\n    name - string\n\nroles \n    id - integer\n    name - string\n\nrole_employees\n    user_id - integer\n    role_id - integer<\/code><\/pre>\n<p>\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u3092\u77e5\u3063\u3066\u3044\u308c\u3070\u3001<strong>Employee<\/strong>\u30e2\u30c7\u30eb\u3092<strong>belongToMany Role<\/strong>\u30e2\u30c7\u30eb\u306b\u7c21\u5358\u306b\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Employee extends Model\n{\n    public function roles() \n    {\n        return $this- &gt;belongsToMany(Role::class);\n    }\n}<\/code><\/pre>\n<p>\u3053\u308c\u3092\u5b9a\u7fa9\u3059\u308b\u3068\u3001\u5f93\u696d\u54e1\u306e\u3059\u3079\u3066\u306e\u5f79\u5272\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u3001\u3055\u3089\u306b\u305d\u308c\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">$employee = Employee::find(1);\n$employee-&gt;roles-&gt;forEach(function($role) { \/\/ });\n\n\/\/ \u307e\u305f\u306f\n\n$employee = Employee::find(1)-&gt;roles()-&gt;orderBy('name')-&gt;where('name', 'admin')-&gt;get();<\/code><\/pre>\n<p>\u4ed6\u306e\u30e1\u30bd\u30c3\u30c9\u540c\u69d8\u3001<strong>belongsToMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u306e\u5916\u90e8\u30ad\u30fc\u3084\u30ed\u30fc\u30ab\u30eb\u30ad\u30fc\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>belongsToMany<\/strong>\u306e\u9006\u65b9\u5411\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9a\u7fa9\u3059\u308b\u306e\u306b\u3082\u540c\u3058\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3048\u307e\u3059\u304c\u3001\u4eca\u5ea6\u306f\u5b50\u30e1\u30bd\u30c3\u30c9\u306b\u89aa\u3092\u5f15\u6570\u3068\u3057\u3066\u4e0e\u3048\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Role extends Model\n{\n    public function employees() \n    {\n        return $this-&gt;belongsToMany(Employee::class);\n    }\n}<\/code><\/pre>\n<h3>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u4f7f\u7528<\/h3>\n<p>\u3059\u3067\u306b\u304a\u6c17\u3065\u304d\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u591a\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u5e38\u306b\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u3092\u6301\u3064\u3053\u3068\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u4f8b\u3067\u306f\u3001<strong>role_employees<\/strong>\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u30d4\u30dc\u30c3\u30c8\u30c6\u30fc\u30d6\u30eb\u306bid\u5c5e\u6027\u306e\u307f\u304c\u542b\u307e\u308c\u307e\u3059\u3002\u4ed6\u306e\u5c5e\u6027\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;belongsToMany(Employee::class)-&gt;withPivot(\"active\", \"created_at\");<\/code><\/pre>\n<p>\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u306b\u3064\u3044\u3066\u306e\u624b\u52d5\u3067\u306e\u51e6\u7406\u3092\u7701\u304f\u306b\u306f\u3001\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;belongsToMany(Employee::class)-&gt;withTimestamps();<\/code><\/pre>\n<p>1\u3064\u306e\u30b3\u30c4\u3068\u3057\u3066\u300cpivot\u300d\u3068\u3044\u3046\u540d\u524d\u306f\u3001\u597d\u307f\u306e\u3082\u306e\u306b\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;belongsToMany(Employee::class)-&gt;as('subscription')-&gt;withPivot(\"active\", \"created_by\");<\/code><\/pre>\n<p><a href=\"https:\/\/kinsta.com\/jp\/blog\/laravel-performance\/\">Laravel\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u6700\u9069\u5316<\/a>\u3057\u3001\u30b9\u30c6\u30c3\u30d7\u30a2\u30c3\u30d7\u3057\u305f\u3044\u958b\u767a\u8005\u306b\u3068\u3063\u3066\u3001Eloquent\u30af\u30a8\u30ea\u306e\u7d50\u679c\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3059\u308b\u3053\u3068\u306f\u5fc5\u9808\u306e\u77e5\u8b58\u3067\u3059\u3002<\/p>\n<p>Laravel\u306b\u306f\u3053\u308c\u3092\u652f\u3048\u308b\u7d20\u6674\u3089\u3057\u3044\u6a5f\u80fd\u304c\u3042\u308a\u3001\u53ce\u96c6\u3057\u305f\u3044\u30c7\u30fc\u30bf\u306e\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u306b\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<a href=\"https:\/\/kinsta.com\/jp\/blog\/laravel-database\/\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3<\/a>\u306e\u3088\u3046\u306a\u4ed6\u306e\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u584a\u3067\u53d6\u5f97\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001<strong>wherePivot<\/strong>\u3001<strong>wherePivotIn<\/strong>\u3001<strong>wherePivotNotIn<\/strong>\u3001<strong>wherePivotBetween<\/strong>\u3001<strong>wherePivotNotBetween<\/strong>\u3001<strong>wherePivotNull<\/strong>\u3001<strong>wherePivotNotNull<\/strong>\u306e\u3088\u3046\u306a\u4fbf\u5229\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u53ef\u80fd\u3067\u3059\u3002\u3053\u308c\u3089\u306f\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9a\u7fa9\u3059\u308b\u3068\u304d\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;belongsToMany(Employee::class)-&gt;wherePivot('promoted', 1);\nreturn $this-&gt;belongsToMany(Employee::class)-&gt;wherePivotIn('level', [1, 2]);\nreturn $this-&gt;belongsToMany(Employee::class)-&gt;wherePivotNotIn('level', [2, 3]);\nreturn $this-&gt;belongsToMany(Employee::class)-&gt;wherePivotBetween('posted_at', ['2023-01-01 00:00:00', '2023-01-02 00:00:00']);\nreturn $this-&gt;belongsToMany(Employee::class)-&gt;wherePivotNull('expired_at');\nreturn $this-&gt;belongsToMany(Employee::class)-&gt;wherePivotNotNull('posted_at');<\/code><\/pre>\n<p>\u6700\u5f8c\u306b\u3082\u3046\u3072\u3068\u3064\u3001\u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\u306e\u4e26\u3073\u9806\u304c\u9078\u3079\u308b\u3068\u3044\u3046\u7d20\u6674\u3089\u3057\u3044\u6a5f\u80fd\u3082\u6ce8\u76ee\u306b\u5024\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">return $this-&gt;belongsToMany(Employee::class)\n        -&gt;where('promoted', true)\n        -&gt;orderByPivot('hired_at', 'desc');<\/code><\/pre>\n<h2>\u300c\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u300d\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>\u300c\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u300d\u3068\u3044\u3046\u8a00\u8449\u306f\u30ae\u30ea\u30b7\u30e3\u8a9e\u306b\u7531\u6765\u3057\u3001\u300c\u591a\u5f62\u4f53\u300d\u3092\u610f\u5473\u3057\u307e\u3059\u30021\u3064\u306e\u30e2\u30c7\u30eb\u304c\u591a\u304f\u306e\u5f62\u3092\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3001\u3064\u307e\u308a\u8907\u6570\u306e\u95a2\u9023\u4ed8\u3051\u3092\u6301\u3064\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u30d6\u30ed\u30b0\u3001\u52d5\u753b\u3001\u6295\u7968\u306a\u3069\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u69cb\u7bc9\u3057\u3066\u3044\u308b\u3068\u3057\u307e\u3057\u3087\u3046\u3002\u30e6\u30fc\u30b6\u30fc\u306f\u3053\u308c\u3089\u306e\u3069\u308c\u306b\u5bfe\u3057\u3066\u3082\u30b3\u30e1\u30f3\u30c8\u3092\u6b8b\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001<strong>Comment<\/strong>\uff08\u30b3\u30e1\u30f3\u30c8\uff09\u30e2\u30c7\u30eb\u306f<strong>Blogs<\/strong>\uff08\u30d6\u30ed\u30b0\uff09\u3001<strong>Videos<\/strong>\uff08\u52d5\u753b\uff09\u3001<strong>Polls<\/strong>\uff08\u6295\u7968\uff09\u30e2\u30c7\u30eb\u306e\u3044\u305a\u308c\u306b\u3082\u5c5e\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u300c1\u5bfe1\u300d<\/h2>\n<p>\u3053\u306e\u30bf\u30a4\u30d7\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306f\u3001\u6a19\u6e96\u7684\u306a1\u5bfe1\u306e\u3082\u306e\u306b\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u552f\u4e00\u306e\u9055\u3044\u3068\u3057\u3066\u3001\u5b50\u30e2\u30c7\u30eb\u304c1\u3064\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u8907\u6570\u306e\u30bf\u30a4\u30d7\u306e\u30e2\u30c7\u30eb\u306b\u5c5e\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001<strong>Tenant<\/strong>\uff08\u5c45\u4f4f\u8005\uff09\u3068<strong>Landlord<\/strong>\uff08\u5927\u5bb6\uff09\u306e\u30e2\u30c7\u30eb\u3092\u4f8b\u306b\u3068\u308b\u3068\u3001<strong>WaterBill<\/strong>\uff08\u6c34\u9053\u4ee3\uff09\u30e2\u30c7\u30eb\u3068\u306e\u591a\u76f8\u95a2\u4fc2\u3092\u5171\u6709\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">tenants\n    id \u2013 integer\n    name \u2013 string\n\nlandlords\n    id \u2013 integer\n    name \u2013 string\n\nwaterbills\n    id \u2013 integer\n    amount \u2013 double\n    waterbillable_id\n    waterbillable_type<\/code><\/pre>\n<p><strong>landlord<\/strong>\u307e\u305f\u306f<strong>tenant<\/strong>\u306eid\u306b\u306fwaterbillable_id\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002waterbillable_type\u306b\u306f\u89aa\u30e2\u30c7\u30eb\u306e\u30af\u30e9\u30b9\u540d\u304c\u5165\u308a\u307e\u3059\u3002type\u30ab\u30e9\u30e0\u306fEloquent\u304c\u3069\u306e\u89aa\u30e2\u30c7\u30eb\u3092\u8fd4\u3059\u304b\u3092\u5224\u65ad\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u95a2\u4fc2\u306e\u30e2\u30c7\u30eb\u5b9a\u7fa9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass WaterBill extends Model\n{\n    public function billable()\n    {\n        return $this-&gt;morphTo();\n    }\n}\n\nclass Tenant extends Model\n{\n    public function waterBill()    \n    {\n        return $this-&gt;morphOne(WaterBill::class, 'billable');\n    }\n}\n\nclass Landlord extends Model\n{\n    public function waterBill()    \n    {\n        return $this-&gt;morphOne(WaterBill::class, 'billable');\n    }\n}<\/code><\/pre>\n<p>\u3053\u308c\u304c\u3059\u3079\u3066\u6574\u3048\u3070\u3001\u5bb6\u4e3b\uff08Landlord\uff09\u3068\u501f\u4e3b\uff08Tenant\uff09\u306e\u4e21\u65b9\u306e\u30e2\u30c7\u30eb\u304b\u3089\u30c7\u30fc\u30bf\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\n$tenant = Tenant::find(1)-&gt;waterBill;\n$landlord = Landlord::find(1)-&gt;waterBill;<\/code><\/pre>\n<h2>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u300c1\u5bfe\u591a\u300d<\/h2>\n<p>\u3053\u308c\u306f\u3001\u901a\u5e38\u306e1\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u552f\u4e00\u306e\u91cd\u8981\u306a\u9055\u3044\u3068\u3057\u3066\u3001\u5b50\u30e2\u30c7\u30eb\u304c1\u3064\u306e\u95a2\u9023\u6027\u3092\u4f7f\u7528\u3057\u3066\u3001\u8907\u6570\u306e\u30bf\u30a4\u30d7\u306e\u30e2\u30c7\u30eb\u306b\u5c5e\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Facebook\u306e\u3088\u3046\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u6295\u7a3f\u3001\u52d5\u753b\u3001\u6295\u7968\u3001\u30e9\u30a4\u30d6\u306a\u3069\u306b\u30b3\u30e1\u30f3\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306a1\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u7528\u3059\u308b\u3068\u30011\u3064\u306e\u30b3\u30e1\u30f3\u30c8\uff08<strong>comments<\/strong>\uff09\u30c6\u30fc\u30d6\u30eb\u3092\u4f7f\u7528\u3057\u3066\u3001\u3059\u3079\u3066\u306e\u30ab\u30c6\u30b4\u30ea\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u4fdd\u5b58\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">posts \n    id \u2013 integer\n    title \u2013 string\n    body \u2013 text\n\nvideos\n    id \u2013 integer\n    title \u2013 string\n    url \u2013 string\n\npolls\n    id \u2013 integer\n    title \u2013 string\n\ncomments \n    id \u2013 integer\n    body \u2013 text\n    commentable_id \u2013 integer\n    commentable_type \u2013 string<\/code><\/pre>\n<p>commentable_id\u306f\u30ec\u30b3\u30fc\u30c9\u306eID\u3067\u3001commentable_type\u306f\u30af\u30e9\u30b9\u306e\u30bf\u30a4\u30d7\u3067\u3001Eloquent\u3067\u4f55\u3092\u63a2\u3059\u3079\u304d\u304b\u304c\u660e\u3089\u304b\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u30e2\u30c7\u30eb\u306e\u69cb\u9020\u3068\u3057\u3066\u306f\u3001\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u4e00\u5bfe\u591a\u3068\u975e\u5e38\u306b\u3088\u304f\u4f3c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Comment extends Model \n{\n    public function commentable()\n    {\n        return $this-&gt;morphTo();\n    }\n}\n\nclass Poll extends Model\n{\n    public function comments()\n    {\n        return $this-&gt;morphMany(Comment::class, 'commentable');\n    }\n}\n\nclass Live extends Model\n{\n    public function comments()\n    {\n        return $this-&gt;morphMany(Comments::class, 'commentable');\n    }\n}<\/code><\/pre>\n<p>\u3053\u308c\u3067\u3001Live\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u3001id\u3092\u6307\u5b9a\u3057\u3066find\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3060\u3051\u3067\u3001comments iterable\u30af\u30e9\u30b9\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nuse App\\Models\\Live;\n\n$live = Live::find(1);\n\nforeach ($live-&gt;comments as $comment) { }\n\n\/\/ \u307e\u305f\u306f\n\nLive::find(1)-&gt;comments()-&gt;each(function($comment) { \/\/ });\nLive::find(1)-&gt;comments()-&gt;map(function($comment) { \/\/ });\nLive::find(1)-&gt;comments()-&gt;filter(function($comment) { \/\/ });\n\n\/\/ etc.<\/code><\/pre>\n<p>\u305d\u3057\u3066\u3001\u30b3\u30e1\u30f3\u30c8\u304c\u8ab0\u306e\u3082\u306e\u304b\u77e5\u308a\u305f\u3044\u5834\u5408\u306b\u306f\u3001commentable\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nuse App\\Models\\Comment;\n\n$comment = Comment::find(10);\n$commentable = $comment-&gt;commentable;\n\n\/\/ commentable \u2013 type of Post, Video, Poll, Live<\/code><\/pre>\n<h2>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u300cOne of Many\u300d<\/h2>\n<p>\u30b9\u30b1\u30fc\u30eb\u3092\u610f\u8b58\u3057\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u3001\u5404\u30e2\u30c7\u30eb\u9593\u3067\u306e\u901a\u4fe1\u3092\u7c21\u5358\u306b\u3059\u308b\u624b\u6cd5\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u6700\u521d\u306e\u6295\u7a3f\u3084\u6700\u5f8c\u306e\u6295\u7a3f\u3092\u53d6\u5f97\u3057\u305f\u3044\u3068\u3057\u307e\u3059\u3002\u3053\u308c\u306f<strong>morphOne<\/strong>\u30e1\u30bd\u30c3\u30c9\u3068<strong>ofMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\npublic function latestPost()\n{\n    return $this-&gt;morphOne(Post::class, 'postable')-&gt;latestOfMany();\n}\n\npublic function oldestPost()\n{\n    return $this-&gt;morphOne(Post::class, 'postable')-&gt;oldestOfMany();\n}<\/code><\/pre>\n<p>\u4e3b\u30ad\u30fc\u304c\u30bd\u30fc\u30c8\u53ef\u80fd\u3067\u3042\u308b\u3068\u3044\u3046\u524d\u63d0\u306e\u3082\u3068\u3067\u3001<strong>latestOfMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u3068<strong>oldestOfMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u304c\u3001\u30e2\u30c7\u30eb\u306e\u4e3b\u30ad\u30fc\u306b\u57fa\u3065\u3044\u3066\u6700\u3082\u65b0\u3057\u3044\u307e\u305f\u306f\u6700\u3082\u53e4\u3044\u30e2\u30c7\u30eb\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u3001ID\u3067\u306e\u30bd\u30fc\u30c8\u3092\u907f\u3051\u305f\u3044\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\u6295\u7a3f\u306e\u516c\u958b\u65e5\u3092\u5909\u66f4\u3057\u305f\u30b1\u30fc\u30b9\u306a\u3069\u3067\u3059\u3002\u305d\u3093\u306a\u6642\u306b\u306f\u3001ID\u306e\u9806\u3067\u306f\u306a\u304f\u516c\u958b\u65e5\u306b\u306a\u3089\u3063\u3066\u4e26\u3079\u66ff\u3048\u3092\u884c\u3046\u306e\u304c\u3044\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3053\u308c\u3092\u884c\u3046\u306b\u306f\u3001<strong>ofMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u306b2\u3064\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6e21\u3057\u307e\u3059\u3002\u6700\u521d\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u30d5\u30a3\u30eb\u30bf\u3092\u304b\u3051\u305f\u3044<strong>\u30ad\u30fc<\/strong>\u3067\u30012\u756a\u76ee\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f<strong>\u30bd\u30fc\u30c8\u306e\u65b9\u6cd5<\/strong>\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\npublic function latestPublishedPost()\n{\n    return $this-&gt;morphOne(Post::class, \"postable\")-&gt;ofMany(\"published_at\", \"max\");\n}<\/code><\/pre>\n<p>\u3053\u308c\u3092\u5ff5\u982d\u306b\u7f6e\u3044\u3066\u3001\u3088\u308a\u9ad8\u5ea6\u306a\u69cb\u9020\u3092\u69cb\u7bc9\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u4f8b\u3048\u3070\u3001\u3053\u3093\u306a\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002\u6295\u7a3f\u306e\u4e00\u89a7\u3092\u516c\u958b\u9806\u306b\u751f\u6210\u3059\u308b\u3088\u3046\u4f9d\u983c\u3055\u308c\u307e\u3057\u305f\u3002\u3053\u3053\u3067\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u540c\u3058published_at\u306e\u5024\u3092\u6301\u3064\u6295\u7a3f\u304c2\u3064\u3042\u308b\u5834\u5408\u3084\u3001\u7279\u5b9a\u306e\u6295\u7a3f\u306e\u516c\u958b\u304c\u4e88\u5b9a\u3055\u308c\u3066\u3044\u308b\uff08\u3064\u307e\u308a\u307e\u3060\u516c\u958b\u3055\u308c\u3066\u3044\u306a\u3044\uff09\u5834\u5408\u306f\u3069\u3046\u3059\u3079\u304d\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u3053\u308c\u3092\u884c\u3046\u306b\u306f\u3001\u30d5\u30a3\u30eb\u30bf\u3092\u9069\u7528\u3059\u308b\u9806\u756a\u3092<strong>ofMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3057\u307e\u3059\u3002\u3053\u306e\u65b9\u6cd5\u3067\u306f\u3001published_at\u3067\u4e26\u3073\u66ff\u3048\u3001\u540c\u3058\u5834\u5408\u306fid\u3067\u4e26\u3073\u66ff\u3048\u307e\u3059\u3002\u6b21\u306b\u3001<strong>ofMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u306b\u30af\u30a8\u30ea\u95a2\u6570\u3092\u9069\u7528\u3057\u3066\u3001\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u8abf\u6574\u4e2d\u306e\u6295\u7a3f\u3092\u3059\u3079\u3066\u9664\u5916\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\npublic function currentPosts()\n{\n    return $this-&gt;hasOne(Post::class)-&gt;ofMany([\n        'published_at' =&gt; 'max',\n        'id' =&gt; 'max',\n    ], function ($query) {\n        $query-&gt;where('published_at', '&lt;', now());\n    });\n}<\/code><\/pre>\n<h2>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u300cMany To Many\u300d<\/h2>\n<p>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u591a\u5bfe\u591a\u306f\u3001\u901a\u5e38\u306e\u3082\u306e\u3088\u308a\u5c11\u3057\u8907\u96d1\u3067\u3059\u3002\u30bf\u30b0\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u306e\u591a\u304f\u306e\u30a2\u30bb\u30c3\u30c8\u306b\u9069\u7528\u3055\u308c\u308b\u3053\u3068\u304c\u591a\u3005\u3042\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001TikTok\u3067\u306f\u3001\u52d5\u753b\u3084\u30b9\u30c8\u30fc\u30ea\u30fc\u306b\u30bf\u30b0\u3092\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u306e\u591a\u5bfe\u591a\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u52d5\u753b\u3084\u30b9\u30c8\u30fc\u30ea\u30fc\u306b\u95a2\u9023\u3059\u308b\u30bf\u30b0\u30921\u3064\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u307e\u3068\u3081\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u306e\u69cb\u9020\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre><code class=\"language-bash\">videos\n    id \u2013 integer\n    description \u2013 string\n\nstories \n    id \u2013 integer\n    description \u2013 string\n\ntaggables \n    tag_id \u2013 integer\n    taggable_id \u2013 integer\n    taggable_type \u2013 string<\/code><\/pre>\n<p>\u30c6\u30fc\u30d6\u30eb\u306e\u6e96\u5099\u304c\u3067\u304d\u305f\u3089\u3001\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u3066<strong>morphToMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u540d\u3068\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u540d\u3092\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Video extends Model\n{\n    public function tags()\n    {\n        return $this-&gt;morphToMany(Tag::class, 'taggable');\n    }\n}<\/code><\/pre>\n<p>\u305d\u3057\u3066\u3001\u3053\u308c\u306b\u3088\u3063\u3066\u3001\u9006\u306e\u95a2\u4fc2\u3092\u7c21\u5358\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3059\u3079\u3066\u306e\u5b50\u30e2\u30c7\u30eb\u306b\u5bfe\u3057\u3066\u3001<strong>morphedByMany<\/strong>\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nnamespace App\\Models;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Tag extends Model\n{\n    public function stories()\n    {\n        return $this-&gt;morphedByMany(Story::class, 'taggable');\n    }\n\n    public function videos()\n    {\n        return $this-&gt;morphedByMany(Video::class, 'taggable');\n    } \n}<\/code><\/pre>\n<p>\u305d\u3057\u3066\u3001\u30bf\u30b0\u3092\u53d6\u5f97\u3059\u308b\u3068\u3001\u305d\u306e\u30bf\u30b0\u306b\u95a2\u9023\u3059\u308b\u3059\u3079\u3066\u306e\u52d5\u753b\u3084\u30b9\u30c8\u30fc\u30ea\u30fc\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\nuse App\\Model\\Tag;\n\n$tag = Tag::find(10);\n$posts = $tag-&gt;stories;\n$videos = $tag-&gt;stories;<\/code><\/pre>\n<h2>Eloquent\u306e\u30b9\u30d4\u30fc\u30c9\u6700\u9069\u5316<\/h2>\n<p>Laravel\u306eEloquent ORM\u3092\u4f7f\u7528\u3059\u308b\u969b\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30af\u30a8\u30ea\u3092\u6700\u9069\u5316\u3059\u308b\u65b9\u6cd5\u3092\u7406\u89e3\u3057\u3001\u30c7\u30fc\u30bf\u3092\u30d5\u30a7\u30c3\u30c1\u3059\u308b\u306e\u306b\u5fc5\u8981\u306a\u6642\u9593\u3068\u30e1\u30e2\u30ea\u3092\u6700\u5c0f\u9650\u306b\u6291\u3048\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002\u3053\u308c\u3092\u884c\u30461\u3064\u306e\u65b9\u6cd5\u3068\u3057\u3066\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b<a href=\"https:\/\/kinsta.com\/blog\/laravel-caching\/\">\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u5b9f\u88c5<\/a>\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Laravel\u3067\u306f\u3001<a href=\"https:\/\/redis.io\/\">Redis<\/a>\u3001<a href=\"https:\/\/memcached.org\/\">Memcached<\/a>\u3001<a href=\"https:\/\/www.ibm.com\/docs\/en\/zvm\/7.1?topic=reference-file-caching\">\u30d5\u30a1\u30a4\u30eb\u30d9\u30fc\u30b9\u306e\u30ad\u30e3\u30c3\u30b7\u30e5<\/a>\u306a\u3069\u3001\u69d8\u3005\u306a\u30d0\u30c3\u30af\u30a8\u30f3\u30c9\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b\u67d4\u8edf\u306a\u30ad\u30e3\u30c3\u30b7\u30e5\u30b7\u30b9\u30c6\u30e0\u304c\u5229\u7528\u53ef\u80fd\u3067\u3059\u3002Eloquent\u306e\u30af\u30a8\u30ea\u7d50\u679c\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30af\u30a8\u30ea\u306e\u56de\u6570\u3092\u6e1b\u3089\u3057\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u3088\u308a\u9ad8\u901f\u3067\u4fa1\u5024\u3042\u308b\u3082\u306e\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001Laravel\u306e<a href=\"https:\/\/laravel.com\/docs\/10.x\/queries\">\u30af\u30a8\u30ea\u30d3\u30eb\u30c0\u30fc<\/a>\u3092\u4f7f\u7528\u3057\u3066\u3001\u3088\u308a\u8907\u96d1\u306a\u30af\u30a8\u30ea\u3092\u4f5c\u6210\u3057\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u4e00\u5c64\u6700\u9069\u5316\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u7d50\u8ad6\u3068\u3057\u3066\u3001Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306fLaravel\u306e\u4fbf\u5229\u306a\u6a5f\u80fd\u3067\u3001\u958b\u767a\u8005\u306f\u3053\u308c\u3092\u4f7f\u3046\u3053\u3068\u3067\u95a2\u9023\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4e00\u5bfe\u4e00\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u591a\u5bfe\u591a\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u307e\u3067\u3001Eloquent\u306b\u306f\u3053\u308c\u3089\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9a\u7fa9\u3057\u30af\u30a8\u30ea\u3059\u308b\u305f\u3081\u306e\u30b7\u30f3\u30d7\u30eb\u304b\u3064\u76f4\u611f\u7684\u306a\u69cb\u6587\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Laravel\u958b\u767a\u8005\u306b\u3068\u3063\u3066\u3001Eloquent\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u30de\u30b9\u30bf\u30fc\u306f\u5fc5\u9808\u3067\u3059\u3002\u958b\u767a\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u3092\u5927\u5e45\u306b\u5f37\u5316\u3057\u3001\u30b3\u30fc\u30c9\u3092\u3088\u308a\u52b9\u7387\u7684\u3067\u8aad\u307f\u3084\u3059\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002Kinsta\u3067\u306f\u3001Laravel\u3092\u4f7f\u3044\u3053\u306a\u3059\u305f\u3081\u306e<a href=\"https:\/\/kinsta.com\/blog\/laravel-tutorial\/\">\u89e3\u8aac<\/a>\u3084<a href=\"https:\/\/kinsta.com\/blog\/laravel-developer-salary\/\">Laravel\u958b\u767a\u8005\u306e\u7d66\u4e0e\u306b\u95a2\u3059\u308b\u8a18\u4e8b<\/a>\u306a\u3069\u3001\u69d8\u3005\u306a\u30ea\u30bd\u30fc\u30b9\u3092\u3054\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/sevalla.com\/application-hosting\/\">Laravel\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30c7\u30d7\u30ed\u30a4\u3068\u7ba1\u7406<\/a>\u3092\u5bb9\u6613\u306b\u3059\u308b\u30b5\u30fc\u30d0\u30fc\u3082\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u958b\u767a\u8005\u306f\u65e5\u3005\u306e\u696d\u52d9\u306e\u4e2d\u3067\u3057\u3070\u3057\u3070\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u306e\u901a &#8230;<\/p>\n","protected":false},"author":267,"featured_media":46447,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kinsta_gated_content":false,"_kinsta_gated_content_redirect":"","footnotes":""},"tags":[],"topic":[784,818],"class_list":["post-46446","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","topic-laravel","topic-web-development-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.6 (Yoast SEO v24.6) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\uff5cKinsta\u00ae<\/title>\n<meta name=\"description\" content=\"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\" \/>\n<meta property=\"og:description\" content=\"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\" \/>\n<meta property=\"og:site_name\" content=\"Kinsta\u00ae\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Kinsta-Japan-334616080691171\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-25T17:15:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-30T08:49:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1460\" \/>\n\t<meta property=\"og:image:height\" content=\"730\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Coman Cosmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:description\" content=\"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@Kinsta_JP\" \/>\n<meta name=\"twitter:site\" content=\"@Kinsta_JP\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Coman Cosmin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"6\u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\"},\"author\":{\"name\":\"Coman Cosmin\",\"@id\":\"https:\/\/kinsta.com\/jp\/#\/schema\/person\/aa307e51da3929c7aead1f4b4439f3da\"},\"headline\":\"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\",\"datePublished\":\"2023-11-25T17:15:47+00:00\",\"dateModified\":\"2023-11-30T08:49:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\"},\"wordCount\":169,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kinsta.com\/jp\/#organization\"},\"image\":{\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg\",\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\",\"url\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\",\"name\":\"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\uff5cKinsta\u00ae\",\"isPartOf\":{\"@id\":\"https:\/\/kinsta.com\/jp\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg\",\"datePublished\":\"2023-11-25T17:15:47+00:00\",\"dateModified\":\"2023-11-30T08:49:32+00:00\",\"description\":\"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage\",\"url\":\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg\",\"contentUrl\":\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg\",\"width\":1460,\"height\":730},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kinsta.com\/jp\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Laravel\",\"item\":\"https:\/\/kinsta.com\/jp\/topics\/laravel\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kinsta.com\/jp\/#website\",\"url\":\"https:\/\/kinsta.com\/jp\/\",\"name\":\"Kinsta\u00ae\",\"description\":\"\u9ad8\u901f\u304b\u3064\u5805\u7262\u306a\u30d7\u30ec\u30df\u30a2\u30e0\u30b5\u30fc\u30d0\u30fc\u30b5\u30fc\u30d3\u30b9\",\"publisher\":{\"@id\":\"https:\/\/kinsta.com\/jp\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kinsta.com\/jp\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kinsta.com\/jp\/#organization\",\"name\":\"Kinsta\",\"url\":\"https:\/\/kinsta.com\/jp\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/kinsta.com\/jp\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/12\/kinsta-logo.jpeg\",\"contentUrl\":\"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/12\/kinsta-logo.jpeg\",\"width\":500,\"height\":500,\"caption\":\"Kinsta\"},\"image\":{\"@id\":\"https:\/\/kinsta.com\/jp\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Kinsta-Japan-334616080691171\/\",\"https:\/\/x.com\/Kinsta_JP\",\"https:\/\/www.instagram.com\/kinstahosting\/\",\"https:\/\/www.linkedin.com\/company\/kinsta\/\",\"https:\/\/www.pinterest.com\/kinstahosting\/\",\"https:\/\/www.youtube.com\/c\/Kinsta\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/kinsta.com\/jp\/#\/schema\/person\/aa307e51da3929c7aead1f4b4439f3da\",\"name\":\"Coman Cosmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/kinsta.com\/jp\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ede71ae86b38c64bcf00417fd17a686b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ede71ae86b38c64bcf00417fd17a686b?s=96&d=mm&r=g\",\"caption\":\"Coman Cosmin\"},\"description\":\"Cosmin Coman is a technology writer and developer with over 3 years of experience. Apart from writing for Kinsta, he has assisted in research at nuclear physics facilities and universities. Tech-savvy and integrated into the community, he always comes up with innovative solutions.\",\"url\":\"https:\/\/kinsta.com\/jp\/blog\/author\/comancosmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\uff5cKinsta\u00ae","description":"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/","og_locale":"ja_JP","og_type":"article","og_title":"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac","og_description":"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002","og_url":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/","og_site_name":"Kinsta\u00ae","article_publisher":"https:\/\/www.facebook.com\/Kinsta-Japan-334616080691171\/","article_published_time":"2023-11-25T17:15:47+00:00","article_modified_time":"2023-11-30T08:49:32+00:00","og_image":[{"width":1460,"height":730,"url":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg","type":"image\/jpeg"}],"author":"Coman Cosmin","twitter_card":"summary_large_image","twitter_description":"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002","twitter_image":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg","twitter_creator":"@Kinsta_JP","twitter_site":"@Kinsta_JP","twitter_misc":{"\u57f7\u7b46\u8005":"Coman Cosmin","\u63a8\u5b9a\u8aad\u307f\u53d6\u308a\u6642\u9593":"6\u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#article","isPartOf":{"@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/"},"author":{"name":"Coman Cosmin","@id":"https:\/\/kinsta.com\/jp\/#\/schema\/person\/aa307e51da3929c7aead1f4b4439f3da"},"headline":"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac","datePublished":"2023-11-25T17:15:47+00:00","dateModified":"2023-11-30T08:49:32+00:00","mainEntityOfPage":{"@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/"},"wordCount":169,"commentCount":0,"publisher":{"@id":"https:\/\/kinsta.com\/jp\/#organization"},"image":{"@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage"},"thumbnailUrl":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg","inLanguage":"ja","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/","url":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/","name":"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac\uff5cKinsta\u00ae","isPartOf":{"@id":"https:\/\/kinsta.com\/jp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage"},"image":{"@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage"},"thumbnailUrl":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg","datePublished":"2023-11-25T17:15:47+00:00","dateModified":"2023-11-30T08:49:32+00:00","description":"Laravel\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30ca\u30eb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u6271\u3046\u969b\u306b\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u63a5\u7d9a\u306e\u3057\u304b\u305f\u3068\u3057\u3066\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u67d4\u8edf\u306b\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002","breadcrumb":{"@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#primaryimage","url":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg","contentUrl":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/06\/laravel-relationships.jpg","width":1460,"height":730},{"@type":"BreadcrumbList","@id":"https:\/\/kinsta.com\/jp\/blog\/laravel-relationships\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kinsta.com\/jp\/"},{"@type":"ListItem","position":2,"name":"Laravel","item":"https:\/\/kinsta.com\/jp\/topics\/laravel\/"},{"@type":"ListItem","position":3,"name":"Laravel Eloquent\u306e\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u5fb9\u5e95\u89e3\u8aac"}]},{"@type":"WebSite","@id":"https:\/\/kinsta.com\/jp\/#website","url":"https:\/\/kinsta.com\/jp\/","name":"Kinsta\u00ae","description":"\u9ad8\u901f\u304b\u3064\u5805\u7262\u306a\u30d7\u30ec\u30df\u30a2\u30e0\u30b5\u30fc\u30d0\u30fc\u30b5\u30fc\u30d3\u30b9","publisher":{"@id":"https:\/\/kinsta.com\/jp\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kinsta.com\/jp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":"Organization","@id":"https:\/\/kinsta.com\/jp\/#organization","name":"Kinsta","url":"https:\/\/kinsta.com\/jp\/","logo":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/kinsta.com\/jp\/#\/schema\/logo\/image\/","url":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/12\/kinsta-logo.jpeg","contentUrl":"https:\/\/kinsta.com\/jp\/wp-content\/uploads\/sites\/6\/2023\/12\/kinsta-logo.jpeg","width":500,"height":500,"caption":"Kinsta"},"image":{"@id":"https:\/\/kinsta.com\/jp\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Kinsta-Japan-334616080691171\/","https:\/\/x.com\/Kinsta_JP","https:\/\/www.instagram.com\/kinstahosting\/","https:\/\/www.linkedin.com\/company\/kinsta\/","https:\/\/www.pinterest.com\/kinstahosting\/","https:\/\/www.youtube.com\/c\/Kinsta"]},{"@type":"Person","@id":"https:\/\/kinsta.com\/jp\/#\/schema\/person\/aa307e51da3929c7aead1f4b4439f3da","name":"Coman Cosmin","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/kinsta.com\/jp\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ede71ae86b38c64bcf00417fd17a686b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ede71ae86b38c64bcf00417fd17a686b?s=96&d=mm&r=g","caption":"Coman Cosmin"},"description":"Cosmin Coman is a technology writer and developer with over 3 years of experience. Apart from writing for Kinsta, he has assisted in research at nuclear physics facilities and universities. Tech-savvy and integrated into the community, he always comes up with innovative solutions.","url":"https:\/\/kinsta.com\/jp\/blog\/author\/comancosmin\/"}]}},"acf":[],"_links":{"self":[{"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/posts\/46446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/users\/267"}],"replies":[{"embeddable":true,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/comments?post=46446"}],"version-history":[{"count":15,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/posts\/46446\/revisions"}],"predecessor-version":[{"id":52790,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/posts\/46446\/revisions\/52790"}],"alternate":[{"embeddable":true,"hreflang":"en","title":"English","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/en"},{"embeddable":true,"hreflang":"it","title":"Italian","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/it"},{"embeddable":true,"hreflang":"pt","title":"Portuguese","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/pt"},{"embeddable":true,"hreflang":"fr","title":"French","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/fr"},{"embeddable":true,"hreflang":"de","title":"German","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/de"},{"embeddable":true,"hreflang":"ja","title":"Japanese","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/jp"},{"embeddable":true,"hreflang":"es","title":"Spanish","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/es"},{"embeddable":true,"hreflang":"nl","title":"Dutch","href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/translations\/nl"},{"href":"https:\/\/kinsta.com\/jp\/wp-json\/kinsta\/v1\/posts\/46446\/tree"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/media\/46447"}],"wp:attachment":[{"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/media?parent=46446"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/tags?post=46446"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/kinsta.com\/jp\/wp-json\/wp\/v2\/topic?post=46446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}