{"id":11991,"date":"2022-04-14T10:00:00","date_gmt":"2022-04-14T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11991"},"modified":"2022-04-13T18:16:01","modified_gmt":"2022-04-13T09:16:01","slug":"datatables%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e7%94%9f%e6%88%90%e3%81%a8%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%b5%e3%82%a4%e3%83%89%e9%80%a3-8","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11991","title":{"rendered":"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(8)"},"content":{"rendered":"\n<p>\u672c\u8a18\u4e8b\u3067\u306fDataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u65b9\u6cd5\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u65b9\u6cd5\u3092\u30b7\u30a7\u30a2\u3057\u307e\u3059\u3002<br><a href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11935\" target=\"_blank\" rel=\"noreferrer noopener\">\u524d\u56de\u306e\u8a18\u4e8b<\/a>\u3067\u30da\u30fc\u30b8\u30f3\u30b0\u304a\u3088\u3073\u30bd\u30fc\u30c8\u51e6\u7406\u306e\u5b9f\u88c5\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u306e\u3067<br>\u4eca\u56de\u306f\u691c\u7d22(\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0)\u51e6\u7406\u306e\u4f5c\u6210\u3092\u304a\u3053\u306a\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h4>\u691c\u7d22(\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0)\u51e6\u7406\u306e\u8ffd\u52a0<\/h4>\n\n\n\n<p>DataTables\u306e\u521d\u671f\u72b6\u614b\u3067\u306f\u691c\u7d22\u30a6\u30a4\u30f3\u30c9\u30a6\u306b\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3057\u305f\u6642\u70b9\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067<br>\u90fd\u5ea6\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u3068\u901a\u4fe1\u304c\u304a\u3053\u306a\u308f\u308c\u308b\u305f\u3081\u3001\u691c\u7d22\u30dc\u30bf\u30f3\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br>\u691c\u7d22\u30a6\u30a4\u30f3\u30c9\u30a6\u306b\u5165\u529b\u3055\u308c\u305f\u30ef\u30fc\u30c9\u306fLaravel\u304b\u3089\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\/\/\u691c\u7d22\u30a6\u30a4\u30f3\u30c9\u30a6\u306b\u5165\u529b\u3055\u308c\u305f\u30ef\u30fc\u30c9\u3092\u53d6\u5f97<br>$search_value = $request-&gt;search[&#8216;value&#8217;];<\/p>\n\n\n\n<p>\u307e\u305f\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u304b\u3089\u8fd4\u5374\u3059\u308bjson\u3067\u8a2d\u5b9a\u3059\u308b\u5408\u8a08\u4ef6\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306f&#8221;recordsTotal&#8221;\u3068&#8221;recordsFiltered&#8221;\u306e<br>\u3044\u305a\u308c\u3082\u30ec\u30b3\u30fc\u30c9\u306e\u7dcf\u4ef6\u6570\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u6b63\u78ba\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>recordsTotal\uff1a\u30ec\u30b3\u30fc\u30c9\u306e\u7dcf\u4ef6\u6570<br>recordsFiltered\uff1a\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u5f8c(\u691c\u7d22\u6761\u4ef6\u7d5e\u308a\u8fbc\u307f\u5f8c)\u306e\u7dcf\u4ef6\u6570<\/strong><\/p>\n\n\n\n<p>\u4e0a\u8a18\u306e\u8a2d\u5b9a\u3092\u53cd\u6620\u3055\u305b\u305f\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u5074\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function user_datatables(Request $request) {\n\n    $rec_data = &#091;];\n    $query = Member::query();\n\n    \/\/\u5168\u4ef6\u4ef6\u6570\u306e\u53d6\u5f97\n    $total_cnt = $query-&gt;count();\n\n    \/\/\u691c\u7d22\u51e6\u7406\n    $search_value = $request-&gt;search&#091;'value'];\n    $query-&gt;where('mail', 'LIKE', '%'.$search_value.'%')\n            -&gt;orWhere('sei', 'LIKE', '%'.$search_value.'%')\n            -&gt;orWhere('mei', 'LIKE', '%'.$search_value.'%')\n            -&gt;orWhere('sei_kana', 'LIKE', '%'.$search_value.'%')\n            -&gt;orWhere('mei_kana', 'LIKE', '%'.$search_value.'%')\n            -&gt;orWhere('mail', 'LIKE', '%'.$search_value.'%');\n\n    \/\/\u691c\u7d22\u6761\u4ef6\u7d5e\u308a\u8fbc\u307f\u5f8c\u306e\u4ef6\u6570\u306e\u53d6\u5f97\n    $filtered_total_cnt = $query-&gt;count();\n\n    $length = $request-&gt;length;\n    $start = $request-&gt;start;\n    $order_column = &#091;\n                        'id', \n                        'sei', \n                        'sei_kana', \n                        'mail', \n                        'created_at', \n                    ];\n    $order_column_num = $request-&gt;order&#091;0]&#091;'column'];\n    $order_dir = $request-&gt;order&#091;0]&#091;'dir']; \/\/ asc or desc\n    $query-&gt;orderBy($order_column&#091;$order_column_num], $order_dir);\n    $query-&gt;offset($start);\n    $query-&gt;limit($length);\n    $member_list = $query-&gt;get();\n    foreach($member_list as $member){\n        $row_data = &#091;\n            'item1' =&gt; $member-&gt;id,\n            'item2' =&gt; $member-&gt;sei.$member-&gt;mei,\n            'item3' =&gt; $member-&gt;sei_kana.$member-&gt;mei_kana,\n            'item4' =&gt; $member-&gt;mail,\n            'item5' =&gt; $member-&gt;created_at-&gt;format('Y-m-d H:i'),\n        ];\n        $rec_data&#091;] = $row_data;\n    }\n\n    $draw = $request-&gt;draw;\n    $res_json = array(\n        'draw' =&gt; $draw, \n        'recordsTotal' =&gt; $total_cnt, \n        'recordsFiltered' =&gt; $filtered_total_cnt, \n        'data' =&gt; $rec_data, \n    );\n\n    return response()-&gt;json($res_json);\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u4ee5\u4e0a\u304c\u691c\u7d22\u51e6\u7406\u306e\u5b9f\u88c5\u30b5\u30f3\u30d7\u30eb\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u5b9f\u969b\u306e\u904b\u7528\u306b\u306fLIKE\u691c\u7d22\u6642\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u51e6\u7406\u306a\u3069\u306e\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\u3082\u5fc5\u9808\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6b21\u56de\u306f\u4e0a\u8a18\u691c\u7d22\u51e6\u7406\u306e\u52d5\u4f5c\u78ba\u8a8d\u3084\u3001DataTables\u3092\u65e5\u672c\u8a9e\u5316\u3059\u308b\u65b9\u6cd5\u306a\u3069\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6728\u66dc\u65e5\u62c5\u5f53\uff1anishida<\/p>\n\n\n\n<p><\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11991\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11991\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(8)\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11991\" data-text=\"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(8)\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11991\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11991\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u8a18\u4e8b\u3067\u306fDataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u65b9\u6cd5\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u65b9\u6cd5\u3092\u30b7\u30a7\u30a2\u3057\u307e\u3059\u3002\u524d\u56de\u306e\u8a18\u4e8b\u3067\u30da\u30fc\u30b8\u30f3\u30b0\u304a\u3088\u3073\u30bd\u30fc\u30c8\u51e6\u7406\u306e\u5b9f\u88c5\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u306e\u3067\u4eca\u56de\u306f\u691c\u7d22(\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0)\u51e6\u7406\u306e\u4f5c\u6210\u3092\u304a\u3053\u306a\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11991"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=11991"}],"version-history":[{"count":11,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11991\/revisions"}],"predecessor-version":[{"id":12005,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11991\/revisions\/12005"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}