{"id":826,"date":"2019-05-13T08:37:33","date_gmt":"2019-05-12T23:37:33","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=826"},"modified":"2019-08-18T18:14:18","modified_gmt":"2019-08-18T09:14:18","slug":"blade%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88-%e3%83%87%e3%83%bc%e3%82%bf%e5%b1%95%e9%96%8b-laravel5-8","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=826","title":{"rendered":"\u3010Laravel\u3011Blade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8 \u30c7\u30fc\u30bf\u5c55\u958b"},"content":{"rendered":"<p>\nLaravel\u306eblade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u30c7\u30fc\u30bf\u306e\u8868\u793a\u306b\u95a2\u3057\u3066\u3082\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u591a\u304f\u3042\u308a\u307e\u3059\u3002<!--more--><br \/>\n\u4eca\u56de\u306fblade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u304a\u3051\u308b\u30c7\u30fc\u30bf\u5c55\u958b\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\n<\/p>\n<h1>\u524d\u63d0<\/h1>\n<h2>\u30d5\u30a1\u30a4\u30eb\u69cb\u6210<\/h2>\n<p>\n\u4eca\u56de\u4f7f\u7528\u3059\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\n<\/p>\n<table class=\"table\">\n<thead>\n<tr>\n<th scope=\"col\">\u30d5\u30a1\u30a4\u30eb\u540d<\/th>\n<th scope=\"col\">\u8aac\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>resources\/views\/layouts\/main.blade.php<\/td>\n<td>\u89aa\u30d3\u30e5\u30fc(\u30ec\u30a4\u30a2\u30a6\u30c8\u30d5\u30a1\u30a4\u30eb)<\/td>\n<\/tr>\n<tr>\n<td>resources\/views\/expansion\/data_expansion.blade.php<\/td>\n<td>\u5b50\u30d3\u30e5\u30fc(\u30b3\u30f3\u30c6\u30f3\u30c4\u30d5\u30a1\u30a4\u30eb)<\/td>\n<\/tr>\n<tr>\n<td>routes\/web.php<\/td>\n<td>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u30d5\u30a1\u30a4\u30eb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n<p>\n\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\n<\/p>\n<pre class=\"lang:default decode:true \" title=\"web.php\" >Route::get('\/data_expansion', function () {\r\n    return view('expansion.data_expansion');\r\n});<\/pre>\n<h1>\u5909\u6570\u5c55\u958b<\/h1>\n<h2>\u8868\u793a<\/h2>\n<p>\n{{}}\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u5909\u6570\u306e\u5185\u5bb9\u3092\u8868\u793a\u3057\u307e\u3059\u3002\n<\/p>\n<pre class=\"lang:default decode:true \" title=\"data_expansion.blade.php\" >@extends('layouts.main')\r\n@php\r\n  $value = '\u30a2\u30a4\u30a6\u30a8\u30aa';\r\n@endphp\r\n\r\n@section('content')\r\n\r\n  {{-- \u5909\u6570\u5c55\u958b\u3057\u307e\u3059\u3002 --}}\r\n  &lt;p style=\"color:#008080\"&gt;{{$value}}&lt;\/p&gt;\r\n\r\n@endsection\r\n\r\n<\/pre>\n<h2>\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0(XSS)\u3078\u306e\u5bfe\u5fdc<\/h2>\n<p>\n\u81ea\u52d5\u7684\u306bphp\u306ehtmlspecialchars\u304c\u4f7f\u7528\u3055\u308c\u5909\u6570\u306e\u5185\u5bb9\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br \/>\n\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0(XSS)\u306b\u3064\u3044\u3066\u306f\u3001<a href=\"https:\/\/dennie.tokyo\/web\/2016\/12\/25\/xss\/\" rel=\"noopener noreferrer\" target=\"_blank\">\u30af\u30ed\u30b9\u30b5\u30a4\u30c8\u30b9\u30af\u30ea\u30d7\u30c6\u30a3\u30f3\u30b0\u3092\u6839\u7d76\u3057\u3088\u3046 \u3010\u8aac\u660e\u7de8\u3011<\/a> \u3092\u53c2\u7167\u3057\u3066\u4e0b\u3055\u3044\u3002\n<\/p>\n<h1>\u30a8\u30f3\u30b3\u30fc\u30c9\u306a\u3057<\/h1>\n<p>\n\u5148\u307b\u3069\u306e\u8aac\u660e\u306b\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u3001Laravel\u306eBlade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306fXSS\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u70ba\u3001{{ }} \u3067\u5024\u3092\u8868\u793a\u3059\u308b\u5834\u5408\u3001Java Script\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u3001\u7121\u52b9\u5316\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002<br \/>\nJavaScript\u3092\u4f7f\u7528\u3057\u305f\u3044(\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u304f\u306a\u3044)\u5834\u5408\u3001{!! !!} \u3092\u4f7f\u3044\u307e\u3059\u3002\n<\/p>\n<h2>JavaScript\u306e\u30a8\u30f3\u30b3\u30fc\u30c9\u306e\u4f8b<\/h2>\n<p>\n\u4ee5\u4e0b\u306e\u4f8b\u306f\u3001\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u30a2\u30e9\u30fc\u30c8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br \/>\n\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u5834\u5408\u3001JavaScriot\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u6587\u5b57\u5217\u3068\u3057\u3066\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002\n<\/p>\n<pre class=\"lang:default decode:true \" title=\"data_expansion.blade.php\" >@extends('layouts.main')\r\n@php\r\n  $htmlValue = \"&lt;input type='button' value='click' onclick='sample()'&gt;\";\r\n@endphp\r\n\r\n@section('content')\r\n\r\n  {{-- \u4ee5\u4e0b\u306f\u3001\u30a8\u30b9\u30b1\u30fc\u30d7\u306a\u3057\u3002 --}}\r\n  {!!$htmlValue!!}\r\n\r\n  {{-- \u4ee5\u4e0b\u306f\u3001\u30a8\u30b9\u30b1\u30fc\u30d7\u3042\u308a\u3002 --}}\r\n  {{$htmlValue}}\r\n\r\n  &lt;script&gt;\r\n    function sample(){\r\n      alert('\u30a2\u30e9\u30fc\u30c8');\r\n    }\r\n  &lt;\/script&gt;\r\n\r\n@endsection\r\n<\/pre>\n<h2>\u5b9f\u884c\u7d50\u679c<\/h2>\n<p>\n\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u306a\u3044\u5834\u5408\u3001\u30dc\u30bf\u30f3\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<br \/>\n\u4e00\u65b9\u3067\u3001\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u305f\u5834\u5408JavaScriot\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u6587\u5b57\u5217\u3068\u3057\u3066\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2019\/05\/data.png\" alt=\"\" width=\"1920\" height=\"300\" class=\"alignnone size-full wp-image-1263\" srcset=\"https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2019\/05\/data.png 1920w, https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2019\/05\/data-300x47.png 300w, https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2019\/05\/data-768x120.png 768w, https:\/\/dennie.tokyo\/it\/wp-content\/uploads\/2019\/05\/data-1024x160.png 1024w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<h1>\u30b3\u30e1\u30f3\u30c8<\/h1>\n<p>\n\u30b3\u30e1\u30f3\u30c8\u3092\u8a18\u8f09\u3059\u308b\u306b\u306f{{&#8211; \u30b3\u30e1\u30f3\u30c8 &#8211;}} \u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u307e\u3067\u306e\u4f8b\u306e\u4e2d\u3067\u30b3\u30e1\u30f3\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044\u3002\n<\/p>\n<h1>json\u30a8\u30f3\u30b3\u30fc\u30c9<\/h1>\n<p>\n@json\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001Json\u30a8\u30f3\u30b3\u30fc\u30c9\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306f\u3001@json\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u7528\u3057\u305f\u4f8b\u3067\u3059\u3002php\u95a2\u6570\u306ejson_encode\u3092\u4f7f\u7528\u3057\u305f\u4f8b\u3082\u540c\u6642\u306b\u8a18\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u7d50\u679c\u306f\u540c\u3058\u306b\u306a\u308a\u307e\u3059\u3002\n<\/p>\n<pre class=\"lang:default decode:true \" title=\"data_expansion.blade.php\" >@extends('layouts.main')\r\n@php\r\n  $arrayValue = [\r\n    'data1' =&gt; '\u3055\u3057',\r\n    'data2' =&gt; '\u3059\u305b',\r\n  ];\r\n@endphp\r\n\r\n@section('content')\r\n\r\n  &lt;script&gt;\r\n\r\n    var data = @json($arrayValue);\r\n    console.log(data);\r\n\r\n    var app = &lt;?php echo json_encode($arrayValue); ?&gt;;\r\n    console.log(app);\r\n\r\n  &lt;\/script&gt;\r\n\r\n@endsection\r\n<\/pre>\n<h1>javascript\u3078\u30c7\u30fc\u30bf\u3092\u6e21\u3059<\/h1>\n<p>\nJavascript\u3078\u30c7\u30fc\u30bf\u3092\u6e21\u3059\u5834\u5408\u3001{{}}\u3092'(\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8)\u3067\u56f2\u3044\u307e\u3059\u3002\n<\/p>\n<pre class=\"lang:default decode:true \" title=\"data_expansion.blade.php\" >@extends('layouts.main')\r\n@php\r\n  $value = '\u30a2\u30a4\u30a6\u30a8\u30aa';\r\n@endphp\r\n\r\n@section('content')\r\n\r\n  &lt;p id='test' style=\"color:#808000\"&gt;&lt;\/p&gt;\r\n\r\n  &lt;script&gt;\r\n\r\n    var value = '{{$value}}';\r\n    document.getElementById(\"test\").innerHTML = value;\r\n\r\n  &lt;\/script&gt;\r\n\r\n@endsection\r\n<\/pre>\n<h1>javascript\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3078\u306e\u5bfe\u5fdc<\/h1>\n<h2>\u5909\u6570\u5358\u4f4d\u306e\u5bfe\u5fdc<\/h2>\n<p>\nVue.js\u306e\u3088\u3046\u306ajavascript\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u306f\u3001{{}}\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u5834\u5408\u3001{{}}\u306fblade\u3067\u5909\u6570\u5c55\u958b\u3057\u305f\u304f\u306a\u3044\u3067\u3059\u3002<br \/>\n@{{}}\u3068\u8a18\u8f09\u3059\u308c\u3070blade\u306f{{}}\u306e\u5909\u6570\u5c55\u958b\u3092\u884c\u3044\u307e\u305b\u3093\u3002\n<\/p>\n<h2>\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u5358\u4f4d\u306e\u5bfe\u5fdc<\/h2>\n<p>\n@verbatim\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u7528\u3059\u308b\u3068\u3001@verbatim\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u5185\u306e{{}}\u306f\u5909\u6570\u5c55\u958b\u3055\u308c\u307e\u305b\u3093\u3002\n<\/p>\n<h1>View\u306e\u30ad\u30e3\u30c3\u30b7\u30e5<\/h1>\n<p>\nView\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u3055\u308c\u307e\u3059\u3002<br \/>\nLaravel\u306fView\u304c\u547c\u3073\u51fa\u3055\u308c\u308b\u3068\u3001blade\u30d5\u30a1\u30a4\u30eb\u304cphp\u3078\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u3001\u305d\u306e\u7d50\u679c\u3092\u30ad\u30e3\u30c3\u30b7\u30e5\u3068\u3057\u3066\u4fdd\u6301\u3057\u307e\u3059\u3002<br \/>\n\u305d\u306e\u70ba\u3001\u6bce\u56deblade\u30d5\u30a1\u30a4\u30eb\u304cphp\u3078\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u308b\u3053\u3068\u306f\u306a\u3044\u306e\u3067\u9ad8\u901f\u3067\u3059\u3002<br \/>\n\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u5909\u66f4\u3055\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306fblade\u30d5\u30a1\u30a4\u30eb\u3092\u66f4\u65b0\u3057\u3001view\u3092\u547c\u3073\u51fa\u3057\u305f\u6642\u3067\u3059\u3002<br \/>\nView\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u306f storage\/framework\/views \u306b\u3042\u308a\u307e\u3059\u3002<br \/>\n\u753b\u9762\u304c\u5909\u308f\u3089\u306a\u3044\u5834\u5408\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u30af\u30ea\u30a2\u3057\u307e\u3057\u3087\u3046\u3002\n<\/p>\n<h1>\u307e\u3068\u3081<\/h1>\n<p>\n\u7279\u306b\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u306eblade\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u30c7\u30fc\u30bf\u306e\u8868\u793a\u306b\u95a2\u3057\u3066\u3082\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u591a\u304f\u3042\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":968,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,4],"tags":[],"class_list":["post-826","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-php"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=826"}],"version-history":[{"count":22,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/826\/revisions"}],"predecessor-version":[{"id":1264,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/826\/revisions\/1264"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/968"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}