{"id":12411,"date":"2022-09-01T10:00:00","date_gmt":"2022-09-01T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=12411"},"modified":"2022-09-01T13:38:06","modified_gmt":"2022-09-01T04:38:06","slug":"laravel-%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0%e3%83%90%e3%83%aa%e3%83%87%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e8%bf%bd%e5%8a%a0","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/12411","title":{"rendered":"[Laravel] \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8ffd\u52a0"},"content":{"rendered":"\n<p>\u4eca\u56de\u306fLaravel\u6a19\u6e96\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3067\u306f\u30ab\u30d0\u30fc\u3067\u304d\u306a\u3044\u7279\u5225\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306b\u6709\u52b9\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h4>Laravel\u6a19\u6e96\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5834\u5408<\/h4>\n\n\n\n<p>Laravel\u6a19\u6e96\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306battributes\u3068rules\u306e\u8a2d\u5b9a\u3092\u304a\u3053\u306a\u3044\u3001<br>post\u3055\u308c\u305frequest\u306bValidator::make\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u304a\u3053\u306a\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$attributes = &#091;\n    'name' =&gt; '\u540d\u524d',\n    'url'  =&gt; '\u30db\u30fc\u30e0\u30da\u30fc\u30b8URL',\n    'remain_time'  =&gt; '\u6b8b\u308a\u6642\u9593',\n];\n\n$rules = &#091;\n    'name' =&gt; 'required|max:100',\n    'url'  =&gt; 'nullable|url|max:1000',\n    'remain_time'  =&gt; 'required|numeric',\n];\n\n\/\/\u203b1 \u30d0\u30ea\u30c7\u30fc\u30c8\u51e6\u7406\n$validator = \\Validator::make($request-&gt;all(), $rules, &#091;], $attributes);\n\n\/\/\u203b2 \u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30a8\u30e9\u30fc\u3068post\u30c7\u30fc\u30bf\u3092\u4fdd\u6301\u3057\u3066\n\/\/\u5165\u529b\u30d5\u30a9\u30fc\u30e0\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3092\u304a\u3053\u306a\u3046\u3002\nif ($validator-&gt;fails()) {\n    return redirect('input_form)-&gt;withErrors($validator)-&gt;withInput();\n}<\/code><\/pre>\n\n\n\n<h4>\u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8ffd\u52a0<\/h4>\n\n\n\n<p>Laravel\u6a19\u6e96\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3067\u306f\u30ab\u30d0\u30fc\u3067\u304d\u306a\u3044\u7279\u5225\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u3042\u308b\u5834\u5408\u3001\u4e0a\u8a18\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306e\u203b1\u3068\u203b2\u306e\u9593\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4efb\u610f\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u4efb\u610f\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\n$validator-&gt;after(function($validator) use($request) {\n\n    \/\/\u4f8b\uff09\u5165\u529b\u3055\u308c\u305f\u6b8b\u308a\u6642\u9593(remain_time)\u304c15\u5206\u523b\u307f\u3067\u3042\u308b\u304b\u3092\u30d0\u30ea\u30c7\u30fc\u30c8\n    $remain_time = intval($request-&gt;remain_time);\n    if($remain_time%15!=0){\n        $validator-&gt;errors()-&gt;add('remain_time', '\u6b8b\u308a\u6642\u9593\u306f15\u5206\u523b\u307f\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044');\n    }\n\n});<\/code><\/pre>\n\n\n\n<p><br>\u6728\u66dc\u65e5\u62c5\u5f53\uff1anishida<\/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\/12411\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/12411\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"[Laravel] \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8ffd\u52a0\" 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\/12411\" data-text=\"[Laravel] \u30ab\u30b9\u30bf\u30e0\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u8ffd\u52a0\" 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\/12411\" 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\/12411\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fLaravel\u6a19\u6e96\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u3067\u306f\u30ab\u30d0\u30fc\u3067\u304d\u306a\u3044\u7279\u5225\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u306b\u6709\u52b9\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/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\/12411"}],"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=12411"}],"version-history":[{"count":8,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12411\/revisions"}],"predecessor-version":[{"id":12420,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12411\/revisions\/12420"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=12411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=12411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=12411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}