{"id":1317,"date":"2018-09-28T04:30:20","date_gmt":"2018-09-27T19:30:20","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=1317"},"modified":"2018-10-23T03:36:47","modified_gmt":"2018-10-22T18:36:47","slug":"laravel%e3%81%a7%e4%ba%88%e7%b4%84%e3%81%8c%e5%85%a5%e3%81%a3%e3%81%a6%e3%81%84%e3%82%8b%e3%81%8b%e3%83%81%e3%82%a7%e3%83%83%e3%82%af%e3%81%99%e3%82%8b%e7%8b%ac%e8%87%aa%e3%83%90%e3%83%aa%e3%83%87","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=1317","title":{"rendered":"Laravel\u3067\u4e88\u7d04\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u5b9f\u306f\u73fe\u5728\u3082Laravel\u6700\u65b0\u7248\u3092\u4f7f\u3063\u305f\u958b\u767a\u3092\u884c\u3063\u3066\u3044\u308b\u6700\u4e2d\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u958b\u767a\u306e\u4e2d\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u5b58\u5728\u3057\u306a\u3044\u3061\u3087\u3063\u3068\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u305d\u3053\u306f\u3055\u3059\u304cLaravel\u3067\u3059\u3002<\/p>\n<p>\u305d\u3093\u306a\u30a4\u30ec\u30ae\u30e5\u30e9\u30fc\u306a\u72b6\u6cc1\u306b\u3082\u5bfe\u5fdc\u3067\u304d\u308b\u3088\u3046\u306b\u300c\u72ec\u81ea\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u300d\u3092\u5b9a\u7fa9\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30fb\u30fb\u30fb\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3063\u3066<strong>\u300c\u3042\u308b\u90e8\u5c4b\u306e\u3001\u3042\u308b\u6642\u9593\u306b\u4e88\u7d04\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u300d<\/strong>\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-731 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/07\/panda_2.png\" alt=\"\" width=\"149\" height=\"120\" \/><\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4f8b\u3048\u3070\u3001\u3042\u308b\u5c45\u9152\u5c4b\u300c\u3088\u3044\u3069\u308c\uff08\u4eee\u540d\uff09\u300d\u306e\u300c\u685c\u306e\u9593\uff08\u90e8\u5c4b\u756a\u53f7\uff1a1\uff09\u300d\u304c\u6b21\u306e\u6642\u9593\u5e2f\u306b\u7a7a\u3044\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p><strong>2018\u5e7410\u67081\u65e5\u300019\u664200\u5206 \u301c 23\u664200\u5206<\/strong><\/p>\n<p>\u3067\u306f\u3001\u5c11\u3057\u9577\u3044\u3067\u3059\u304c\u3072\u3068\u3064\u305a\u3064\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>\u4e88\u7d04\u30c6\u30fc\u30d6\u30eb\u3092\u3064\u304f\u308b<\/h1>\n<p>\u307e\u305a\u4e88\u7d04\u3092\u4fdd\u5b58\u3057\u3066\u304a\u304f\u30c6\u30fc\u30d6\u30eb\u304c\u306a\u3044\u3068\u59cb\u307e\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3053\u3067<code>reservations<\/code>\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u3092\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan make:migration create_reservations_table<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u3001<\/p>\n<p><code>\/database\/migrations\/<\/code>\u30d5\u30a9\u30eb\u30c0\u306b<code>****_**_**_******_create_reservations_table.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066<code>up()<\/code>\u5185\u306b\u5fc5\u8981\u306a\u30d5\u30a3\u30fc\u30eb\u30c9\u9805\u76ee\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>public function up()\r\n{\r\n    Schema::create('reservations', function (Blueprint $table) {\r\n        $table-&gt;increments('id');\r\n<strong>        $table-&gt;unsignedInteger('room_id')-&gt;comment('\u90e8\u5c4b\u756a\u53f7');<\/strong>\r\n<strong>        $table-&gt;dateTime('start_at')-&gt;comment('\u958b\u59cb\u6642\u9593');<\/strong>\r\n<strong>        $table-&gt;dateTime('end_at')-&gt;comment('\u7d42\u4e86\u6642\u9593');<\/strong>\r\n        $table-&gt;timestamps();\r\n    });\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u3066\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>php artisan migrate<\/strong><\/pre>\n<p>\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30c6\u30fc\u30d6\u30eb\u304c\u3067\u304d\u307e\u3059\u3002\uff08\u3061\u306a\u307f\u306b<code>comment()<\/code>\u3092\u4f7f\u3063\u3066\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u8aac\u660e\u3092\u8ffd\u52a0\u3057\u3066\u304a\u304f\u3068\u3001\u4fdd\u5b88\u7ba1\u7406\u304c\u697d\u306b\u306a\u308a\u307e\u3059\u3088\uff01\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1318\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_table_structure.png\" alt=\"\" width=\"349\" height=\"525\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_table_structure.png 349w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_table_structure-199x300.png 199w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/p>\n<h1>\u9001\u4fe1\u30d5\u30a9\u30fc\u30e0\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u6b21\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u3053\u306e\u30d5\u30a9\u30fc\u30e0\u304b\u3089\u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u3001\u3059\u3067\u306b\u4e88\u7d04\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u306a\u306e\u3067\u3001Ajax\u306f\u4f7f\u308f\u305a\u30ce\u30fc\u30de\u30eb\u306aHTML\u306e\u9001\u4fe1\u30d5\u30a9\u30fc\u30e0\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u4e88\u7d04\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u4ee5\u4e0b\uff12\u3064\u306eRoute\u3092<code>\/routes\/web.php<\/code>\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>Route::<strong>get<\/strong>('reservation', 'ReservationController@<strong>create<\/strong>'); \/\/ \u5165\u529b\u30d5\u30a9\u30fc\u30e0\r\nRoute::<strong>post<\/strong>('reservation', 'ReservationController@<strong>store<\/strong>'); \/\/ \u9001\u4fe1\u5148<\/pre>\n<p>\u3053\u306e\u307e\u307e\u3067\u306f<code>ReservationController<\/code>\u304c\u5b58\u5728\u305b\u305a\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3082\u4f5c\u6210\u3057\u3001\u5fc5\u8981\u306a\u30e1\u30bd\u30c3\u30c9<code>create<\/code>\u3068<code>store<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:controller ReservationController<\/strong><\/pre>\n<pre>class <strong>ReservationController<\/strong> extends Controller\r\n{\r\n    <strong>public function create() {<\/strong>\r\n\r\n<strong>        return view('reservation');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n    <strong>public function store() {<\/strong>\r\n\r\n        \/\/ \u3053\u3053\u3067\u4e88\u7d04\u30c7\u30fc\u30bf\u4fdd\u5b58\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3055\u3089\u306b\u3001\u3053\u306e\u307e\u307e\u3067\u306f\u30d3\u30e5\u30fc\u304c\u5b58\u5728\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001<code>\/resources\/views<\/code>\u30d5\u30a9\u30eb\u30c0\u306b<code>reservation.blade.php<\/code>\u3092\u4f5c\u6210\u3057\u3066\u3053\u3053\u306b\u9001\u4fe1\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u306f\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u672c\u6765\u306flayouts\u306a\u3069\u3092\u4f7f\u3046\u3079\u304d\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u306a\u306e\u3067\u76f4\u306bHTML\u30bf\u30b0\u306a\u3069\u3092\u66f8\u304d\u8fbc\u3093\u3067\u3044\u307e\u3059\uff09<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n    <strong>&lt;form method=\"POST\" action=\"\/reservation\"&gt;<\/strong>\r\n<strong>        @csrf<\/strong>\r\n<strong>        &lt;select name=\"room_id\"&gt;<\/strong>\r\n<strong>            &lt;option&gt;&lt;\/option&gt;<\/strong>\r\n<strong>            &lt;option selected value=\"1\"&gt;\u685c\u306e\u9593&lt;\/option&gt;<\/strong>\r\n<strong>            &lt;option value=\"2\"&gt;\u677e\u306e\u9593&lt;\/option&gt;<\/strong>\r\n<strong>            &lt;option value=\"3\"&gt;\u7af9\u306e\u9593&lt;\/option&gt;<\/strong>\r\n<strong>            &lt;option value=\"4\"&gt;\u6885\u306e\u9593&lt;\/option&gt;<\/strong>\r\n<strong>        &lt;\/select&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>        &lt;input type=\"date\" name=\"start_date\" value=\"2018-10-01\"&gt;<\/strong>\r\n<strong>        &lt;input type=\"time\" name=\"start_time\" value=\"19:00\"&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>        &lt;input type=\"date\" name=\"end_date\" value=\"2018-10-01\"&gt;<\/strong>\r\n<strong>        &lt;input type=\"time\" name=\"end_time\" value=\"23:00\"&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>        &lt;button type=\"submit\"&gt;\u4e88\u7d04\u3059\u308b&lt;\/button&gt;<\/strong>\r\n<strong>    &lt;\/form&gt;<\/strong>\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u30da\u30fc\u30b8\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1319\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create.png\" alt=\"\" width=\"236\" height=\"140\" \/><\/p>\n<h1>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u6e96\u5099\u3092\u3059\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u306e\u30d5\u30a9\u30fc\u30e0\u304b\u3089\u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b<code>ReservationRequest<\/code>\u3068\u3044\u3046\u5c02\u7528\u306e\u30d5\u30a9\u30fc\u30e0\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:request ReservationRequest<\/strong><\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001<code>\/app\/Http\/Requests\/<\/code>\u30d5\u30a1\u30eb\u30c0\u306b<code>ReservationRequest.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u3067\u304d\u3066\u3044\u308b\u306e\u3067\u3001<code>ReservationController<\/code>\u306e<code>store<\/code>\u30e1\u30bd\u30c3\u30c9\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>public function store(<strong>ReservationRequest $request<\/strong>) {\r\n\r\n    \/\/ \u3053\u3053\u3067\u4e88\u7d04\u30c7\u30fc\u30bf\u4fdd\u5b58\r\n\r\n}<\/pre>\n<p>\uff08\u3061\u306a\u307f\u306b\u4ee5\u4e0b\u306e\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u3092\u7701\u7565\u3057\u3066\u3044\u308b\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre><strong>use App\\Http\\Requests\\ReservationRequest;<\/strong><\/pre>\n<p>\u3067\u306f\u3001\u3053\u308c\u3067\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f7f\u3046\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<code>ReservationRequest.php<\/code>\u3092\u958b\u3044\u3066<code>authorize()<\/code>\u3068<code>all()<\/code>\u3001<code>rules()<\/code>\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>public function <strong>authorize()<\/strong>\r\n{\r\n    return <strong>true<\/strong>;\r\n}<\/pre>\n<pre>public function <strong>all($keys = null)<\/strong>\r\n{\r\n<strong>    $results = parent::all($keys);<\/strong>\r\n<strong>    $results['start_at'] = $results['start_date'] .' '. $results['start_time'];<\/strong>\r\n<strong>    $results['end_at'] = $results['end_date'] .' '. $results['end_time'];<\/strong>\r\n<strong>    return $results;<\/strong>\r\n}<\/pre>\n<p><code>all()<\/code>\u5185\u3067\u306f\u958b\u59cb\u65e5\u6642\u3092<code>$this-&gt;start_at<\/code>\u3001\u7d42\u4e86\u65e5\u6642\u3092<code>$this-&gt;end_at<\/code>\u3068\u3057\u3066\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre>public function <strong>rules()<\/strong>\r\n{\r\n    return [\r\n        'room_id' =&gt; 'required', \/\/ \u672c\u6765\u306fexists\u3092\u5165\u308c\u308b\u3079\u304d\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u5272\u611b\u3057\u307e\u3059\r\n        'start_date' =&gt; 'required|date',\r\n        'start_time' =&gt; 'required|date_format:H:i',\r\n        'end_date' =&gt; 'required|date',\r\n        'end_time' =&gt; 'required|date_format:H:i',\r\n<strong>        'start_at' =&gt; [<\/strong>\r\n<strong>            new ReservationRule(<\/strong>\r\n<strong>                $this-&gt;room_id, \/\/ \u90e8\u5c4b\u756a\u53f7<\/strong>\r\n<strong>                $this-&gt;start_at, \/\/ \u958b\u59cb\u65e5\u6642<\/strong>\r\n<strong>                $this-&gt;end_at \/\/ \u7d42\u4e86\u65e5\u6642<\/strong>\r\n<strong>            )<\/strong>\r\n<strong>        ]<\/strong>\r\n    ];\r\n}<\/pre>\n<p>\u305d\u3057\u3066\u3001<code>rules()<\/code>\u3067\u306f<code>new ReservationRule()<\/code>\u3068\u3044\u3046\u90e8\u5206\u304c\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306b\u306a\u308a\u307e\u3059\u3002\u6b21\u306f\u3053\u306e\u90e8\u5206\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u3061\u306a\u307f\u306b\u3001\u305d\u306e\u4ed6\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f<a href=\"https:\/\/blog.capilano-fw.com\/?p=341\">\u516853\u7a2e\u985e\uff01Laravel 5.6\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5b9f\u4f8b<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u30e2\u30c7\u30eb\u3092\u4f5c\u308b<\/h1>\n<p>\u3067\u306f\u3001\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u5185\u90e8\u3067\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3001\u4e8b\u524d\u306b<code>Reservation<\/code>\u30e2\u30c7\u30eb\u3092\u4f5c\u3063\u3066\u300c\u4e88\u7d04\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u300d\u72ec\u81ea\u30b9\u30b3\u30fc\u30d7\uff08where\u30e1\u30bd\u30c3\u30c9\uff09\u3092\u4f5c\u3063\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30e2\u30c7\u30eb\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:model Reservation<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001<code>app\/Reservation.php<\/code>\u3092\u958b\u3044\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>scopeWhereHasReservation()<\/code>\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nnamespace App;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Reservation extends Model\r\n{\r\n    protected $guarded = ['id'];\r\n\r\n    \/\/ Scope\r\n    <strong>public function scopeWhereHasReservation($query, $start, $end) {<\/strong>\r\n\r\n<strong>        $query-&gt;where(function($q) use($start, $end) { \/\/ \u89e3\u8aac - 1<\/strong>\r\n\r\n<strong>            $q-&gt;where('start_at', '&gt;=', $start)<\/strong>\r\n<strong>                -&gt;where('start_at', '&lt;', $end);<\/strong>\r\n\r\n<strong>        })<\/strong>\r\n<strong>        -&gt;orWhere(function($q) use($start, $end) { \/\/ \u89e3\u8aac - 2<\/strong>\r\n\r\n<strong>            $q-&gt;where('end_at', '&gt;', $start)<\/strong>\r\n<strong>                -&gt;where('end_at', '&lt;=', $end);<\/strong>\r\n\r\n<strong>        })<\/strong>\r\n<strong>        -&gt;orWhere(function($q) use ($start, $end) { \/\/ \u89e3\u8aac - 3<\/strong>\r\n\r\n<strong>            $q-&gt;where('start_at', '&lt;', $start)<\/strong>\r\n<strong>                -&gt;where('end_at', '&gt;', $end);<\/strong>\r\n\r\n<strong>        });<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3061\u306a\u307f\u306b\u30b9\u30b3\u30fc\u30d7\u306e\u4e2d\u3067\u306f\u3001\u4ee5\u4e0b\uff13\u30d1\u30bf\u30fc\u30f3\u3092or\u691c\u7d22\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3044\u6642\u9593\u5e2f\u306e\u4e2d\u304b\u3089\u59cb\u307e\u308b\u4e88\u7d04\u304c\u3042\u308b<\/li>\n<li>\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3044\u6642\u9593\u5e2f\u306e\u4e2d\u3067\u7d42\u308f\u308b\u4e88\u7d04\u304c\u3042\u308b<\/li>\n<li>\u30c1\u30a7\u30c3\u30af\u3057\u305f\u3044\u6642\u9593\u5e2f\u306e\u4e2d\u306b\u3059\u3063\u307d\u308a\u5165\u308b\u4e88\u7d04\u304c\u3042\u308b<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u3001\u7d75\u3067\u7d39\u4ecb\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d1\u30bf\u30fc\u30f3\uff11<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1326\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/has_reservation_1.png\" alt=\"\" width=\"539\" height=\"514\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/has_reservation_1.png 539w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/has_reservation_1-300x286.png 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/p>\n<p>\u30d1\u30bf\u30fc\u30f3\uff12<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1326\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/has_reservation_2.png\" alt=\"\" width=\"539\" height=\"514\" \/><\/p>\n<p>\u30d1\u30bf\u30fc\u30f3\uff13<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1326\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/has_reservation_3.png\" alt=\"\" width=\"539\" height=\"514\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u30b9\u30b3\u30fc\u30d7\u3092\u8a2d\u5b9a\u3059\u308b\u3068<code>whereHasReservation()<\/code>\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u5f15\u6570\u306b\u958b\u59cb\u65e5\u6642\u3068\u7d42\u4e86\u65e5\u6642\u3092\u5165\u308c\u308b\u3060\u3051\u3067\u300c\u305d\u306e\u6642\u9593\u5e2f\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u300d\u3068\u3044\u3046\u6761\u4ef6\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\\App\\Reservation::<strong>whereHasReservation($start_at, $end_at)<\/strong>-&gt;get();<\/pre>\n<p>\u203b \u306a\u304a\u30e2\u30c7\u30eb\u5185\u306b\u306f\u4fdd\u5b58\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u306a\u3044\u3088\u3046\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3082\u8ffd\u52a0\u3057\u3066\u3044\u308b\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>protected $guarded = ['id'];<\/strong><\/pre>\n<h1>\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b<\/h1>\n<p>\u3084\u3063\u3068\u672c\u984c\u306b\u305f\u3069\u308a\u3064\u304d\u307e\u3057\u305f\uff08\u7b11\uff09<br \/>\n\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>php artisan make:rule ReservationRule<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001<code>\/app\/Rules\/ReservationRule.php<\/code>\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u3001\u3053\u306e\u4e2d\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067<code>ReservationRequest<\/code>\u304b\u3089\u53d7\u3051\u53d6\u308b\u30c7\u30fc\u30bf\u3092\u30e1\u30f3\u30d0\u5909\u6570\u306b\u683c\u7d0d\u3057\u3001\u3069\u3053\u304b\u3089\u3067\u3082\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>private <strong>$_room_id,<\/strong>\r\n<strong>        $_start_at,<\/strong>\r\n<strong>        $_end_at;<\/strong>\r\n\r\npublic function __construct(<strong>$room_id, $start_at, $end_at<\/strong>)\r\n{\r\n<strong>    $this-&gt;_room_id = $room_id;<\/strong>\r\n<strong>    $this-&gt;_start_at = $start_at;<\/strong>\r\n<strong>    $this-&gt;_end = $end_at;<\/strong>\r\n}<\/pre>\n<p>\u6b21\u306b<code>passes()<\/code>\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<br \/>\n\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3067<code>true<\/code>\u3092\u8fd4\u305b\u3070\u3001\u3053\u306e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u901a\u904e\u3057\u307e\u3059\u3002<\/p>\n<pre>public function passes($attribute, $value)\r\n{\r\n<strong>    return \\App\\Reservation::where('room_id', $this-&gt;_room_id)<\/strong>\r\n<strong>        -&gt;whereHasReservation($this-&gt;_start_at, $this-&gt;_end)<\/strong>\r\n<strong>        -&gt;doesntExist();<\/strong>\r\n}<\/pre>\n<p>\u305d\u306e\u305f\u3081\u3001<code>doesntExist()<\/code>\u3067\u3001\u305d\u306e\u4ed6\u306e\u30c7\u30fc\u30bf\u304c<span style=\"text-decoration: underline;\">\u5b58\u5728\u3057\u3066\u3044\u306a\u3044\u306a\u3089<\/span><code>true<\/code>\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u305b\u3063\u304b\u304f\u306a\u306e\u3067<code>message()<\/code>\u3067\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3082\u5909\u66f4\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>public function message()\r\n{\r\n    return <strong>'\u4ed6\u306e\u4e88\u7d04\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002'<\/strong>;\r\n}<\/pre>\n<p>\u3053\u308c\u3067\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u306f\u5b8c\u6210\u3067\u3059\u3002<\/p>\n<h1>\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u6700\u5f8c\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n<code>ReservationController<\/code>\u306e<code>store()<\/code>\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3059\u308b\u30b3\u30fc\u30c9\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>\\App\\Reservation::create([<\/strong>\r\n<strong>    'room_id' =&gt; $request-&gt;room_id,<\/strong>\r\n<strong>    'start_at' =&gt; $request-&gt;start_at,<\/strong>\r\n<strong>    'end_at' =&gt; $request-&gt;end_at<\/strong>\r\n<strong>]);<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u4fdd\u5b58\u3057\u305f\u5f8c\u306f<code>back()<\/code>\u3068<code>with()<\/code>\u3092\u4f7f\u3063\u3066\u5b8c\u4e86\u30e1\u30c3\u30bb\u30fc\u30b8\u3068\u3068\u3082\u306b\u5143\u30da\u30fc\u30b8\u3078\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>return back()-&gt;with('result', '\u4e88\u7d04\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3002');<\/strong><\/pre>\n<h1>\u6210\u529f\uff06\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b<\/h1>\n<p>\u4e0a\u306e\u4f5c\u696d\u3067\u3001<code>reservation.blade.php<\/code>\u306b\u9001\u4fe1\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u308a\u307e\u3057\u305f\u304c\u3001\u307e\u3060\u3053\u3053\u306b\u306f\u4ee5\u4e0b\uff12\u3064\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306f\u306a\u3063\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u3001\u3053\u308c\u3089\u3092\u4f5c\u3063\u3066\u304b\u3089\u6700\u5f8c\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u5b9f\u969b\u306b\u9001\u4fe1\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u4e88\u7d04\u304c\u6210\u529f\u3057\u305f\u6642\u306e\u5b8c\u4e86\u30e1\u30c3\u30bb\u30fc\u30b8<\/li>\n<li>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3067\u5931\u6557\u3057\u305f\u5834\u5408\u306e\u30a8\u30e9\u30fc<\/li>\n<\/ul>\n<pre>&lt;form method=\"POST\" action=\"\/reservation\"&gt;\r\n    @csrf\r\n\r\n    &lt;!-- \u5b8c\u4e86\u30e1\u30c3\u30bb\u30fc\u30b8 --&gt;\r\n<strong>    @if (session('result'))<\/strong>\r\n<strong>        &lt;div style=\"color:green;\"&gt;<\/strong>\r\n<strong>            {{ session('result') }}<\/strong>\r\n<strong>        &lt;\/div&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>    @endif<\/strong>\r\n\r\n    &lt;!-- \u7701\u7565 --&gt;\r\n\r\n    &lt;!-- \u30a8\u30e9\u30fc\u8868\u793a --&gt;\r\n<strong>    @if($errors-&gt;any())<\/strong>\r\n<strong>        &lt;div style=\"color:red;\"&gt;<\/strong>\r\n<strong>            \u3010\u30a8\u30e9\u30fc\u3011&lt;br&gt;&lt;br&gt;<\/strong>\r\n<strong>            @foreach ($errors-&gt;all() as $error)<\/strong>\r\n<strong>                {{ $error }}&lt;br&gt;<\/strong>\r\n<strong>            @endforeach<\/strong>\r\n<strong>        &lt;\/div&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>    @endif<\/strong>\r\n\r\n    &lt;button type=\"submit\"&gt;\u4e88\u7d04\u3059\u308b&lt;\/button&gt;\r\n&lt;\/form&gt;<\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u4ee5\u5916\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u306f\u65e5\u672c\u8a9e\u5316\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u65e5\u672c\u8a9e\u5316\u306e\u65b9\u6cd5\u306f<a href=\"https:\/\/blog.capilano-fw.com\/?p=289\">\u3010Laravel5.6\u3011\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u76f4\u5f8c\u306b\u3084\u308b\u3053\u3068\uff13\u70b9<\/a>\u306e\u300c\uff12\uff0e\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u300d\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u5b9f\u969b\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u767b\u9332\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u304a\u5f85\u305f\u305b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u5b9f\u969b\u306b\u4e88\u7d04\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1319\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create.png\" alt=\"\" width=\"236\" height=\"140\" \/><\/p>\n<p>\u3059\u3067\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3053\u306e\u307e\u307e\u300c\u4e88\u7d04\u30dc\u30bf\u30f3\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<br \/>\n\u3059\u308b\u3068\u30fb\u30fb\u30fb\uff1f\uff1f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1327\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create_success.png\" alt=\"\" width=\"234\" height=\"174\" \/><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\uff01<br \/>\n\u5ff5\u306e\u305f\u3081\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u5185\u3082\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1329\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_record.png\" alt=\"\" width=\"718\" height=\"361\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_record.png 718w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_record-300x151.png 300w\" sizes=\"auto, (max-width: 718px) 100vw, 718px\" \/><\/p>\n<p>\u3053\u3061\u3089\u3082\u554f\u984c\u306a\u304f\u3001\u90e8\u5c4b\u756a\u53f7\u3068\u4e88\u7d04\u6642\u523b\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u6b21\u306b\u4eca\u306e\u72b6\u614b\u3067\u518d\u5ea6\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u3059\u3067\u306b\u5148\u7d04\u304c\u3042\u308b\u306e\u3067\u3001\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u304c\u3046\u307e\u304f\u50cd\u3044\u3066\u3044\u308b\u306a\u3089\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1328\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create_error.png\" alt=\"\" width=\"244\" height=\"203\" \/><\/p>\n<p>\u3046\u307e\u304f\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306b\u958b\u59cb\u3068\u7d42\u4e86\u306e\u6642\u9593\u3060\u3051\u3092\u5909\u66f4\u3057\u3066\u9001\u4fe1\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1330\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create_2.png\" alt=\"\" width=\"240\" height=\"140\" \/><\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u3059\u3067\u306b19:00\u301c23:00\u3067\u4e88\u7d04\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u308b\u3079\u304d\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1328\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create_error.png\" alt=\"\" width=\"244\" height=\"203\" \/><\/p>\n<p>\u3046\u307e\u304f\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002\uff08\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u306a\u306e\u3067\u5165\u529b\u5024\u306f\u5143\u306b\u623b\u3063\u3066\u3044\u307e\u3059\uff09<\/p>\n<p>\u3067\u306f\u6700\u5f8c\u306b\u540c\u3058\u65e5\u4ed8\u306e\u540c\u3058\u6642\u9593\u5e2f\u3067\u3059\u304c\u3001\u9055\u3046\u90e8\u5c4b\u3092\u4e88\u7d04\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1331\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create_3.png\" alt=\"\" width=\"240\" height=\"140\" \/><\/p>\n<p>\u3082\u3061\u308d\u3093\u3001\u300c\u6885\u306e\u9593\u300d\u306b\u4e88\u7d04\u306f\u307e\u3060\uff11\u4ef6\u3082\u5165\u3063\u3066\u3044\u307e\u305b\u3093\u306e\u3067\u3001\u4e88\u7d04\u306f\u6210\u529f\u3059\u308b\u3079\u304d\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1327\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_create_success.png\" alt=\"\" width=\"234\" height=\"174\" \/><\/p>\n<p>\u3053\u308c\u3082\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\u3002<br \/>\nDB\u306b\u306f\u3001\u90e8\u5c4b\u756a\u53f7\u304c\u9055\u3046\u540c\u3058\u6642\u9593\u5e2f\u306e\u30c7\u30fc\u30bf\u304c\u8ffd\u52a0\u306b\u306a\u308a\u3001\u5168\uff12\u4ef6\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1332\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_record_2.png\" alt=\"\" width=\"721\" height=\"385\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_record_2.png 721w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/09\/reservation_record_2-300x160.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/p>\n<p>\u3053\u308c\u3067\u3001\u4eca\u56de\u306e\u4f5c\u696d\u306f\u7d42\u4e86\u3067\u3059\u3002<\/p>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01<\/p>\n<h1>\u4eca\u56de\u4f7f\u3063\u305f\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h1>\n<p>\u4eca\u56de\u306e\u8a18\u4e8b\u3067\u4f7f\u3063\u305f\u5168\u30b3\u30fc\u30c9\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3002\u7d30\u304b\u306a\u90e8\u5206\u306f\u5225\u9014\u5b9f\u88c5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u6839\u672c\u90e8\u5206\u306f\u5b8c\u4e86\u3057\u3066\u3044\u308b\u306e\u3067\u305c\u3072\u53c2\u8003\u306b\u3057\u3066\u3044\u305f\u3060\u3051\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=1334&amp;tmstv=1777528687\" rel=\"nofollow\" id=\"download-link-1334\" data-redirect=\"false\" >\n\tLaravel\u3067\u4e88\u7d04\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30fb\u5168\u30b3\u30fc\u30c9<\/a>\n\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u4e88\u7d04\u30c1\u30a7\u30c3\u30af\u3092\u3059\u308bLaravel\u306e\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3044\u3064\u3082\u611f\u3058\u3066\u3044\u308b\u3053\u3068\u3067\u3059\u304c\u3001\u304d\u3063\u3068\u4eca\u56de\u306e\u3088\u3046\u306b\u72ec\u81ea\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u304c\u3057\u3084\u3059\u3044Laravel\u306e\u5305\u5bb9\u529b\u304c\u4e16\u754c\u4e2d\u306e\u958b\u767a\u8005\u3092\u3068\u308a\u3053\u306b\u3057\u3066\u3044\u308b\u306e\u306f\u9593\u9055\u3044\u306a\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u3002^^<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u4f5c\u3063\u305f<code>whereHasReservation()<\/code>\u306a\u3069\u306e\u3088\u3046\u306a\u6c4e\u7528\u7684\u306b\u4f7f\u3048\u308b\u30e1\u30bd\u30c3\u30c9\u306f\u30c8\u30ec\u30a4\u30c8\u5316\u3057\u3066\u304a\u3051\u3070\u5f8c\u3067\u306a\u3093\u3069\u3067\u3082\u4f7f\u3048\u307e\u3059\u3057\u3001\u958b\u767a\u901f\u5ea6\u3082\u65e9\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3066\u4e00\u77f3\u4e8c\u9ce5\u3067\u3059\u306d\u3002<\/p>\n<p>\u307f\u306a\u3055\u3093\u306e\u53c2\u8003\u306b\u306a\u308c\u3070\u5e78\u3044\u3067\u3059\uff01<\/p>\n<p>\u3067\u306f\u3067\u306f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-444 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/16.png\" alt=\"\" width=\"370\" height=\"310\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/16.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/04\/16-300x251.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u5b9f\u306f\u73fe\u5728\u3082Laravel\u6700\u65b0\u7248\u3092\u4f7f\u3063\u305f\u958b\u767a\u3092\u884c\u3063\u3066\u3044\u308b\u6700\u4e2d\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u958b\u767a\u306e\u4e2d\u3067\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u5b58\u5728\u3057\u306a\u3044\u3061\u3087\u3063\u3068\u8907\u96d1\u306a\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u3059\u308b\u5fc5\u8981\u304c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=1317\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel\u3067\u4e88\u7d04\u304c\u5165\u3063\u3066\u3044\u308b\u304b\u30c1\u30a7\u30c3\u30af\u3059\u308b\u72ec\u81ea\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":1339,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,97],"tags":[5],"class_list":["post-1317","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-97","tag-5"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1317","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=1317"}],"version-history":[{"count":8,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1317\/revisions"}],"predecessor-version":[{"id":1342,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1317\/revisions\/1342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/1339"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}