{"id":9879,"date":"2019-02-05T21:29:50","date_gmt":"2019-02-05T12:29:50","guid":{"rendered":"https:\/\/www.itblog.jp\/?p=9879"},"modified":"2019-03-11T08:31:44","modified_gmt":"2019-03-10T23:31:44","slug":"larabel%e3%81%a7%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%82%92%e4%bd%9c%e6%88%90%e3%81%99%e3%82%8b%e6%89%8b%e9%a0%86","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=9879","title":{"rendered":"Larabel(5.7)\u3067\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u6210\u3059\u308b\u624b\u9806"},"content":{"rendered":"<p>Laravel\u3067\u7c21\u5358\u306a\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u308b\u306e\u306f\u57fa\u790e\u4e2d\u306e\u57fa\u790e\u3067\u3059\u304c\u3001\u6163\u308c\u306a\u3044\u3046\u3061\u306f\u4f55\u7b87\u6240\u304b\u3064\u307e\u3065\u3044\u305f\u306e\u3067\u8a18\u9332\u306b\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30d5\u30a9\u30fc\u30e0\u306e\u4ed5\u69d8<\/h2>\n<p>\u8a18\u4e8b\u3092\u6295\u7a3f\u3057\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b<\/p>\n<p>\u4ef6\u540d(\u30bf\u30a4\u30c8\u30eb)\u3068\u672c\u6587\u3092\u5165\u529b\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u4fdd\u5b58\u3059\u308b\u3002<\/p>\n<p>\u30b5\u30a4\u30c8\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u3067\u4fdd\u5b58\u3055\u308c\u305f\u8a18\u4e8b\u4e00\u89a7\u3068\u3001<\/p>\n<p>\u305f\u3060\u3053\u308c\u3060\u3051\u306e\u30b7\u30f3\u30d7\u30eb\u306a\u4ed5\u69d8\u3002<\/p>\n<h2>\u307e\u305a\u306f\u74b0\u5883\u69cb\u7bc9<\/h2>\n<p>\u74b0\u5883\u69cb\u7bc9\u306b\u306fhomestead\u3092\u5229\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u624b\u9806\u306f\u3053\u3061\u3089\u306e\u8a18\u4e8b\u306b\u66f8\u3044\u3066\u3044\u308b\u306e\u3067\u5272\u611b\u3057\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/www.itblog.jp\/?p=9872\">Laravel Homestead\u5c0e\u5165\u6642\u306e\u60aa\u6226\u82e6\u95d8\u30e1\u30e2<\/a><\/p>\n<p>\u6700\u521d\u306b\u3084\u3063\u305f\u306e\u306f\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3(Laravel4\u7cfb)\u3060\u3063\u305f\u306e\u3067\u3001\u518d\u5ea6\u3084\u308a\u306a\u304a\u3057\u3066Laravel5\u7cfb\u3067\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.itblog.jp\/?p=9875\">Laravel Homestead\u3092PHP7\u3067\u52d5\u4f5c\u3055\u305b\u308b<\/a><\/p>\n<p>\u74b0\u5883\u69cb\u7bc9\u306b\u624b\u9593\u53d6\u308a\u307e\u3057\u305f\u304c\u3001\u3088\u3046\u3084\u304f\u52d5\u4f5c\u3057\u305f\u306e\u3067\u30d5\u30a9\u30fc\u30e0\u306e\u5236\u4f5c<\/p>\n<h2>\uff11\uff0e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210<\/h2>\n<p>\u307e\u305a\u306f\u3001Homestead\u306e\u74b0\u5883\u306b\u30ed\u30b0\u30a4\u30f3\u5f8c\u3001Artisan\u30b3\u30de\u30f3\u30c9\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059<br \/>\n\u4eca\u56de\u306f\u3001\u8a18\u4e8b\u3092\u6295\u7a3f\u3059\u308b\u306e\u3067\u3001posts\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210<\/p>\n<p>php artisan make:migration create_posts_table &#8211;create=posts<\/p>\n<pre class=\"lang:default decode:true \" >public function up()\r\n    {\r\n        Schema::create('posts', function (Blueprint $table) {\r\n            $table-&gt;increments('id');\r\n            $table-&gt;string('title');\r\n            $table-&gt;text('body');\r\n            $table-&gt;boolean('delete_flg')-&gt;default(0);\r\n            $table-&gt;timestamps();\r\n        });\r\n    }<\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u305f\u5f8c\u3001<\/p>\n<p>php artisan migrate<\/p>\n<p>\u3067\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30e2\u30c7\u30eb\u4f5c\u6210<\/h2>\n<p>\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u5f8c\u3001\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u5fdc\u3057\u305f\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>php artisan make:model Post<\/p>\n<p>\u3053\u308c\u3067\u3001<\/p>\n<p>\/App\/Post.php<\/p>\n<p>\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\n\u3053\u308c\u3067\u3001\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u5fdc\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30e2\u30c7\u30eb\u306f\u3042\u3068\u3067\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<h2>\u7ba1\u7406\u753b\u9762\u3092\u4f5c\u308b<\/h2>\n<p>\u307e\u305a\u306f\u3001\u8a18\u4e8b\u3092\u6295\u7a3f\u3059\u308b\u7ba1\u7406\u753b\u9762\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u7ba1\u7406\u753b\u9762\u306e\u51e6\u7406\u306b\u5bfe\u5fdc\u3059\u308b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>php artisan make:controller AdminEntryController<\/p>\n<p>\u3053\u308c\u3067\u3001\/Http\/Controllers\/AdminEntryController.php\u304c\u4f5c\u6210\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u7ba1\u7406\u753b\u9762\u306e\u51e6\u7406\u306b\u5bfe\u5fdc\u3059\u308b\u8a18\u8ff0\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u6642\u70b9\u3067\u306f\u96db\u5f62\u304c\u4f5c\u3089\u308c\u305f\u3060\u3051\u3067\u51e6\u7406\u306f\u4f55\u3082\u5165\u3063\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<h2>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8a18\u8ff0\u3059\u308b<\/h2>\n<p>\/admin\/entry \u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u3001\u7ba1\u7406\u753b\u9762\u306e\u6295\u7a3f\u753b\u9762\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8a18\u8ff0\u30d5\u30a1\u30a4\u30eb\u306f\u3001\/routes\/web.php\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<\/p>\n<p>Route::get(&#8216;\/admin\/entry&#8217;, &#8216;AdminEntryController@top&#8217;);<\/p>\n<p>\u3053\u308c\u3067\u306f\u3001url\u300c\/admin\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u306b\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9AdminEntryController\u306e\u300ctop\u300d\u30e1\u30bd\u30c3\u30c9\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u6700\u521d\u306f\u3001\u3068\u308a\u3042\u3048\u305a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u5358\u7d14\u306b\u8868\u793a\u3059\u308b\u3060\u3051\u306b\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" >public function top()\r\n    {\r\n        return view('admin.entry');\r\n    }<\/pre>\n<p>\u3053\u308c\u306f\u3001\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u5b9f\u884c\u3055\u308c\u305f\u3068\u304d\u306b<\/p>\n<p>\/resources\/views\/admin\/index.blade.php\u3092\u8868\u793a\u3059\u308b\u3068\u3044\u3046\u51e6\u7406\u3067\u3059\u3002<\/p>\n<p>\u307e\u3060\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u3066\u306a\u3044\u306e\u3067\u3001URL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3082\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<h2>blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210<\/h2>\n<p>blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u3001laravel\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u56fa\u6709\u306e\u8a18\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>CMS\u3084\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u4f7f\u3063\u305f\u3053\u3068\u304c\u3042\u308b\u4eba\u3067\u3042\u308c\u3070\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3044\u3046\u8aac\u660e\u3092\u805e\u304f\u3068\u5927\u4f53\u30a4\u30e1\u30fc\u30b8\u304c\u3064\u304b\u3081\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u57fa\u672c\u7684\u306b\u306f\u540c\u3058\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u7279\u5fb4\u3068\u3057\u3066\u306f\u3001<strong>\u89aa\u3068\u5b50\u306e\u7d99\u627f<\/strong>\u3068\u3044\u3046\u3082\u306e\u304c\u7279\u5fb4\u3067\u3059\u3002<\/p>\n<p>\u5927\u4f53\u306e\u30b5\u30a4\u30c8\u306f\u3001\u57fa\u672c\u3068\u306a\u308b\u5171\u901a\u90e8\u5206\u304c\u3042\u3063\u3066\u3001\u5f8c\u306f\u30b3\u30f3\u30c6\u30f3\u30c4\u90e8\u5206\u3084\u30bf\u30a4\u30c8\u30eb\u306a\u3069\u3001\u4e00\u90e8\u7570\u306a\u308b\u90e8\u5206\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>Laravel\u306eblade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3067\u306f\u3001\u5171\u901a\u3057\u3066\u3044\u308b\u90e8\u5206\u3092\u307e\u305a\u3001\u89aa\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3068\u3057\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u3042\u3068\u306f\u3001\u305d\u308c\u305e\u308c\u306e\u30da\u30fc\u30b8\u306f\u3001\u89aa\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u7d99\u627f\u3059\u308b\u3053\u3068\u3067\u3001\u7570\u306a\u308b\u90e8\u5206\u3060\u3051\u4f5c\u6210\u3059\u308b\u3068\u3044\u3046\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u7279\u5fb4\u306b\u3088\u308a\u3001\u5b50\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u6700\u5c0f\u9650\u306e\u8a18\u8ff0\u3067\u3001\u307e\u305f\u5fc5\u8981\u306a\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3082\u6700\u5c0f\u9650\u3067\u3059\u307f\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\/admin\/\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u304c\u306a\u3051\u308c\u3070\u30b5\u30a4\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u4f5c\u6210\u3057\u305f\u30d5\u30a9\u30fc\u30e0\u306e\u96db\u5f62\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<p>\u6ce8\u610f\u304c\u5fc5\u8981\u306a\u70b9\u3068\u3057\u3066\u306f\u3001\u30d5\u30a9\u30fc\u30e0\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u8a2d\u5b9a\u3067\u306f\u3001\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30ea\u30af\u30a8\u30b9\u30c8\u30d5\u30a9\u30fc\u30b8\u30a7\u30ea\u5bfe\u7b56\u306b\u3001@csrf\u3092\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u57cb\u3081\u8fbc\u3093\u3067\u7f6e\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u66f8\u3044\u3066\u3044\u306a\u3044\u3068\u6295\u7a3f\u6642\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" >@extends('admin.parent')\r\n\r\n@section('title', '\u6295\u7a3f\u7ba1\u7406(\u5165\u529b\u753b\u9762)')\r\n\r\n@section('content')\r\n    &lt;form action=\"\/admin\/entry\/\" method=\"post\" id=\"formid\" enctype=\"multipart\/form-data\"&gt;\r\n\r\n        @csrf\r\n\r\n        &lt;table class=\"table table-striped\"&gt;\r\n\r\n            &lt;tr&gt;\r\n                &lt;td&gt;\u30bf\u30a4\u30c8\u30eb&lt;\/td&gt;\r\n                &lt;td&gt;&lt;input type=\"text\" name=\"title\" value=\"\" placeholder=\"\u30bf\u30a4\u30c8\u30eb\u304c\u5165\u308a\u307e\u3059\" \/&gt;&lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n\r\n            &lt;tr&gt;\r\n                &lt;td&gt;\u672c\u6587&lt;\/td&gt;\r\n                &lt;td&gt;&lt;textarea name=\"body\"&gt;&lt;\/textarea&gt;&lt;\/td&gt;\r\n            &lt;\/tr&gt;\r\n\r\n            &lt;tr&gt;\r\n                &lt;td colspan=\"2\" class=\"text-center\"&gt;\r\n                    &lt;input type=\"submit\" name=\"submit22\" value=\"\u767b\u9332\" class=\"btn btn-primary\"&gt;\r\n                    \u3000&lt;input type=\"hidden\" name=\"action\" value=\"ok\"&gt;\r\n                &lt;\/td&gt;\r\n\r\n            &lt;\/tr&gt;\r\n\r\n        &lt;\/table&gt;\r\n\r\n    &lt;\/form&gt;\r\n@endsection\r\n<\/pre>\n<p>\u3053\u308c\u3092\u3001\u5b9f\u884c\u3057\u305f\u3068\u304d\u306b\u767b\u9332\u3059\u308b\u51e6\u7406\u3092\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>Route::post(&#8216;\/admin\/entry&#8217;, &#8216;AdminEntryController@complete&#8217;);<\/p>\n<p>\u6700\u521d\u306e\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u3001get\u3067\u66f8\u3044\u3066\u307e\u3057\u305f\u304c\u3001\u6295\u7a3f\u306e\u51e6\u7406\u306fpost\u3067\u6e21\u3059\u3053\u3068\u3067\u51e6\u7406\u3092\u5206\u5c90\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>post\u3067URL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u306b\u306f\u3001\u540c\u3058\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u3082\u7570\u306a\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u51e6\u7406\u3067\u306fcomplete\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<h3>complete\u30e1\u30bd\u30c3\u30c9\u306e\u5b9a\u7fa9<\/h3>\n<p>complete\u30e1\u30bd\u30c3\u30c9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true \" >\r\n    public function complete(Request $request)\r\n    {\r\n        $post = new Post();\r\n\r\n        $post-&gt;title = $request-&gt;input('title');\r\n        $post-&gt;body = $request-&gt;input('body');\r\n\r\n        \/\/\u30bb\u30fc\u30d6\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u7d99\u627f\u3057\u3066\u3044\u308b\u89aa\u30af\u30e9\u30b9\u306e\u30e2\u30c7\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\r\n        $post-&gt;save();\r\n\r\n        return view('admin.complete');\r\n    }<\/pre>\n<p>$post = new Post();<\/p>\n<p>\u3067\u3001\u6700\u521d\u306b\u4f5c\u6210\u3057\u305fPost\u30e2\u30c7\u30eb\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u8ff0\u3067\u884c\u3046\u306b\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5148\u982d\u306b<\/p>\n<p>use App\\Post;<\/p>\n<p>\u3092\u8ffd\u8a18\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8ffd\u8a18\u304c\u306a\u3044\u5834\u5408<\/p>\n<p>$post = new App\\Post();<\/p>\n<p>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u5909\u6570\u306b\u30dd\u30b9\u30c8\u3067\u6295\u3052\u3089\u308c\u305f\u5024\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u304b\u3089\u53d6\u5f97\u3057\u3066\u3001save\u30e1\u30bd\u30c3\u30c9\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u5f8c\u306f\u3001\u5b8c\u4e86\u753b\u9762\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u51e6\u7406\u306f\u304b\u306a\u308a\u30b7\u30f3\u30d7\u30eb\u3067\u3059\u304c\u3001Laravel\u72ec\u7279\u306e\u8a18\u6cd5\u306a\u306e\u3067\u3001\u899a\u3048\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u30a8\u30e9\u30fc\u304c\u306a\u3051\u308c\u3070\u3001\u3053\u308c\u3067\u30d5\u30a9\u30fc\u30e0\u306e\u4fdd\u5b58\u304c\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u6295\u7a3f\u306e\u30b5\u30a4\u30c8\u3078\u306e\u8868\u793a<\/h2>\n<p>\u4eca\u5ea6\u306f\u30b5\u30a4\u30c8\u306b\u8868\u793a\u3059\u308b\u51e6\u7406\u3092\u66f8\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u4e00\u89a7\u753b\u9762\u3068\u8a73\u7d30\u753b\u9762\u306b\u5206\u3051\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u5fc5\u8981\u306a\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\/\/\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u3067\u4e00\u89a7\u8868\u793a<br \/>\nRoute::get(&#8216;\/&#8217;, &#8216;PostsController@index&#8217;);<\/p>\n<p>\/\/\u8a73\u7d30\u30da\u30fc\u30b8\u306e\u8868\u793a<br \/>\nRoute::get(&#8216;\/post\/{id}&#8217;, &#8216;PostsController@detail&#8217;);<\/p>\n<p>\u3053\u306e\u4f8b\u3067\u306f\u3001\u30da\u30fc\u30b8\u306e\u8868\u793a\u51e6\u7406\u3092\u3001PostsController\u3068\u3044\u3046\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306b\u4e00\u89a7\u3092\u8868\u793a\u3059\u308b\uff08index\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u884c\uff09\u51e6\u7406\u3001\u8a73\u7d30\u30da\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u51e6\u7406\uff08detail\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u884c\uff09\u306b\u5206\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>PostController\u306f\u3001\u6700\u521d\u3068\u540c\u3058\u304f<\/p>\n<p>php artisan make:controller PostController<\/p>\n<p>\u3067\u4f5c\u6210\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u304c\u3001PostsController\u30af\u30e9\u30b9\u306b\u5b9a\u7fa9\u3057\u305f\u3001\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u3068\u8a73\u7d30\u30da\u30fc\u30b8\u306e\u8868\u793a\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" >\r\n\r\nuse App\\Post;\r\n\r\nclass PostsController extends Controller\r\n{\r\n    \/\/\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\r\n    public function index(Request $request) {\r\n\r\n        $posts = Post::where('delete_flg' , '&lt;&gt;', '1')\r\n            -&gt;get();\r\n\r\n        return view('index', compact('posts'));\r\n\r\n    }\r\n\r\n\r\n    \/\/\u30d6\u30ed\u30b0\u8a73\u7d30\u8a18\u4e8b\u3092\u8868\u793a\u3059\u308b\r\n    public function detail(Request $request, $id) {\r\n\r\n        $post = Post::find($id);\r\n\r\n        return view('post', compact('post'));\r\n\r\n    }\r\n}<\/pre>\n<p>index\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001\u524a\u9664\u30d5\u30e9\u30b0\u304c1\u3067\u306a\u304f\u8a18\u4e8b\u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306a\u51e6\u7406\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>detail\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001URL\u304b\u3089\u53d6\u5f97\u3057\u305f\u30e6\u30fc\u30b6ID\u306b\u8a72\u5f53\u3059\u308b\u8a18\u4e8b\u3092\u53d6\u5f97\u3057\u3066\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u305d\u308c\u305e\u308c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" title=\"index\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\" >@extends('layout')\r\n\r\n@section('title', \"\u65b0\u7740\u8a18\u4e8b\")\r\n\r\n@section('content')\r\n\r\n    &lt;ul&gt;\r\n\r\n    @foreach ($posts as $post)\r\n        &lt;li&gt;&lt;a href=\"\/post\/{{ $post-&gt;id }}\"&gt;{{ $post-&gt;title }}({{ $post-&gt;created_at-&gt;format('Y\u5e74m\u6708d\u65e5') }})&lt;\/a&gt;&lt;\/li&gt;\r\n    @endforeach\r\n\r\n    &lt;\/ul&gt;\r\n\r\n@endsection\r\n<\/pre>\n<pre class=\"lang:default decode:true \" >@extends('layout')\r\n\r\n@section('title', $post-&gt;title)\r\n\r\n@section('content')\r\n\r\n    &lt;p class=\"text-right\"&gt;{{ $post-&gt;created_at-&gt;format('Y\u5e74m\u6708d\u65e5') }}&lt;\/p&gt;\r\n\r\n    &lt;div class=\"contents\"&gt;\r\n    {!! nl2br(e($post-&gt;body)) !!}\r\n    &lt;\/div&gt;\r\n\r\n@endsection\r\n<\/pre>\n<h2>\u8a18\u4e8b\u306e\u7de8\u96c6\u3001\u524a\u9664<\/h2>\n<p>\u6700\u5f8c\u306b\u3001\u7ba1\u7406\u753b\u9762\u304b\u3089\u8a18\u4e8b\u306e\u7de8\u96c6\u3068\u524a\u9664\u3092\u884c\u3048\u308b\u3088\u3046\u306a\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u30b1\u30fc\u30b9\u3067\u306f\u3001\u30eb\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u307e\u305a\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u51e6\u7406\u3092\u8ffd\u8a18\u3057\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true \" >Route::get('\/admin\/edit\/{id}', 'AdminEntryController@edit');\r\n\r\nRoute::post('\/admin\/edit\/{id}', 'AdminEntryController@store');\r\n\r\nRoute::get('\/admin\/delete\/{id}', 'AdminEntryController@delete');\r\n\r\n<\/pre>\n<p>\u7de8\u96c6\u753b\u9762\u306f\u3001\u540c\u3058URL\u3067\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u304c\u3001\u6700\u521d\u306fget\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3001\u7de8\u96c6\u5b8c\u4e86\u51e6\u7406\u306fpost\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u3067\u5b9f\u884c\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3092\u5206\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" >\/\/\u8a18\u4e8b\u3092\u7de8\u96c6\u3059\u308b\r\n    public function edit(Request $request, $id) {\r\n\r\n        $post = Post::find($id);\r\n\r\n        return view('admin.edit', compact('post'));\r\n\r\n    }\r\n\r\n    \/\/\u8a18\u4e8b\u306e\u4fee\u6b63\u3092\u5b8c\u4e86\u3059\u308b\r\n    public function store(Request $request , $id)\r\n    {\r\n        $post = Post::find($id);\r\n\r\n        $post-&gt;title = $request-&gt;input('title');\r\n        $post-&gt;body = $request-&gt;input('body');\r\n\r\n        \/\/\u30bb\u30fc\u30d6\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u7d99\u627f\u3057\u3066\u3044\u308b\u89aa\u30af\u30e9\u30b9\u306e\u30e2\u30c7\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\r\n        $post-&gt;save();\r\n\r\n        return view('admin.complete');\r\n    }\r\n\r\n    \/\/\u8a18\u4e8b\u306e\u524a\u9664\u3092\u5b8c\u4e86\u3059\u308b\r\n    public function delete(Request $request , $id)\r\n    {\r\n        $post = Post::find($id);\r\n\r\n        $post-&gt;delete_flg = 1;\r\n\r\n        \/\/\u30bb\u30fc\u30d6\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u7d99\u627f\u3057\u3066\u3044\u308b\u89aa\u30af\u30e9\u30b9\u306e\u30e2\u30c7\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\r\n        $post-&gt;save();\r\n\r\n        return view('admin.delete');\r\n    }<\/pre>\n<p>\u524a\u9664\u51e6\u7406\u306f\u3001delete\u51e6\u7406\u3092\u4f7f\u3046\u306e\u3067\u306f\u306a\u304f\u3001\u4e00\u5fdc\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f\u6b8b\u3057\u3066\u304a\u304d\u305f\u3044\u306e\u3067\u3001delete_flg\u3092\uff11\u306b\u3059\u308b\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u51e6\u7406\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7ba1\u7406\u753b\u9762\u306e\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306eblede\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3082\u3001\u8a18\u4e8b\u4e00\u89a7\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u304a\u304d\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true \" >@extends('admin.parent')\r\n\r\n@section('title', '\u6295\u7a3f\u7ba1\u7406')\r\n\r\n@section('content')\r\n&lt;div class=\"text-right\"&gt;\r\n    &lt;input type=\"submit\" name=\"submit\" value=\"\u65b0\u898f\u767b\u9332\" class=\"btn btn-primary\" onclick=\"location.href='\/admin\/entry\/'\" \/&gt;\r\n&lt;\/div&gt;\r\n\r\n    &lt;div class=\"content\"&gt;\r\n\r\n        &lt;table&gt;\r\n            @foreach ($posts as $post)\r\n                &lt;tr&gt;&lt;td&gt;&lt;a href=\"\/post\/{{ $post-&gt;id }}\"&gt;{{ $post-&gt;title }}&lt;\/a&gt;&lt;\/td&gt;&lt;td&gt;&lt;input type=\"submit\" value=\"\u7de8\u96c6\" onclick=\"location.href='\/admin\/edit\/{{ $post-&gt;id }}'\" &gt;&lt;\/td&gt;&lt;td&gt;&lt;input type=\"submit\" value=\"\u524a\u9664\" onclick=\"location.href='\/admin\/delete\/{{ $post-&gt;id }}'\" &gt;&lt;\/td&gt;&lt;\/tr&gt;\r\n            @endforeach\r\n        &lt;\/table&gt;\r\n\r\n    &lt;\/div&gt;\r\n\r\n@endsection<\/pre>\n<h2>\u30d8\u30eb\u30d1\u30fc\u3092\u4f7f\u3063\u3066\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u8a18\u8ff0\u3092\u7c21\u7d20\u5316\u3059\u308b<\/h2>\n<p>\u4e0a\u8a18\u306e\u4f8b\u3067\u306f\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u8a18\u8ff0\u304c\u3084\u3084\u3054\u3061\u3083\u3054\u3061\u3083\u3057\u3066\u3044\u307e\u3059\u304c\u3001<br \/>\n\u30d8\u30eb\u30d1\u30fc\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u3067\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u8a18\u8ff0\u3092\u3059\u3063\u304d\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u8a73\u3057\u304f\u306f\u3001\u4ee5\u4e0b\u306e\u30b5\u30a4\u30c8\u306b\u89e3\u8aac\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/laravel10.wordpress.com\/2015\/03\/08\/%E5%88%9D%E3%82%81%E3%81%A6%E3%81%AElaravel-5-16-form%E3%81%AE%E4%BD%9C%E6%88%90\/\">\u521d\u3081\u3066\u306eLaravel 5.6 : (16) Form\u306e\u4f5c\u6210 &#8211; \u30e9\u30e9\u5e33<\/a><\/p>\n<p>composer require &#8220;laravelcollective\/html&#8221;:&#8221;^5.7.0&#8243;<\/p>\n<p>\u3053\u308c\u3067\u30d8\u30eb\u30d1\u30fc\u304c\u5c0e\u5165\u3067\u304d\u308b\u306e\u3067\u3001\u3053\u308c\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"Null\">\r\n@extends('layout')\r\n \r\n@section('content')\r\n    <h1>Write a New Article<\/h1>\r\n \r\n    <hr\/>\r\n \r\n    {!! Form::open() !!}\r\n        <div class=\"form-group\">\r\n            {!! Form::label('title', 'Title:') !!}\r\n            {!! Form::text('title', null, ['class' => 'form-control']) !!}\r\n        <\/div>\r\n        <div class=\"form-group\">\r\n            {!! Form::label('body', 'Body:') !!}\r\n            {!! Form::textarea('body', null, ['class' => 'form-control']) !!}\r\n        <\/div>\r\n        <div class=\"form-group\">\r\n            {!! Form::label('published_at', 'Publish On:') !!}\r\n            {!! Form::input('date', 'published_at', date('Y-m-d'), ['class' => 'form-control']) !!}\r\n        <\/div>    \r\n        <div class=\"form-group\">\r\n            {!! Form::submit('Add Article', ['class' => 'btn btn-primary form-control']) !!}\r\n        <\/div>\r\n    {!! Form::close() !!}\r\n@endsection\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u3067\u7c21\u5358\u306a\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u308b\u306e\u306f\u57fa\u790e\u4e2d\u306e\u57fa\u790e\u3067\u3059\u304c\u3001\u6163\u308c\u306a\u3044\u3046\u3061\u306f\u4f55\u7b87\u6240\u304b\u3064\u307e\u3065\u3044\u305f\u306e\u3067\u8a18\u9332\u306b\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \u30d5\u30a9\u30fc\u30e0\u306e\u4ed5\u69d8 \u8a18\u4e8b\u3092\u6295\u7a3f\u3057\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b \u4ef6\u540d(\u30bf\u30a4\u30c8\u30eb)\u3068\u672c\u6587\u3092\u5165\u529b\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[140,131],"tags":[],"class_list":["post-9879","post","type-post","status-publish","format-standard","hentry","category-laravel","category-131"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9879"}],"version-history":[{"count":1,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9879\/revisions"}],"predecessor-version":[{"id":9880,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9879\/revisions\/9880"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}