{"id":991,"date":"2017-11-13T15:00:04","date_gmt":"2017-11-13T06:00:04","guid":{"rendered":"https:\/\/akamist.com\/blog\/?p=991"},"modified":"2017-10-31T11:23:06","modified_gmt":"2017-10-31T02:23:06","slug":"phpeloquent%e3%82%92%e5%8d%98%e4%bd%93%e3%81%a7%e4%bd%bf%e3%81%86%e3%81%a8%e3%81%8d%e3%80%81%e6%97%a5%e4%bb%98%e3%81%ab%e9%96%a2%e3%81%99%e3%82%8b%e5%88%97%e5%ae%9a%e7%be%a9%e3%81%ae%e5%91%bd","status":"publish","type":"post","link":"https:\/\/akamist.com\/blog\/archives\/991","title":{"rendered":"[PHP]Eloquent\u3067\u65e5\u4ed8\u306b\u95a2\u3059\u308b\u5217\u5b9a\u7fa9\u306e\u547d\u540d\u898f\u5247"},"content":{"rendered":"<p>PHP\u306eOR\u30de\u30c3\u30d1\u30fc\u3067\u3042\u308bEloquent\u3067\u306f\u3001\u30c7\u30fc\u30bf\u306e\u767b\u9332\u6642\u523b\u30fb\u66f4\u65b0\u6642\u523b\u3068\u3001\u30c7\u30fc\u30bf\u306e\u8ad6\u7406\u524a\u9664(SoftDelete)\u3092\u884c\u3046\u3068\u304d\u306e\u524a\u9664\u6642\u523b\u3092\u81ea\u52d5\u3067\u66f4\u65b0\u3057\u3066\u304f\u308c\u308b\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u3053\u308c\u3089\u306e\u6a5f\u80fd\u3092\u6700\u5c0f\u306e\u624b\u9593\u3067(=Eloquent\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u8a2d\u5b9a\u3067)\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u547d\u540d\u898f\u5247\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>Laravel\u3092\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3092\u4f7f\u3048\u3070\u898f\u7d04\u306b\u6cbf\u3063\u305f\u5f62\u3067\u30c6\u30fc\u30d6\u30eb\u5b9a\u7fa9\u3092\u884c\u3063\u3066\u304f\u308c\u308b\u306e\u3067\u3042\u307e\u308a\u610f\u8b58\u3057\u306a\u304f\u3066\u826f\u3044\u3067\u3059\u304c\u3001Laravel\u4ee5\u5916\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u3063\u3066\u3001OR\u30de\u30c3\u30d1\u30fc\u3068\u3057\u3066Eloquent\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3060\u3051\u3092\u4f7f\u3046\u3068\u304d\u306b\u53c2\u8003\u306b\u3059\u308b\u3068\u3088\u3044\u3067\u3059\u3002<\/p>\n<h2>Eloquent\u306e\u65e5\u4ed8\u7ba1\u7406\u5217<\/h2>\n<p>\u7d50\u8ad6\u3092\u5148\u306b\u66f8\u304f\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3059\u308c\u3070\u3088\u3044\u3067\u3059\u3002deleted_at\u3001created_at\u3001updated_at\u5217\u3092timestamp\u578b\u3067\u4f5c\u3063\u3066\u304a\u304d\u307e\u3059\u3002deleted_at\u5217\u306b\u95a2\u3057\u3066\u306fSoftDelete\u6a5f\u80fd\u3092\u5229\u7528\u3059\u308b\u6642\u306e\u307f\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sql\">CREATE TABLE posts (\n  id int(10) unsigned NOT NULL AUTO_INCREMENT,\n  deleted_at timestamp NULL DEFAULT NULL,\n  created_at timestamp NULL DEFAULT NULL,\n  updated_at timestamp NULL DEFAULT NULL,\n  PRIMARY KEY (id)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci\n<\/code><\/pre>\n<h2>\u65e5\u4ed8\u7ba1\u7406\u306b\u95a2\u3059\u308b\u30eb\u30fc\u30eb<\/h2>\n<p>\u3053\u306e\u30c6\u30fc\u30d6\u30eb\u306f\u3001\u4e0b\u8a18\u306e\u4f7f\u3044\u65b9\u3092\u524d\u63d0\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n- \u30c6\u30fc\u30d6\u30eb\u306e\u30e6\u30cb\u30fc\u30af\u30ad\u30fc\u306fid\u5217\u3068\u3059\u308b\u3002<br \/>\n- \u30c7\u30fc\u30bf\u306e\u767b\u9332\u6642\u523b\u3001\u66f4\u65b0\u6642\u523b\u3092\u7ba1\u7406\u3059\u308b\u3002<br \/>\n- \u30c7\u30fc\u30bf\u306f\u8ad6\u7406\u524a\u9664\u3067\u7ba1\u7406\u3059\u308b(delete\u6587\u3067\u30ec\u30b3\u30fc\u30c9\u3092\u6d88\u3059\u306e\u3067\u306f\u306a\u304f\u3001\u524a\u9664\u30d5\u30e9\u30b0\u3092\u7acb\u3066\u308b)\u3002<\/p>\n<h2>Laravel\u3067\u4e0a\u8a18\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u308b\u6642\u306emigration\u5b9a\u7fa9<\/h2>\n<p>\u4e0a\u8a18\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u308b\u305f\u3081\u306b\u306f\u3001Laravel\u306emigration\u3060\u3068\u4e0b\u8a18\u306e\u5b9a\u7fa9\u3092\u4f5c\u308c\u3070\u3088\u3044\u3067\u3059\u3002up()\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u3001softDeletes\u3068timestamps\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\nuse Illuminate\\Support\\Facades\\Schema;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Migrations\\Migration;\n\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\n\nclass CreatePostsTable extends Migration\n{\n    public function up()\n    {\n        Schema::create('posts', function (Blueprint $table) {\n            $table-&gt;increments('id');\n            $table-&gt;softDeletes();\n            $table-&gt;timestamps();\n        });\n    }\n\n    public function down()\n    {\n        Schema::dropIfExists('posts');\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u306eOR\u30de\u30c3\u30d1\u30fc\u3067\u3042\u308bEloquent\u3067\u306f\u3001\u30c7\u30fc\u30bf\u306e\u767b\u9332\u6642\u523b\u30fb\u66f4\u65b0\u6642\u523b\u3068\u3001\u30c7\u30fc\u30bf\u306e\u8ad6\u7406\u524a\u9664(SoftDelete)\u3092\u884c\u3046\u3068\u304d\u306e\u524a\u9664\u6642\u523b\u3092\u81ea\u52d5\u3067\u66f4\u65b0\u3057\u3066\u304f\u308c\u308b\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002 \u4eca\u56de\u306f\u3001\u3053\u308c\u3089\u306e\u6a5f\u80fd\u3092\u6700\u5c0f\u306e\u624b\u9593\u3067( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":730,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[80,81],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/akamist.com\/blog\/wp-content\/uploads\/2017\/10\/icon_php.png","jetpack-related-posts":[{"id":1056,"url":"https:\/\/akamist.com\/blog\/archives\/1056","url_meta":{"origin":991,"position":0},"title":"[Laravel]Eloquent\u3067\u767b\u9332\u6642\u523b\u3060\u3051\u3092\u81ea\u52d5\u7ba1\u7406\u3059\u308b\u65b9\u6cd5","date":"2017\u5e7411\u670816\u65e5","format":false,"excerpt":"PHP\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30afLaravel\u306b\u4ed8\u5c5e\u306eEloquent\u3067\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30c7\u30fc\u30bf\u306e\u767b\u9332\u30fb\u66f4\u65b0\u6642\u523b\u2026","rel":"","context":"Laravel","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/11\/icon_laravel.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":982,"url":"https:\/\/akamist.com\/blog\/archives\/982","url_meta":{"origin":991,"position":1},"title":"Laravel5.5\u3067php artisan migrate\u3057\u305f\u6642\u306b\u30a8\u30e9\u30fc\u300c1071 Specified key was too long; max key length is 767 bytes\u300d\u304c\u767a\u751f","date":"2017\u5e7411\u670813\u65e5","format":false,"excerpt":"Laravel5.5\u3067`php artisan migrate`\u3057\u305f\u6642\u306b\u4e0b\u8a18\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u304c\u2026","rel":"","context":"Laravel","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/11\/icon_laravel.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1059,"url":"https:\/\/akamist.com\/blog\/archives\/1059","url_meta":{"origin":991,"position":2},"title":"[PHP]Eloquent\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5358\u4f53\u3067\u5229\u7528\u6642\u3001created_at\u306b\u5165\u308b\u6642\u523b\u306e\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u3092JST\u306b\u3059\u308b","date":"2017\u5e7411\u670816\u65e5","format":false,"excerpt":"Laravel\u3067OR\u30de\u30c3\u30d1\u30fc\u3068\u3057\u3066\u3001Eloquent\u3092\u4f7f\u7528\u3066\u3044\u308b\u5834\u5408\u3001\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u3092\u5909\u66f4\u3059\u308b\u306b\u306f\u3001c\u2026","rel":"","context":"PHP","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/10\/icon_php.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":4640,"url":"https:\/\/akamist.com\/blog\/archives\/4640","url_meta":{"origin":991,"position":3},"title":"O'Reilly\u306e\u300c\u306f\u3058\u3081\u3066\u306eSQL\u300d\u3092\u8aad\u3093\u3067\u3001MySQL8.0\u306eSQL\u3092\u5b66\u3073\u306a\u304a\u3057\u305f","date":"2021\u5e749\u670825\u65e5","format":false,"excerpt":"\u5fd8\u308c\u3066\u3044\u305f\u3053\u3068\u3001\u77e5\u3089\u306a\u304b\u3063\u305f\u3053\u3068\u3092\u81ea\u5206\u306e\u5fd8\u5099\u9332\u3068\u3057\u3066\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002 ## \uff12\u7ae0: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u2026","rel":"","context":"MySQL","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4634,"url":"https:\/\/akamist.com\/blog\/archives\/4634","url_meta":{"origin":991,"position":4},"title":"\u60c5\u5831\u51e6\u7406\u6280\u8853\u8005\u8a66\u9a13: \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8 H26 \u5348\u5f8c\uff11 \u554f1","date":"2021\u5e749\u670825\u65e5","format":false,"excerpt":"\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30da\u30b7\u30e3\u30ea\u30b9\u30c8\u306e\u904e\u53bb\u554f\u3001H26(2014)\u306e\u5348\u5f8c\uff11\u306e\u554f1\u3092\u89e3\u3044\u3066\u5f97\u3089\u308c\u305f\u304d\u3065\u304d\u3092\u66f8\u304d\u307e\u3059\u2026","rel":"","context":"\u672a\u5206\u985e","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4123,"url":"https:\/\/akamist.com\/blog\/archives\/4123","url_meta":{"origin":991,"position":5},"title":"Laravel Socialite\u3067\u8907\u6570SNS\u306e\u30bd\u30fc\u30b7\u30e3\u30eb\u30ed\u30b0\u30a4\u30f3\u3092\u884c\u3046\u65b9\u6cd5","date":"2020\u5e749\u67086\u65e5","format":false,"excerpt":"Laravel\u3067\u306fSocialite\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u30bd\u30fc\u30b7\u30e3\u30eb\u30ed\u30b0\u30a4\u30f3\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u30bd\u2026","rel":"","context":"\u672a\u5206\u985e","img":{"alt_text":"","src":"https:\/\/i0.wp.com\/akamist.com\/blog\/wp-content\/uploads\/2017\/11\/icon_laravel.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts\/991"}],"collection":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":6,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":1024,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions\/1024"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/media\/730"}],"wp:attachment":[{"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/categories?post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/akamist.com\/blog\/wp-json\/wp\/v2\/tags?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}