{"id":277,"date":"2018-02-12T04:05:07","date_gmt":"2018-02-11T19:05:07","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=277"},"modified":"2018-02-13T21:11:09","modified_gmt":"2018-02-13T12:11:09","slug":"laravel5-6%e3%81%ae%e6%b0%97%e3%81%ab%e3%81%aa%e3%82%8b%ef%bc%93%e3%81%a4%e3%81%ae%e6%96%b0%e6%a9%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=277","title":{"rendered":"Laravel5.6\u306e\u6c17\u306b\u306a\u308b\uff13\u3064\u306e\u65b0\u6a5f\u80fd"},"content":{"rendered":"<p>\u524d\u56de\u3001<a href=\"https:\/\/blog.capilano-fw.com\/?p=264\">Laravel5.6\u306e\u65b0\u6a5f\u80fd\u3067\u30a8\u30e9\u30fc\u3092slack\u306b\u9001\u4fe1<\/a>\u3068\u3044\u3046\u8a18\u4e8b\u3092\u516c\u958b\u3057\u305f\u3093\u3067\u3059\u3051\u3069\u3001\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3001\u305d\u306e\u4ed6\u3067\u6c17\u306b\u306a\u3063\u305f\u65b0\u6a5f\u80fd\u3082\u307e\u3068\u3081\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u7686\u3055\u3093\u306e\u53c2\u8003\u306b\u306a\u3063\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002<\/p>\n<h2>\uff11\uff0eUUID<\/h2>\n<p>\u30e6\u30cb\u30fc\u30af\u306a\uff08\u4e00\u610f\u306a\uff09ID\u3092\u53d6\u5f97\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<br \/>\n\u8ffd\u52a0\u3055\u308c\u305f\u306e\u306f\u3001<\/p>\n<pre><b>use Illuminate\\Support\\Str;<\/b>\n\n<b>echo (string) Str::uuid(); \/\/ d4b3e48c-3b30-40b7-a90d-09bc979cde33<\/b>\n<b>echo (string) Str::orderedUuid(); \/\/ 8a185f1c-2876-4120-b924-4d1ea1655305<\/b><\/pre>\n<p>\u306e\uff12\u3064\u3067\u3059\u3002<\/p>\n<p>\uff11\u3064\u3081\u306f\u901a\u5e38\u306e\u30e6\u30cb\u30fc\u30afID\u3067\u3001\uff12\u3064\u76ee\u306f\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u304b\u3089\u3081\u305f\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3067\u304d\u308b\u3093\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u3059\u308b\u306a\u3069\u306e\u5229\u7528\u65b9\u6cd5\u3092\u60f3\u5b9a\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u79c1\u306e\u74b0\u5883\u3067\u306f\u3001<b>orderedUuid()<\/b>\u3067\u3001\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u89e3\u6c7a\u6cd5\u3092\u6b8b\u3057\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre><b>Cannot call Ramsey\\Uuid\\Converter\\Number\\DegradedNumberConverter::toHex without support for large integers, since integer is an unsigned 128-bit integer; Moontoast\\Math\\BigNumber is required.<\/b><\/pre>\n<p>\u307e\u305a\u3001<b>bcmath<\/b>\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u304cPHP\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u306a\u3044\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><b>sudo apt install php7.2-bcmath<\/b><\/pre>\n<p>\u203bphp\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u5909\u308f\u3063\u3066\u304f\u308b\u3068\u601d\u3046\u3093\u3067\u3001\u3054\u81ea\u8eab\u306e\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-278\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/02\/bcmath.png\" alt=\"\" width=\"968\" height=\"143\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/02\/bcmath.png 968w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/02\/bcmath-300x44.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/02\/bcmath-768x113.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>\u3067\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\uff06\u30a6\u30a7\u30d6\u30b5\u30fc\u30d0\u30fc\u306e\u518d\u8d77\u52d5\u304c\u6e08\u3093\u3060\u3089\u4ee5\u4e0b\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092<b>composer<\/b>\u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre><b>composer require moontoast\/math:*<\/b><\/pre>\n<p>\u203b\u3082\u3057\u304b\u3059\u308b\u3068\u3001PHP\u74b0\u5883\u306b<b>bcmath<\/b>\u304c\u5165\u3063\u3066\u3044\u308c\u3070Laravel\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6642\u306b\u81ea\u52d5\u7684\u306b\u6e96\u5099\u3057\u3066\u304f\u308c\u308b\u306e\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<h2>\uff12\uff0e\u30e2\u30c7\u30eb\u5185\u306e\u65e5\u4ed8\u30fb\u81ea\u52d5\u5909\u63db<\/h2>\n<p>\u4ee5\u524d\u304b\u3089\u30e2\u30c7\u30eb\u5185\u306b<b>$casts<\/b>\u3092\u8a2d\u7f6e\u3059\u308c\u3070\u3001\u81ea\u52d5\u7684\u306b<b>Carbon\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9<\/b>\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u3066\u307e\u3057\u305f\u3051\u3069\u3001\u4eca\u56de\u306f<b>\u65e5\u4ed8\u30d5\u30a9\u30fc\u30de\u30c3\u30c8<\/b>\u3082\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u30e2\u30c7\u30eb\u5185\u306b<\/p>\n<pre><b>protected $casts = [<\/b>\n<b>    'shipped_date' =&gt; 'date:Y-m-d',<\/b>\n<b>    'shipped_at' =&gt; 'datetime:Y-m-d H:00',<\/b>\n<b>];<\/b><\/pre>\n<p>\u3068\u3044\u3046\u98a8\u306b\u30ad\u30e3\u30b9\u30c8\u6307\u5b9a\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u305f\u5834\u5408\u3001<\/p>\n<pre><b>$item = \\App\\Item::find(1);<\/b>\n<b>$json = $item-&gt;toJson();<\/b>\n<b>$array = $item-&gt;toArray();<\/b><\/pre>\n<p><b>$json<\/b>\u304c\u3053\u3093\u306a\u611f\u3058\u3067\u3001<\/p>\n<pre class=\"sf-dump\" id=\"sf-dump-1713885874\" data-indent-pad=\" \"><b>\"<\/b><span class=\"sf-dump-str\" title=\"61 characters\"><b>{\"shipped_date\":\"2018-01-01\",\"shipped_at\":\"2018-01-01 12:00\"}<\/b><\/span><b>\"<\/b><\/pre>\n<p><b>$array<\/b>\u304c\u3001\u65e5\u4ed8\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"sf-dump\" id=\"sf-dump-2070900919\" tabindex=\"0\" data-indent-pad=\" \"><span class=\"sf-dump-note\"><b>array:2<\/b><\/span><b> [<\/b><b><a class=\"sf-dump-ref sf-dump-toggle\" title=\"[Ctrl+click] Expand all children\" href=\"\">\u25bc<\/a><\/b><samp class=\"sf-dump-expanded\" data-depth=\"1\">\n  \"<span class=\"sf-dump-key\">shipped_date<\/span>\" =&gt; \"<span class=\"sf-dump-str\" title=\"10 characters\">2018-01-01<\/span>\"\n  \"<span class=\"sf-dump-key\">shipped_at<\/span>\" =&gt; \"<span class=\"sf-dump-str\" title=\"16 characters\">2018-01-01 12:00<\/span>\"\n<\/samp><b>]<\/b><\/pre>\n<p>\u305f\u3060\u3001\u3053\u306e\u6a5f\u80fd\u306e\u3059\u3054\u3044\u3068\u3053\u308d\u306f\u3001<b>\u901a\u5e38\u306e\u30c7\u30fc\u30bf\u30a2\u30af\u30bb\u30b9\u306e\u5834\u5408\u306f\u3001\u3053\u308c\u307e\u3067\u3069\u304a\u308aCarbon\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u30c7\u30fc\u30bf\u304c\u8fd4\u3063\u3066\u304f\u308b<\/b>\uff08\u3064\u307e\u308a\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306f\u5e38\u306b\u56fa\u5b9a\u3067\u306f\u306a\u304f\u3001json\u3082\u3057\u304f\u306farray\u306e\u5834\u5408\u306e\u307f\u6709\u52b9\uff09\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<pre><b>$item-&gt;shipped_date;<\/b> \/\/ Carbon\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\n\n\/*** \u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\n\nCarbon @1514764800 {#496 \u25bc\n date: 2018-01-01 00:00:00.0 UTC (+00:00)\n}\n\n***\/<\/pre>\n<p>\u3064\u307e\u308a\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4f7f\u3044\u65b9\u304c\u3067\u304d\u308b\u3063\u3066\u3053\u3068\u3067\u3059\u306d\u3002<\/p>\n<pre><b>echo $item-&gt;shipped_date-&gt;format('Y-m-d H:i'); \/\/ 2018-01-01 00:00<\/b><\/pre>\n<p>\u306a\u306e\u3067\u3001\u7279\u306bjson\u306a\u3093\u304b\u306f\u3001Vue\u3068\u306e\u9023\u643a\u304c\u3084\u308a\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u306d\u3002<\/p>\n<h2>\uff13\uff0eAPI\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u4f5c\u6210\u30b3\u30de\u30f3\u30c9<\/h2>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001<b>\/app\/Http\/Controllers\/API<\/b>\u5185\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u4f5c\u6210\u3055\u308c\u3066\u3001\u3057\u304b\u3082\u5185\u5bb9\u306f\u3001<\/p>\n<ul>\n<li><b>index()<\/b><\/li>\n<li><b>store()<\/b><\/li>\n<li><b>show()<\/b><\/li>\n<li><b>update()<\/b><\/li>\n<li><b>destroy()<\/b><\/li>\n<\/ul>\n<p>\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3059\u3067\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u3066\u3001RESTful\u306a\u5185\u5bb9\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><b>php artisan make:controller API\/PhotoController --api<\/b><\/pre>\n<p>\u4ee5\u4e0a\u3067\u3059\u3002<\/p>\n<p>\u65b0\u3057\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u51fa\u308b\u305f\u3073\u306bLaravel\u306f\u3082\u3046\u9032\u5316\u3057\u304d\u3063\u3066\u308b\u3093\u3058\u3083\u306a\u3044\uff1f\uff1f\u306a\u3093\u3066\u601d\u3063\u3066\u3057\u307e\u3046\u3093\u3067\u3059\u3051\u3069\u3001\u307e\u3060\u307e\u3060\u3053\u308c\u304b\u3089\u3082\u697d\u3057\u307f\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u306d\uff01<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u3001Laravel5.6\u306e\u65b0\u6a5f\u80fd\u3067\u30a8\u30e9\u30fc\u3092slack\u306b\u9001\u4fe1\u3068\u3044\u3046\u8a18\u4e8b\u3092\u516c\u958b\u3057\u305f\u3093\u3067\u3059\u3051\u3069\u3001\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u3001\u305d\u306e\u4ed6\u3067\u6c17\u306b\u306a\u3063\u305f\u65b0\u6a5f\u80fd\u3082\u307e\u3068\u3081\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=277\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel5.6\u306e\u6c17\u306b\u306a\u308b\uff13\u3064\u306e\u65b0\u6a5f\u80fd&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":269,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[38],"class_list":["post-277","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-php","tag-uuid"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/277","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=277"}],"version-history":[{"count":2,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":280,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions\/280"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/269"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}