{"id":1050,"date":"2019-01-19T15:35:45","date_gmt":"2019-01-19T06:35:45","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=1050"},"modified":"2019-01-24T11:22:43","modified_gmt":"2019-01-24T02:22:43","slug":"post-1050","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2019\/01\/19\/post-1050\/","title":{"rendered":"Laravel\uff1a\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306brole\u3082\u4e00\u7dd2\u306bcreate\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<h2>Laravel\uff1a\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306brole\u3082\u4e00\u7dd2\u306bcreate\u3059\u308b\u65b9\u6cd5<\/h2>\n<p>\u7ba1\u7406\u8005\u306b\u3088\u308b\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u4f5c\u6210\u95a2\u9023\u3068\u3057\u3066\u3001\u524d\u56de\u307e\u3067\u306e\u8a18\u4e8b\u3067\u4e0b\u8a18\u69cb\u6210\u3092\u69cb\u7bc9\u3057\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2019\/01\/18\/post-1045\/\">\u7ba1\u7406\u8005\u306b\u3088\u308b\u30e6\u30fc\u30b6\u30fc\u767b\u9332\uff0fguest\u306e\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u4e0d\u53ef<\/a><\/li>\n<li>\n<p id=\"outline__1\"><a href=\"https:\/\/qol-kk.com\/wp2\/blog\/2019\/01\/18\/post-1048\/\">register\u5b9f\u884c\u5f8c\u306e\u52d5\u4f5c\u3092\u540c\u3058\u30ed\u30b0\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u306e\u307e\u307eHome\u306b\u8a2d\u5b9a<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u3053\u306e\u72b6\u614b\u3067\u30e6\u30fc\u30b6\u30fc\u306e\u767b\u9332\u9805\u76ee\u3092\u5909\u66f4\u3057\u3088\u3046\u3068\u3057\u305f\u3068\u3053\u308d\u3001\u65b0\u8a2d\u3057\u305f\u9805\u76ee(role\u7b49)\u304c\u521d\u671f\u5024\u3067\u5165\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\n\u4ee5\u524d\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u305f\u5834\u6240\u306a\u306e\u3067\u3059\u304c\u3001\u3059\u3063\u304b\u308a\u5fd8\u308c\u3066\u3044\u305f\u306e\u3067\u5099\u5fd8\u9332\u306b\u6b8b\u3057\u307e\u3059\u3002<\/p>\n<h3>\u9805\u76ee\u8ffd\u52a0\u6642\u306f2\u500b\u6240\u306e\u5909\u66f4\u304c\u5fc5\u8981\u3067\u3059<\/h3>\n<div class=\"borderBox\">\n<ol>\n<li>\\app\\Http\\Controllers\\RegisterController.php<\/li>\n<li>\\app\\User.php<\/li>\n<\/ol>\n<\/div>\n<p>Controller\u3068Model\u3067\u3059\u3002<br \/>\n\u3088\u304f\u8003\u3048\u308c\u3070\u5f53\u305f\u308a\u524d\u306a\u306e\u3067\u3059\u304c\u3001\u79c1\u306fUser.php\u306e\u5909\u66f4\u3092\u3059\u3063\u304b\u308a\u5fd8\u308c\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001role\u306e\u5024\u304c\u521d\u671f\u5024\u3067\u767b\u9332\u3055\u308c\u308b\u3068\u3044\u3046\u73fe\u8c61\u304c\u767a\u751f\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<h3>RegisterController.php\u306b\u8ffd\u8a18<\/h3>\n<pre class=\"lang:default decode:true\">    \/**\r\n     * Get a validator for an incoming registration request.\r\n     * \u7740\u4fe1\u767b\u9332\u8981\u6c42\u306e\u30d0\u30ea\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\r\n     * @param  array  $data\r\n     * @return \\Illuminate\\Contracts\\Validation\\Validator\r\n     *\/\r\n    protected function validator(array $data)\r\n    {\r\n        return Validator::make($data, [\r\n            'name' =&gt; 'required|string|max:255',\r\n            'email' =&gt; 'required|string|email|max:255|unique:users',\r\n            'password' =&gt; 'required|string|min:6|confirmed',\r\n            'role' =&gt; 'required|Integer|max:2',\u3000\/\/\u8ffd\u52a0\u30f6\u6240\r\n        ]);\r\n    }\r\n\r\n    \/**\r\n     * Create a new user instance after a valid registration.\r\n     * \u6709\u52b9\u306a\u767b\u9332\u5f8c\u306b\u65b0\u3057\u3044\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\r\n     * @param  array  $data\r\n     * @return \\App\\User\r\n     *\/\r\n    protected function create(array $data)\r\n    {\r\n        return User::create([\r\n            'name' =&gt; $data['name'],\r\n            'email' =&gt; $data['email'],\r\n            'password' =&gt; bcrypt($data['password']),\r\n            'role' =&gt; $data['role'],\u3000\/\/\u8ffd\u52a0\u30f6\u6240\r\n        ]);\r\n    }\r\n<\/pre>\n<p>\u30d0\u30ea\u30c7\u30fc\u30bf\u3068\u30af\u30ea\u30a8\u30a4\u30c8\u306b\u65b0\u898f\u8ffd\u52a0\u6642\u306b\u767b\u9332\u3057\u305f\u3044\u5024\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n<h3>User.php\u306b\u8ffd\u8a18<\/h3>\n<pre class=\"lang:default decode:true\">    protected $fillable = [\r\n        'name',\r\n        'email',\r\n        'password',\r\n        'role',      \/\/\u8ffd\u52a0\u30f6\u6240\r\n    ];<\/pre>\n<p>$fillable \u306e\u4e2d\u306b\u65b0\u898f\u8ffd\u52a0\u6642\u306b\u767b\u9332\u3057\u305f\u3044\u5024\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u3053\u306e2\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u66f4\u3059\u308c\u3070\u826f\u3044\u3060\u3051\u306a\u306e\u3067\u3001\u4f8b\u3048\u3070\u300e\u82d7\u5b57\u3068\u540d\u524d\u3092\u5206\u3051\u308b\u300f\u300e\u30ed\u30b0\u30a4\u30f3ID\u3092\u65b0\u8a2d\u3059\u308b\u300f\u306a\u3093\u3066\u6642\u3082\u7c21\u5358\u306b\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\uff1a\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u6642\u306brole\u3082\u4e00\u7dd2\u306bcreate\u3059\u308b\u65b9\u6cd5 \u7ba1\u7406\u8005\u306b\u3088\u308b\u65b0\u898f\u30e6\u30fc\u30b6\u30fc\u4f5c\u6210\u95a2\u9023\u3068\u3057\u3066\u3001\u524d\u56de\u307e\u3067\u306e\u8a18\u4e8b\u3067\u4e0b\u8a18\u69cb\u6210\u3092\u69cb\u7bc9\u3057\u307e\u3057\u305f\u3002 \u7ba1\u7406\u8005\u306b\u3088\u308b\u30e6\u30fc\u30b6\u30fc\u767b\u9332\uff0fguest\u306e\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u4e0d\u53ef regist [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[34],"tags":[287,153,99,98,285,53,277,286,45],"class_list":["post-1050","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php-memorandum","tag-create","tag-laravel","tag-mysql","tag-php","tag-role","tag-53","tag-277","tag-286","tag-45"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2018\/11\/laravel_logo.png","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=1050"}],"version-history":[{"count":0,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/1050\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/944"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=1050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=1050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}