{"id":1740,"date":"2018-10-25T02:47:01","date_gmt":"2018-10-24T17:47:01","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=1740"},"modified":"2021-10-09T02:11:28","modified_gmt":"2021-10-08T17:11:28","slug":"laravel-%e3%83%a1%e3%83%bc%e3%83%ab%e3%82%a2%e3%83%89%e3%83%ac%e3%82%b9%e3%82%92%e7%94%bb%e5%83%8f%e5%8c%96%e3%81%97%e3%81%a6%e3%82%b9%e3%83%91%e3%83%a0%e3%82%92%e9%98%b2%e6%ad%a2%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=1740","title":{"rendered":"Laravel \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u753b\u50cf\u5316\u3057\u3066\u30b9\u30d1\u30e0\u3092\u9632\u6b62\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3092\u59cb\u3081\u308b\u305a\u3063\u3068\u524d\u304b\u3089\u3067\u3059\u304c\u3001\u79c1\u306f\u4ed6\u306b\u3082\u300c<a href=\"https:\/\/www.prerele.com\/\">\u3077\u308c\u308a\u308a\u30fb\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9<\/a>\u300d\u3068\u3044\u3046\u500b\u4eba\u60c5\u5831\u306a\u3057\u3067\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u304c\u516c\u958b\u3067\u304d\u308b\u7121\u6599\u30b5\u30a4\u30c8\u3092\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5143\u3005\u3044\u308d\u3044\u308d\u3068\u30a6\u30a7\u30d6\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u3063\u3066\u304d\u305f\uff08\u7d50\u679c\u9589\u9396\u3082\u3057\u3066\u304d\u305f ^^;\uff09\u3053\u3068\u3082\u3042\u3063\u3066\u3001\u4e16\u306e\u4e2d\u306e\u30b5\u30a4\u30c8\u30fb\u30aa\u30fc\u30d7\u30f3\u3092\u5c11\u3057\u3067\u3082\u591a\u304f\u77e5\u3063\u3066\u3082\u3089\u3048\u308b\u6a5f\u4f1a\u304c\u3042\u308c\u3070\u3044\u3044\u3068\u601d\u3044\u3001\u307b\u307c\u30dc\u30e9\u30f3\u30c6\u30a3\u30a2\u306e\u3088\u3046\u306a\u5f62\u3067\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u306e\u8a71\u984c\u306f\u3053\u306e\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u30fb\u30b5\u30a4\u30c8\u3067\u3082\u4f7f\u3063\u3066\u3044\u308b\u30c6\u30af\u30cb\u30c3\u30af\u3067\u3001\u300c<strong>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u753b\u50cf\u5316\u3057\u3066\u30b9\u30d1\u30e0\u304b\u3089\u5b88\u308b<\/strong>\u300d\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u306f\u305d\u306e\u6027\u8cea\u4e0a\u3001\u3088\u304f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u96fb\u8a71\u756a\u53f7\u306a\u3069\u3092\u8a18\u8f09\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u305d\u306e\u307e\u307e\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u306b\u8f09\u305b\u3066\u3057\u307e\u3046\u3068\u6a5f\u68b0\u7684\u306b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u53ce\u96c6\u3057\u3066\u3044\u308d\u3044\u308d\u306a\u5e83\u544a\u3092\u9001\u308a\u3064\u3051\u308b\u3001\u3044\u308f\u3086\u308b\u300c\u30b9\u30d1\u30e0\u30e1\u30fc\u30eb\u300d\u306e\u6a19\u7684\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3053\u3068\u3082\u6709\u540d\u306a\u8a71\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u3072\u3068\u3064\u306e\u5bfe\u7b56\u6cd5\u3068\u3057\u3066\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u30c6\u30ad\u30b9\u30c8\u3067\u306f\u306a\u304f\u753b\u50cf\u5316\u3057\u3066\u3057\u307e\u3046\u3068\u3044\u3046\u30c6\u30af\u30cb\u30c3\u30af\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u3046\u3057\u3066\u304a\u304f\u3068\uff08\u3082\u3061\u308d\u3093AI\u3084OCR\u3092\u4f7f\u308f\u308c\u308b\u3068\u5b8c\u5168\u3068\u306f\u8a00\u3048\u307e\u305b\u3093\u304c\uff09\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u53ce\u96c6\u306f\u9632\u6b62\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306fLaravel\u3092\u4f7f\u3063\u3066\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u753b\u50cf\u5316\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\u6700\u5f8c\u306b\u306f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u306e\u3067\u3001\u305c\u3072\u30b5\u30a4\u30c8\u958b\u767a\u306b\u5f79\u7acb\u3066\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1575 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/22.png\" alt=\"\" width=\"310\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/22.png 310w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/22-291x300.png 291w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/><\/p>\n<p>\u203b \u958b\u767a\u74b0\u5883\u306fLaravel 5.7\u3067\u3059\u3002<\/p>\n<h1>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u306f\u753b\u50cf\u3092\u6271\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001<a href=\"https:\/\/blog.capilano-fw.com\/?p=1574\">\u5b8c\u5168\u7db2\u7f85\uff01Intervention Image\uff08PHP\uff09\u3067\u753b\u50cf\u3092\u7de8\u96c6\u3059\u308b\u5168\u5b9f\u4f8b<\/a>\u3067\u3082\u7d39\u4ecb\u3057\u305f\u30d1\u30c3\u30b1\u30fc\u30b8<strong>Intervention Image<\/strong>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5\u3082\u3053\u306e\u8a18\u4e8b\u306e\u4e2d\u306b\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<h1>\u30c6\u30b9\u30c8\u6587\u5b57<\/h1>\n<p>\u30c6\u30b9\u30c8\u3067\u4f7f\u3046\u4f1a\u793e\u60c5\u5831\u306f\u6b21\u306e\u3082\u306e\u3068\u3057\u307e\u3059\u3002<\/p>\n<pre>Example\u682a\u5f0f\u4f1a\u793e\r\n<strong>test@example.com<\/strong><\/pre>\n<p>\u203b \u3061\u306a\u307f\u306b\u3001<code>example.com<\/code>\u306f\u4eca\u56de\u306e\u3088\u3046\u306b\u30b5\u30f3\u30d7\u30eb\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u30c9\u30e1\u30a4\u30f3\u306a\u306e\u3067\u3001\u30ea\u30f3\u30af\u3092\u8cbc\u308d\u3046\u304c\u3001\u30e1\u30fc\u30eb\u9001\u4fe1\u3057\u3088\u3046\u304c\u8ab0\u306b\u3082\u8ff7\u60d1\u3092\u304b\u3051\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u306a\u306e\u3067Laravel\u306e<code>config\/mail.php<\/code>\u5185\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\uff08\u521d\u671f\u5024\uff09\u3082<code>hello@example.com<\/code>\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306e\u958b\u767a\u3067\u306f\u3053\u306e\u300ctest@example.com\u300d\u306e\u90e8\u5206\u3092\u753b\u50cf\u5316\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h1>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u308b<\/h1>\n<p>\u307e\u305a\u306f\u300cExample\u682a\u5f0f\u4f1a\u793e\u300d\u306e\u4f1a\u793e\u60c5\u5831\u304c\u901a\u5e38\u901a\u308a\u8868\u793a\u3055\u308c\u308b\u30da\u30fc\u30b8\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n<p>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u3067\u3059\u3002<br \/>\n\uff11\u3064\u76ee\u306f\u4f1a\u793e\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u308b\u30da\u30fc\u30b8\u3067\u3001\uff12\u3064\u76ee\u306f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u753b\u50cf\u306e\u30da\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<pre><strong>Route::get('test\/email_image', 'TestController@email_image');<\/strong>\r\n<strong>Route::get('image\/email\/{code}', 'ImageController@email');<\/strong><\/pre>\n<h2>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u3067\u306f\u3001\u6b21\u306b\u30d3\u30e5\u30fc\u3067\u3059\u3002<br \/>\n<code>resources\/views\/email_image.blade.php<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u3001\u305d\u306e\u4e2d\u306b\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n    &lt;div&gt;\r\n        <strong>{!! $email_text !!}<\/strong>\r\n    &lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3064\u307e\u308a\u3001<code>$email_text<\/code>\u306b\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u542b\u3093\u3060\u30c6\u30ad\u30b9\u30c8\u304c\u5165\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h2>\n<p>\u5fc5\u8981\u306b\u306a\u308b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306f<code>TestController<\/code>\u3068<code>ImageController<\/code>\u306e\uff12\u3064\u3067\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:controller TestController<\/strong>\r\n<strong>php artisan make:controller ImageController<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001<code>TestController<\/code>\u3092\u958b\u3044\u3066<code>email_image()<\/code>\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>public function email_image() {\r\n\r\n    $email_text = 'Example\u682a\u5f0f\u4f1a\u793e&lt;br&gt;test@example.com';\r\n<strong>    return view('email_image')<\/strong>\r\n<strong>        -&gt;with('email_text', $email_text);<\/strong>\r\n\r\n}<\/pre>\n<p>\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u4e2d\u3067\u3001\u30d3\u30e5\u30fc\u3092\u8a2d\u5b9a\u3057\u3001\u305d\u306e\u4e2d\u3067\u4f1a\u793e\u60c5\u5831\u3092\u5909\u6570\u3068\u3057\u3066\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u5b9f\u969b\u306b\u30da\u30fc\u30b8\u306b\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-1741\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/example_company_info_1.png\" alt=\"\" width=\"160\" height=\"47\" \/><\/p>\n<p>\u203b \u3082\u3061\u308d\u3093\u3001\u307e\u3060\u5168\u3066\u30c6\u30ad\u30b9\u30c8\u3067\u3059\u3002<\/p>\n<h1>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u753b\u50cf\u5316\u3059\u308b<\/h1>\n<p>\u3067\u306f\u3001\u3053\u306e\u300ctest@example.com\u300d\u306e\u90e8\u5206\u3060\u3051\u3092\u753b\u50cf\u306b\u5165\u308c\u66ff\u3048\u307e\u3059\u3002<\/p>\n<h2>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6b63\u898f\u8868\u73fe\u3067&lt;img&gt;\u30bf\u30b0\u3068\u5165\u308c\u66ff\u3048\u308b<\/h2>\n<p>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u90e8\u5206\u3060\u3051\u3092\u30c6\u30ad\u30b9\u30c8\u5185\u304b\u3089\u629c\u304d\u51fa\u3059\u306b\u306f\u901a\u5e38<code>preg_replace()<\/code>\u3092\u4f7f\u3044\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u629c\u304d\u51fa\u3057\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u52a0\u5de5\u3082\u5fc5\u8981\u306a\u306e\u3067\u3001\u3055\u3089\u306b\u8907\u96d1\u306a\u51e6\u7406\u304c\u3067\u304d\u308b<code>preg_replace_callback()<\/code>\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre>$email_text = 'Example\u682a\u5f0f\u4f1a\u793e&lt;br&gt;test@example.com';\r\n\r\n$pattern = '\/(?:[a-z0-9!#$%&amp;\\'*+\\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&amp;\\'*+\\\/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])\/';\r\n$email_image_text = <strong>preg_replace_callback($pattern, function($matches){<\/strong>\r\n\r\n<strong>    $email = $matches[0];<\/strong>\r\n<strong>    $encrypted_email = encrypt($email); \/\/ \u6697\u53f7\u5316<\/strong>\r\n<strong>    return '&lt;img src=\"\/image\/email\/'. $encrypted_email .'\"&gt;';<\/strong>\r\n\r\n<strong>}, $email_text);\r\n\r\n<\/strong>return view('email_image')\r\n\u00a0   -&gt;with('email_text', $email_image_text);\r\n<\/pre>\n<p>\u307e\u305a\u3001<code>$pattern<\/code>\u306f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u63a2\u3057\u51fa\u3059\u30d1\u30bf\u30fc\u30f3\uff08\u6b63\u898f\u8868\u73fe\uff09\u3067\u3059\u3002\uff08\u306a\u304a\u3001\u3053\u306e\u30d1\u30bf\u30fc\u30f3\u306f\u3001<a href=\"https:\/\/emailregex.com\/\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3067<code>RFC 5322 Official Standard<\/code>\u3068\u3057\u3066\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u3082\u306e\u3067\u3059\uff09<\/p>\n<p>\u203b \u3061\u306a\u307f\u306b100\uff05\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u30de\u30c3\u30c1\u3059\u308b\u6b63\u898f\u8868\u73fe\u306f\u5b58\u5728\u3057\u306a\u3044\u3068\u8a00\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>preg_replace_callback()<\/code>\u306e\u4e2d\u3067\u306f\u3001\u53d6\u5f97\u3057\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092Laravel\u306e<code>encrypt()<\/code>\u3067\u6697\u53f7\u5316\u3057\u3001\u305d\u306e\u6587\u5b57\u5217\u3092\u542b\u3093\u3060URL\u3092\u753b\u50cf\u306e<code>src<\/code>\u3068\u3057\u3066\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001HTML\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;body&gt;\r\n&lt;div&gt;\r\n    Example\u682a\u5f0f\u4f1a\u793e&lt;br&gt;<strong>&lt;img src=\"\/image\/email\/\uff08\u6697\u53f7\u5316\u30b3\u30fc\u30c9\uff09\"&gt;<\/strong>\r\n&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<h2>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u753b\u50cf\u3092\u3064\u304f\u308b<\/h2>\n<h2>\u30d5\u30a9\u30f3\u30c8\u3092\u7528\u610f\u3059\u308b<\/h2>\n<p>\u3067\u306f\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u66f8\u304b\u308c\u305f\u753b\u50cf\u3092\u4f5c\u6210\u3059\u308b\u90e8\u5206\u3067\u3059\u304c\u3001\u305d\u306e\u524d\u306b\u3072\u3068\u3064\u3060\u3051\u6e96\u5099\u3092\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u306f\u30d5\u30a9\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<p><code>Intervention Image<\/code>\u3092\u4f7f\u3063\u3066\u30c6\u30ad\u30b9\u30c8\u3092\u753b\u50cf\u306b\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u3059\u304c\u3001\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3059\u308b\u306a\u3069\u3057\u305f\u3044\u5834\u5408\u306f\u30d5\u30a9\u30f3\u30c8\u3092\u6307\u5b9a\u3057\u3066\u304a\u304f\u3079\u304d\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u5546\u7528\u3067\u3082\u5229\u7528\u53ef\u80fd\u306a<a href=\"https:\/\/moji.or.jp\/ipafont\/ipafontdownload\/\" target=\"_blank\" rel=\"noopener\">IPA\u30d5\u30a9\u30f3\u30c8<\/a>\u306a\u3069\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3001<code>storage\/fonts<\/code>\u5185\u306b\u8a2d\u7f6e\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\uff08\u4eca\u56de\u306f<code>ipagp.ttf<\/code>\u3092\u4f7f\u3044\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1742\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/Screenshot-from-2018-10-23-18-26-14.png\" alt=\"\" width=\"296\" height=\"155\" \/><\/p>\n<h2>\u30c6\u30ad\u30b9\u30c8\u3092\u753b\u50cf\u5316\u3059\u308b<\/h2>\n<p>\u6700\u521d\u306b\u3064\u304f\u3063\u305f<code>ImageController<\/code>\u5185\u306b<code>email()<\/code>\u3092\u8ffd\u52a0\u3057\u3066\u753b\u50cf\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>public function email($code) {\r\n\r\n    $email = decrypt($code); \/\/ \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u5fa9\u53f7\r\n\r\n    \\Image::configure(['driver' =&gt; 'imagick']); \/\/ ImageMagick\u3092\u4f7f\u3046\r\n    $width = 200;   \/\/ \u753b\u50cf\u306e\u5e45\r\n    $height = 22;   \/\/ \u753b\u50cf\u306e\u9ad8\u3055\r\n    $x = 5;\r\n    $y = 5;\r\n    <strong>$img = \\Image::canvas($width, $height, '#ddd');<\/strong>\r\n<strong>    $img-&gt;text($email, $x, $y, function($font) {<\/strong>\r\n<strong>        $font-&gt;file(storage_path('app\/fonts\/ipagp.ttf')); \/\/ \u30d5\u30a9\u30f3\u30c8\u3092\u6307\u5b9a<\/strong>\r\n<strong>        $font-&gt;size(18);      \/\/ \u30c6\u30ad\u30b9\u30c8\u30b5\u30a4\u30ba<\/strong>\r\n<strong>        $font-&gt;align('left'); \/\/ \u5de6\u63c3\u3048<\/strong>\r\n<strong>        $font-&gt;valign('top'); \/\/ \u4e0a\u63c3\u3048<\/strong>\r\n<strong>    });<\/strong>\r\n    return $img-&gt;response();\r\n\r\n}<\/pre>\n<p>\u3084\u3063\u3066\u3044\u308b\u3053\u3068\u306f\u3001\u307e\u305a<code>$code<\/code>\u306f\u6697\u53f7\u5316\u3055\u308c\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306a\u306e\u3067\u3001\u3053\u308c\u3092<code>decrypt()<\/code>\u3067\u5143\u306b\u623b\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3088\u308a\u7dba\u9e97\u306a\u753b\u50cf\u304c\u4f5c\u6210\u3067\u304d\u308b\u306e\u3067\u3001<code>\\Image::configure()<\/code>\u3067ImageMagick\u3092\u4f7f\u3046\u8a2d\u5b9a\u306b\u3057\u3066\u3044\u307e\u3059\u3002\uff08\u305f\u3060\u3057\u3001<code>ImageMagick<\/code>\u3092\u4f7f\u3046\u306b\u306fPHP\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306a\u3069\u304c\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u305f\u3081\u3001\u3081\u3093\u3069\u3046\u306a\u5834\u5408\u306f\u3053\u3053\u306f\u524a\u9664\u3057\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\uff09<\/p>\n<p>\u305d\u3057\u3066\u6700\u5f8c\u306b\u3001<code>Intervention Image<\/code>\u3067\u753b\u50cf\u306e\u4e2d\u306b\u30c6\u30ad\u30b9\u30c8\u3092\u63cf\u753b\u3057\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u3001<a href=\"https:\/\/blog.capilano-fw.com\/?p=1574\">\u5b8c\u5168\u7db2\u7f85\uff01Intervention Image\uff08PHP\uff09\u3067\u753b\u50cf\u3092\u7de8\u96c6\u3059\u308b\u5168\u5b9f\u4f8b<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u308c\u3067\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3053\u306e\u3088\u3046\u306a\u753b\u50cf\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\uff08\u4eca\u56de\u306f\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u80cc\u666f\u8272\u3092\u3064\u3051\u3066\u3044\u307e\u3059\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1745\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/example_email.jpg\" alt=\"\" width=\"200\" height=\"22\" \/><\/p>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u3064\u304f\u3063\u305f\u4f1a\u793e\u60c5\u5831\u304c\u8868\u793a\u3055\u308c\u308b\u30da\u30fc\u30b8\u306b\u3082\u30a2\u30af\u30bb\u30b9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1747\" style=\"border: 1px solid #ccc;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/example_company_info_2.png\" alt=\"\" width=\"361\" height=\"108\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/example_company_info_2.png 361w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/10\/example_company_info_2-300x90.png 300w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><\/p>\n<p>\u5c11\u3057\u5206\u304b\u308a\u306b\u304f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4e0a\u306e\u6bb5\u306f\u901a\u5e38\u306e\u30c6\u30ad\u30b9\u30c8\u3067\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u90e8\u5206\u3060\u3051\u753b\u50cf\u5316\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u304a\u307e\u3051\u30fb\u30fb\u30fb\u305d\u306e\uff11\uff08\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u5316\u3059\u308b\uff09<\/h1>\n<p>\u4eca\u56de\u3064\u304f\u3063\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u753b\u50cf\u5316\u306f\u30b5\u30a4\u30c8\u306b\u3088\u3063\u3066\u306f\u3068\u3066\u3082\u6c4e\u7528\u6027\u304c\u9ad8\u3044\u6a5f\u80fd\u3068\u8a00\u3048\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u3053\u306e\u6a5f\u80fd\u3092\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u5316\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u72ec\u81ea\u306e\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u3092\u3064\u304f\u308b\u306b\u306f\u3001\u307e\u305a<code>app\/helpers.php<\/code>\u3092\u4f5c\u6210\u3057\u3066<code>email_text()<\/code>\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<pre>&lt;?php\r\n\r\nif (! function_exists('email_text')) {\r\n\r\n    <strong>function email_text($text) {<\/strong>\r\n\r\n<strong>        $pattern = '\/(?:[a-z0-9!#$%&amp;\\'*+\\\/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&amp;\\'*+\\\/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])\/';<\/strong>\r\n<strong>        return preg_replace_callback($pattern, function($matches){<\/strong>\r\n\r\n<strong>            $email = $matches[0];<\/strong>\r\n<strong>            $encrypted_email = encrypt($email); \/\/ \u6697\u53f7\u5316<\/strong>\r\n<strong>            return '&lt;img src=\"\/image\/email\/'. $encrypted_email .'\"&gt;';<\/strong>\r\n\r\n<strong>        }, $text);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n}<\/pre>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\u307e\u307e\u3067\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306a\u3069\u304b\u3089\u306f\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u306e\u3067\u3001<code>composer.json<\/code>\u306e<code>autoload<\/code>\u5185\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u65b0\u3057\u3044\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<pre>\"autoload\": {\r\n<strong>    \"files\": [<\/strong>\r\n<strong>        \"app\/helpers.php\"<\/strong>\r\n<strong>    ],<\/strong><\/pre>\n<p>\u305d\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067<code>autoload<\/code>\u3092\u66f4\u65b0\u3059\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<pre><strong>composer dump-autoload<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u3001\u3069\u3053\u304b\u3089\u3067\u3082<code>email_text()<\/code>\u3068\u3059\u308c\u3070\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u304c\u753b\u50cf\u5316\u3055\u308c\u305f\u30c6\u30ad\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h1>\u304a\u307e\u3051\u30fb\u30fb\u30fb\u305d\u306e\uff12\uff08\u753b\u50cf\u3092\u518d\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u3059\u308b\uff09<\/h1>\n<p>\u73fe\u72b6\u3067\u306f\u3001<code>ImageController<\/code>\u306e<code>email()<\/code>\u3067\u306f\u6bce\u56de\u753b\u50cf\u3092\u3064\u304f\u308b\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u308c\u307b\u3069\u5927\u304d\u306a\u753b\u50cf\u3067\u306f\u306a\u3044\u306e\u3067\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3078\u306e\u8ca0\u8377\u306f\u5c11\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4f55\u56de\u3082\u540c\u3058\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u306e\u306f\u3042\u307e\u308a\u8ce2\u3044\u3084\u308a\u65b9\u3068\u306f\u3044\u3048\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u753b\u50cf\u306f\u6700\u521d\u306b\u4fdd\u5b58\u3057\u3066\u304a\u304f\u3053\u3068\u306b\u3057\u3001\u3082\u3057\u5b58\u5728\u3057\u3066\u3044\u308c\u3070\u6b21\u304b\u3089\u306f\u305d\u306e\u753b\u50cf\u3092\u8aad\u307f\u8fbc\u3080\u3068\u3044\u3046\u5f62\u306b\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>public function email($code) {\r\n\r\n    $email = decrypt($code); \/\/ \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u5fa9\u53f7\r\n    <strong>$path = storage_path('app\/images\/email\/'. md5($email) .'.jpg');<\/strong>\r\n\r\n    <strong>if(file_exists($path)) {<\/strong> \/\/ 2\u56de\u76ee\u4ee5\u964d\u306f\u3053\u3053\u3092\u901a\u308b\r\n\r\n        $img = \\Image::make($path);\r\n\r\n    <strong>} else {<\/strong>\r\n\r\n        \\Image::configure(['driver' =&gt; 'imagick']); \/\/ ImageMagick\u3092\u4f7f\u3046\r\n        $width = 200;   \/\/ \u753b\u50cf\u306e\u5e45\r\n        $height = 22;   \/\/ \u753b\u50cf\u306e\u9ad8\u3055\r\n        $x = 5;\r\n        $y = 5;\r\n        $img = \\Image::canvas($width, $height, '#ddd');\r\n        $img-&gt;text($email, $x, $y, function($font) {\r\n            $font-&gt;file(storage_path('app\/fonts\/ipagp.ttf')); \/\/ \u30d5\u30a9\u30f3\u30c8\u3092\u6307\u5b9a\r\n            $font-&gt;size(18);      \/\/ \u30c6\u30ad\u30b9\u30c8\u30b5\u30a4\u30ba\r\n            $font-&gt;align('left'); \/\/ \u5de6\u63c3\u3048\r\n            $font-&gt;valign('top'); \/\/ \u4e0a\u63c3\u3048\r\n        });\r\n        $img-&gt;save($path);\r\n\r\n    <strong>}<\/strong>\r\n\r\n    return $img-&gt;response();\r\n\r\n}<\/pre>\n<p>\u307e\u305a\u3001<code>$path<\/code>\u306f\u6697\u53f7\u5316\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3060\u3068\u5c11\u3057\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001<code>md5()<\/code>\u3067\u30cf\u30c3\u30b7\u30e5\u5316\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>file_exists()<\/code>\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u3092\u78ba\u8a8d\u3057\u3001<\/p>\n<ul>\n<li>\u3082\u3057\u3001\u306a\u3051\u308c\u3070\u753b\u50cf\u3092\u4f5c\u3063\u3066\u4fdd\u5b58\u3059\u308b<\/li>\n<li>\u3082\u3057\u3001\u5b58\u5728\u3057\u3066\u3044\u308c\u3070\u305d\u306e\u753b\u50cf\u3092\u8aad\u307f\u8fbc\u3080<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u5206\u5c90\u3092\u3064\u304f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u203b \u305d\u306e\u305f\u3081\u3001<code>storage\/app\/images\/email<\/code>\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u3001\u66f8\u304d\u8fbc\u307f\u6a29\u9650\u3092\u3064\u3051\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h1>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h1>\n<p>\u4eca\u56de\u8aac\u660e\u3067\u4f7f\u3063\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057\u3001<code>Intervention Image<\/code>\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3001\u30d8\u30eb\u30d1\u30fc\u95a2\u6570\u306eautoload\u3001\u307e\u305f\u753b\u50cf\u4f5c\u6210\u306e\u30d5\u30a9\u30f3\u30c8\u8a2d\u5b9a\u306f\u3054\u81ea\u8eab\u3067\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=1750&amp;tmstv=1777538062\" rel=\"nofollow\" id=\"download-link-1750\" data-redirect=\"false\" >\n\t\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u753b\u50cf\u5316\u3057\u3066\u30b9\u30d1\u30e0\u3092\u9632\u6b62\uff1a \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e00\u5f0f<\/a>\n\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3092\u59cb\u3081\u308b\u305a\u3063\u3068\u524d\u304b\u3089\u3067\u3059\u304c\u3001\u79c1\u306f\u4ed6\u306b\u3082\u300c\u3077\u308c\u308a\u308a\u30fb\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u300d\u3068\u3044\u3046\u500b\u4eba\u60c5\u5831\u306a\u3057\u3067\u30d7\u30ec\u30b9\u30ea\u30ea\u30fc\u30b9\u304c\u516c\u958b\u3067\u304d\u308b\u7121\u6599\u30b5\u30a4\u30c8\u3092\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=1740\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u753b\u50cf\u5316\u3057\u3066\u30b9\u30d1\u30e0\u3092\u9632\u6b62\u3059\u308b\u65b9\u6cd5&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":1755,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,97],"tags":[81,83],"class_list":["post-1740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-97","tag-81","tag-83"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1740","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=1740"}],"version-history":[{"count":7,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1740\/revisions"}],"predecessor-version":[{"id":9683,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/1740\/revisions\/9683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/1755"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}