{"id":4466,"date":"2019-08-22T00:31:02","date_gmt":"2019-08-21T15:31:02","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=4466"},"modified":"2020-03-21T19:00:32","modified_gmt":"2020-03-21T10:00:32","slug":"laravel-livewire%e3%81%a7%e8%aa%95%e7%94%9f%e6%97%a5%e3%81%8b%e3%82%89%e5%b9%b4%e9%bd%a2%e3%82%92%e8%87%aa%e5%8b%95%e8%a8%88%e7%ae%97%e3%81%99%e3%82%8b%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=4466","title":{"rendered":"Laravel + livewire\u3067\u8a95\u751f\u65e5\u304b\u3089\u5e74\u9f62\u3092\u81ea\u52d5\u8a08\u7b97\u3059\u308b\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u306b\u8a18\u4e8b\u3092\u66f8\u304f\u305f\u3081\u306b\u666e\u6bb5\u304b\u3089\u3044\u308d\u3044\u308d\u306a\u60c5\u5831\u3092\u96c6\u3081\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3067\u3082\u306f\u3084\u308a\u9650\u754c\u304c\u3042\u3063\u3066\u5168\u3066\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u96e3\u3057\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u5148\u65e5\u3082\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3055\u3093\u306b\u6559\u3048\u3066\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u3084\u3089\u00a0<a href=\"https:\/\/livewire-framework.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">livewire<\/a> \u3068\u3044\u3046<strong>Laravel\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30fb\u30b7\u30b9\u30c6\u30e0\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u308b<\/strong>\u3068\u306e\u3053\u3068\u3067\u3057\u305f\u3002\uff08\u3044\u3064\u3082\u6709\u76ca\u306a\u60c5\u5831\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\ud83d\ude0a\u2728\uff09<\/p>\n<p>\u65e9\u901f\u8abf\u3079\u305f\u3068\u3053\u308d\u3001<code>livewire<\/code>\u306e\u30b3\u30f3\u30bb\u30d7\u30c8\u306f<strong>\u300c\u6700\u8fd1\u306eJavaScript\u306f\u3061\u3087\u3063\u3068\u3057\u305f\u3053\u3068\u3059\u308b\u3060\u3051\u306a\u306e\u306b\u3001\u8907\u96d1\u306a\u4f5c\u696d\u304c\u5fc5\u8981\u3002\u3082\u3046\u3001\u305d\u3046\u3044\u3046\u306e\u3084\u3081\u3088\u3046\uff01\u300d<\/strong>\u3068\u3044\u3046\u3082\u306e\u3067\u3057\u305f\u3002<\/p>\n<p>\u305f\u3057\u304b\u306b\u3001\u6700\u8fd1\u306e<code>JavaScript<\/code>\u958b\u767a\u306f\u3001<code>npm<\/code>\u3092\u4f7f\u3063\u3066\u5909\u66f4\u3092<code>watch<\/code>\u3057\u3066\u3001\u30d3\u30eb\u30c9\u306e\u5b8c\u4e86\u3092\u5f85\u3063\u3066\u3001\u3084\u3063\u3068\u3067\u304d\u305f\u3068\u601d\u3063\u305f\u3089\u307e\u305f\u5909\u66f4\u304c\u5fc5\u8981\u3067\u30fb\u30fb\u30fb\u518d\u8aad\u8fbc\u304c\u8ffd\u3044\u3064\u304b\u306a\u3044\u30fb\u30fb\u30fb\uff08\u4ee5\u4e0b\u7e70\u308a\u8fd4\u3057\uff09<\/p>\n<p>\u307f\u305f\u3044\u306a\u72b6\u6cc1\u306b\u306a\u308b\u306e\u3067\u3001<code>livewire<\/code>\u306e\u30b3\u30f3\u30bb\u30d7\u30c8\u306b\u3068\u3066\u3082\u8cdb\u6210\u3067\u3059\u3002\uff08\u79c1\u81ea\u8eab\u3082\u30d3\u30eb\u30c9\u306f<code>npm<\/code>\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u307f\u3067\u72ec\u81ea\u306e\u30b3\u30fc\u30c9\u306f\u76f4\u63a5<code>Blade<\/code>\u306b\u66f8\u304d\u8fbc\u3080\u5f62\u5f0f\u3092\u3068\u3063\u3066\u3044\u307e\u3059\uff09<\/p>\n<p>\u305d\u3053\u3067\uff01<\/p>\n<p><span style=\"font-size: 1rem;\">\u4eca\u56de\u306f\u3001\u305d\u3093\u306a\u6c17\u306b\u306a\u308b<\/span><code>livewire<\/code><span style=\"font-size: 1rem;\">\u306e\u4f7f\u3044\u65b9\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u307e\u3068\u3081\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/span><\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2173 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png\" alt=\"\" width=\"300\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/no_24-281x300.png 281w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 5.8<\/p>\n<h1>livewire\u306e\u4ed5\u7d44\u307f<\/h1>\n<p><code>livewire<\/code>\u3068\u3044\u3063\u3066\u3082<code>composer<\/code>\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u3072\u3068\u3064\u3067\u3001<code>Laravel<\/code>\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30fb\u30a8\u30f3\u30b8\u30f3<code>Blade<\/code>\u3067\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u63cf\u753b\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u5185\u5bb9\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u5909\u66f4\uff08\u4f8b\u3048\u3070\u3001\u30c6\u30ad\u30b9\u30c8\u306e\u8868\u793a\uff0f\u975e\u8868\u793a\u306e\u5207\u308a\u66ff\u3048\uff09\u304c\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u306f<code>Ajax<\/code>\u3092\u901a\u3057\u3066PHP\u5074\u304b\u3089HTML\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u305d\u306e\u901a\u4fe1\u306f<code>livewire<\/code>\u304c\u3084\u3063\u3066\u304f\u308c\u308b\u306e\u3067\u72ec\u81ea\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a95\u751f\u65e5\uff08\u5e74\u30fb\u6708\u30fb\u65e5\uff09\u3092\u5165\u529b\u3059\u308b\u3068\u81ea\u52d5\u7684\u306b\u5e74\u9f62\u3092\u8a08\u7b97\u3057\u3066\u8868\u793a\u3057\u3066\u304f\u308c\u308b\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<strong>\u300cbirthday\u300d<\/strong>\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4468\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/livewire_calc_age_1.png\" alt=\"\" width=\"487\" height=\"135\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/livewire_calc_age_1.png 487w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/livewire_calc_age_1-300x83.png 300w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/p>\n<p>\u306a\u304a\u3001\u300c\u65e5\u300d\u306e\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u306f\u5404\u6708\u306b\u5408\u308f\u305b\u306628\u65e5\u301c31\u65e5\u304c\u81ea\u52d5\u7684\u306b\u5909\u66f4\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u3001\u3055\u3089\u306b\u300c\u3046\u308b\u3046\u5e74\u300d\u306e\u5834\u5408\u306f\u300c2\u670829\u65e5\u300d\u3082\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u5b9f\u969b\u306b<code>livewire<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n<h1>livewire\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p>\u5148\u307b\u3069\u3082\u8a00\u3044\u307e\u3057\u305f\u304c<code>livewire<\/code>\u306f<code>composer<\/code>\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3060\u3051\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3057\u307e\u3059\u3002<\/p>\n<pre><strong>composer require calebporzio\/livewire<\/strong><\/pre>\n<h1>livewire\u306b\u5fc5\u8981\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/h1>\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u306f<code>livewire<\/code>\u304c\u7528\u610f\u3057\u3066\u304f\u308c\u3066\u3044\u308b<code>artisan<\/code>\u30b3\u30de\u30f3\u30c9\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\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:livewire birthday<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u4ee5\u4e0b\uff12\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u81ea\u52d5\u7684\u306b\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<ul>\n<li>\/app\/Http\/Livewire\/Birthday.php\u3000\u30fb\u30fb\u30fb\u3000\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u7ba1\u7406\u3059\u308bPHP\u30af\u30e9\u30b9<\/li>\n<li>\/resources\/views\/livewire\/birthday.blade.php\u3000\u30fb\u30fb\u30fb\u3000\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u30d3\u30e5\u30fc<\/li>\n<\/ul>\n<h1>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u5fc5\u8981\u306a\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3059\u308b<\/h1>\n<p>\u5148\u307b\u3069\u4f5c\u6210\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u5fc5\u8981\u306a\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u305d\u308c\u305e\u308c\u307f\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>PHP\u30af\u30e9\u30b9<\/h2>\n<p>\u4e2d\u8eab\u306f<code>livewire<\/code>\u304c\u7528\u610f\u3057\u3066\u3044\u308b<code>Componet<\/code>\u30af\u30e9\u30b9\u3092\u62e1\u5f35\u3059\u308b\u5f62\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5909\u66f4\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong><code>\/app\/Http\/Livewire\/Birthday.php<\/code><\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Livewire;\r\n\r\nuse Carbon\\Carbon;\r\nuse Livewire\\Component;\r\n\r\nclass Birthday extends Component\r\n{\r\n    \/\/ \u3053\u3053\u306e\u5909\u6570\u304c\u30d3\u30e5\u30fc\u5185\u3067\u5909\u6570\u3068\u3057\u3066\u4f7f\u3048\u308b\r\n    <strong>public $year = 0;<\/strong>\r\n<strong>    public $month = 0;<\/strong>\r\n<strong>    public $day = 0;<\/strong>\r\n<strong>    public $age = -1;<\/strong>\r\n<strong>    public $last_day_of_month = 0;<\/strong>\r\n\r\n    \/\/ \u6e96\u5099\u304c\u5b8c\u4e86\u3057\u305f\u3089\u5b9f\u884c\u3055\u308c\u308b\r\n   <strong> public function mount($year = 0, $month = 0, $day = 0) {<\/strong>\r\n\r\n<strong>        $this-&gt;year = $year;<\/strong>\r\n<strong>        $this-&gt;month = $month;<\/strong>\r\n<strong>        $this-&gt;day = $day;<\/strong>\r\n<strong>        $this-&gt;onChange();<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n    \/\/ \u5165\u529b\u30dc\u30c3\u30af\u30b9\u306b\u5909\u66f4\u304c\u3042\u3063\u305f\u5834\u5408\u306b\u547c\u3070\u308c\u308b\r\n    public function onChange()\r\n    {\r\n        $year = intval($this-&gt;year);\r\n        $month = intval($this-&gt;month);\r\n        $day = intval($this-&gt;day);\r\n\r\n        \/\/ \u8a72\u5f53\u6708\u306e\u65e5\uff0828\u301c31\u65e5\uff09\u3092\u8a08\u7b97\r\n        <strong>if($year &gt; 0 &amp;&amp; $month &gt; 0) {<\/strong>\r\n\r\n<strong>            $this-&gt;last_day_of_month = Carbon::create($this-&gt;year, $this-&gt;month)-&gt;endOfMonth()-&gt;day;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n        \/\/ \u5e74\u9f62\u3092\u8a08\u7b97\r\n        <strong>if(checkdate($month, $day, $year)) {<\/strong>\r\n\r\n<strong>            $this-&gt;age = Carbon::createFromDate($this-&gt;year, $this-&gt;month, $this-&gt;day)-&gt;age;<\/strong>\r\n\r\n<strong>        } else {<\/strong>\r\n\r\n<strong>            $this-&gt;age = -1;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n\r\n    public function render()\r\n    {\r\n        return view('livewire.birthday');\r\n    }\r\n}<\/pre>\n<p>\u307e\u305a\u3001\u3053\u3053\u3067\u91cd\u8981\u306a\u306e\u304c\u300cpublic\u30e1\u30f3\u30d0\u5909\u6570\u300d\u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306e\u30b3\u30fc\u30c9\u3067\u306f\uff15\u3064\u5909\u6570\u3092\u5ba3\u8a00\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u3089\u306f\u81ea\u52d5\u7684\u306b<code>\/resources\/views\/livewire\/birthday.blade.php<\/code>\u306e\u4e2d\u3067\u3001\u901a\u5e38\u306e\u5909\u6570\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>{{ $year }}\r\n{{ $month }}\r\n{{ $day }}\r\n{{ $age }}\r\n{{ $last_day_of_month }}<\/pre>\n<p>\u7d9a\u3044\u3066<code>mount()<\/code>\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u6e96\u5099\u304c\u3067\u304d\u305f\u6642\u70b9\u3067\u547c\u3070\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<p>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306e\u547c\u3073\u51fa\u3057\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u3053\u306e<code>mount()<\/code>\u306b\u5f15\u6570\u3092\u7528\u610f\u3057\u3066\u3044\u308b\u3068\u305d\u306e\u6b21\u306e\u3088\u3046\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><strong>@livewire('birthday')<\/strong>\r\n\r\n\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3042\u308a\u2193\u2193\u2193\r\n\r\n<strong>@livewire('birthday', 2000, 12, 31)<\/strong><\/pre>\n<p>\u307e\u305f\u3001<code>onChange()<\/code>\u306f\uff08\u5e74\u30fb\u6708\u30fb\u65e5\uff09\u304c\u5909\u66f4\u3055\u308c\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u304c\u3001\u3053\u306e\u4e2d\u3067\u306f\u4ee5\u4e0b\uff12\u3064\u306e\u3053\u3068\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u300c\u65e5\u300d\u306e\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u306e\u5185\u5bb9\u3092\u5909\u66f4\uff0828\u65e5\u301c31\u65e5\uff09<\/li>\n<li>\u5e74\u9f62\u3092\u8a08\u7b97<\/li>\n<\/ul>\n<h2>\u30d3\u30e5\u30fc<\/h2>\n<p>\u3067\u306f\u3001\u30d3\u30e5\u30fc\u306b\u3082\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong><code>\/resources\/views\/livewire\/birthday.blade.php<\/code><\/strong><\/p>\n<pre>&lt;div&gt;\r\n\r\n    &lt;!-- \u5e74 --&gt;\r\n    <strong>&lt;select name=\"birth-year\" wire:model=\"year\" wire:change=\"onChange\"&gt;<\/strong>\r\n<strong>        &lt;option&gt;&lt;\/option&gt;<\/strong>\r\n<strong>        @for($i = 1900 ; $i &lt;= date('Y') ; $i++)<\/strong>\r\n<strong>        &lt;option value=\"{{ $i }}\"&gt;{{ $i }}\u5e74&lt;\/option&gt;<\/strong>\r\n<strong>        @endfor<\/strong>\r\n<strong>    &lt;\/select&gt;<\/strong>\r\n\r\n    &lt;!-- \u6708 --&gt;\r\n    <strong>&lt;select name=\"birth-month\" wire:model=\"month\" wire:change=\"onChange\"&gt;<\/strong>\r\n<strong>        &lt;option&gt;&lt;\/option&gt;<\/strong>\r\n<strong>        @for($i = 1 ; $i &lt;= 12 ; $i++)<\/strong>\r\n<strong>        &lt;option value=\"{{ $i }}\"&gt;{{ $i }}\u6708&lt;\/option&gt;<\/strong>\r\n<strong>        @endfor<\/strong>\r\n<strong>    &lt;\/select&gt;<\/strong>\r\n\r\n    &lt;!-- \u65e5 --&gt;\r\n    <strong>&lt;select name=\"birth-day\" wire:model=\"day\" wire:change=\"onChange\"&gt;<\/strong>\r\n<strong>        &lt;option&gt;&lt;\/option&gt;<\/strong>\r\n<strong>        @for($i = 1 ; $i &lt;= $last_day_of_month ; $i++)<\/strong>\r\n<strong>        &lt;option value=\"{{ $i }}\"&gt;{{ $i }}\u65e5&lt;\/option&gt;<\/strong>\r\n<strong>        @endfor<\/strong>\r\n<strong>    &lt;\/select&gt;<\/strong>\r\n\r\n    &lt;!-- \u5e74\u9f62 --&gt;\r\n    <strong>@if($age &gt; -1)<\/strong>\r\n<strong>        &amp;nbsp;\/&amp;nbsp;{{ $age }} \u624d<\/strong>\r\n<strong>    @endif<\/strong>\r\n\r\n&lt;\/div&gt;<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u3001\uff08\u5e74\u30fb\u6708\u30fb\u65e5\uff09\u306e\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u3068\u5e74\u9f62\u3092\u8868\u793a\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u304c\u3001\u91cd\u8981\u306a\u306e\u306f\u300c\u65e5\u300d\u306e\u30bb\u30ec\u30af\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u3042\u308b<code>$last_day_of_month<\/code>\u306e\u90e8\u5206\u3067\u3059\u3002\u306a\u305c\u306a\u3089\u3001\u3053\u306e\u6570\u5b57\u304c\u6761\u4ef6\u306b\u3088\u3063\u306628\u65e5\u301c31\u65e5\u306b\u5909\u66f4\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u5e74\u9f62\u306f<code>-1<\/code>\uff08\u521d\u671f\u5024\uff09\u306e\u5834\u5408\u306f\u8868\u793a\u3092\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u8868\u793a\u3055\u305b\u308b<\/h1>\n<p>\u3067\u306f\u3001\u3053\u3053\u307e\u3067\u3067\u4f5c\u6210\u3057\u305f\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092<code>Laravel<\/code>\u306e\u30da\u30fc\u30b8\u306b\u8868\u793a\u3055\u305b\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3068\u306f\u3044\u3063\u3066\u3082\u3001<code>livewire<\/code>\u5c02\u7528\u306e\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u30d3\u30e5\u30fc\u5185\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    <strong>@livewireStyles<\/strong>\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div&gt;\r\n    <strong>@livewire('birthday')<\/strong>\r\n&lt;\/div&gt;\r\n<strong>@livewireScripts<\/strong>\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>\u3010\u8ffd\u8a18\uff1a2020.3.21\u3011<\/strong>\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u306b\u3088\u308b\u5909\u66f4\u304c\u3042\u3063\u305f\u305f\u3081\u4fee\u6b63\u3057\u307e\u3057\u305f\u3002\u904e\u53bb\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u306f<code>@livewireStyles<\/code>\u3001<code>@livewireScripts<\/code>\u306e\u4ee3\u308f\u308a\u306b<code>@livewireAssets<\/code>\u3092\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><code>@livewire('*****')<\/code>\u304c\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u672c\u4f53\u3001\u305d\u3057\u3066<code>@livewireStyles<\/code>\u3001<code>@livewireScripts<\/code>\u304c\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u3068JavaScript\u3092\u63cf\u753b\u3059\u308b\u90e8\u5206\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b\uff08\u52d5\u753b\uff09<\/h1>\n<p>\u3067\u306f\u3001\u4eca\u56de\u4f5c\u6210\u3057\u305f<code>livewire<\/code>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff01\uff082000\u5e74\u306f\u3046\u308b\u3046\u5e74\u306a\u306e\u3067\u30012\u6708\u304c29\u65e5\u307e\u3067\u3042\u308b\u3053\u3068\u306b\u6ce8\u76ee\u3057\u3066\u898b\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<p><iframe loading=\"lazy\" title=\"\u3010Laravel + livewire\u3011\u8a95\u751f\u65e5\u304b\u3089\u5e74\u9f62\u3092\u81ea\u52d5\u7684\u306b\u8868\u793a\u3059\u308b\u30b5\u30f3\u30d7\u30eb\" width=\"525\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/jk5z565F3tA?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\uff01<\/p>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\ud83d\ude0a\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u306f\u3058\u3081\u3066<code>livewire<\/code>\u306b\u6311\u6226\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u4f7f\u3063\u3066\u307f\u305f\u611f\u60f3\u3068\u3057\u3066\u306f\u3001\u300c\u76f4\u611f\u7684\u3067\u4f7f\u3044\u3084\u3059\u3044\uff01\u300d\u3067\u3057\u305f\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001<code>livewire<\/code>\u3068\u8a00\u3063\u3066\u3082\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306f<code>Blade<\/code>\u304c\u4f7f\u3048\u307e\u3059\u3057\u3001PHP\u5074\u3082\u901a\u5e38\u3088\u304f\u3042\u308b\u30af\u30e9\u30b9\u306e\u30d1\u30bf\u30fc\u30f3\u3068\u540c\u3058\u306a\u306e\u3067\u3001Laravel\u3092\u4f7f\u3063\u3066\u308b\u65b9\u3067\u3057\u305f\u3089\u3059\u3050\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002JavaScript\u30b3\u30fc\u30c9\u3082\u3059\u3067\u306b\u7528\u610f\u3057\u3066\u304f\u308c\u3066\u3044\u307e\u3059\u3057\u306d\ud83d\ude1a<\/p>\n<p>\u305f\u3060\u3001\u4e00\u70b9\u3060\u3051\u3053\u308c\u304b\u3089\u306e\u958b\u767a\u306b\u671f\u5f85\u3057\u305f\u3044\u90e8\u5206\u304c\u3042\u3063\u3066\u3001\u305d\u308c\u304c\u300c\u30d0\u30a4\u30f3\u30c7\u30a3\u30f3\u30b0\u30c7\u30fc\u30bf\u3092JavaScript\u5074\u304b\u3089\u53d6\u5f97\u3057\u3084\u3059\u304f\u3057\u3066\u307b\u3057\u3044\u300d\u3068\u3044\u3046\u3082\u306e\u3067\u3057\u305f\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001<code>livewire<\/code>\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u5185\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\u306b\u306f\u3001<code>document.getElementById<\/code>\u3084<code>document.querySelector<\/code>\u3092\u4f7f\u3063\u3066\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3088\u3046\u306a\u306e\u3067\u3059\u304c\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092\u540c\u3058\u30da\u30fc\u30b8\u3067\u8907\u6570\u4f7f\u3046\u5834\u5408\u306f\u5c11\u3057\u3084\u3084\u3053\u3057\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>ref<\/code>\u3084<code>id<\/code>\u3092\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u30fb\u30fb\u30fb<\/p>\n<pre>&lt;!-- \u6ce8\uff1a\u3053\u306e\u3084\u308a\u65b9\u306f\u5b58\u5728\u3057\u307e\u305b\u3093 --&gt;\r\n\r\n@livewire('birthday')\r\n    <strong>@ref('my-birthday')<\/strong>\r\n@endlivewire\r\n\r\n&lt;lw:birthday <strong>id=\"partners-birthday\"<\/strong>&gt;&lt;\/lw:birthday&gt;<\/pre>\n<p>Vue\u306e\u3088\u3046\u306b\u5024\u304c\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308c\u3070\u3088\u308a\u4fbf\u5229\u304b\u306a\u3068\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<pre><strong>\/\/ \u6ce8\uff1a\u3053\u306e\u3084\u308a\u65b9\u306f\u5b58\u5728\u3057\u307e\u305b\u3093\r\nlivewire.$refs['my-birthday'].year;<\/strong><\/pre>\n<p>\u3068\u3044\u3063\u3066\u3082\u3001\u73fe\u6642\u70b9\u3067<code>GitHub<\/code>\u306e\u30b9\u30bf\u30fc\u304c<code>781<\/code>\u3068\u306a\u3063\u3066\u3044\u3066\u76f8\u5f53\u6ce8\u76ee\u3092\u96c6\u3081\u3066\u3044\u308b\u306e\u3067\u3001\u304d\u3063\u3068\u3053\u308c\u304b\u3089\u9032\u5316\u3057\u3066\u3044\u304f\u3068\u601d\u3044\u307e\u3059\u3002\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u79c1\u3082\u3053\u308c\u304b\u3089\u306e<code>livewire<\/code>\u306b\u6ce8\u76ee\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\uff08\u6642\u9593\u304c\u51fa\u6765\u305f\u3089<code>pull request<\/code>\u3068\u304b\u3057\u3066\u307f\u3088\u3046\u304b\u306a\uff09<\/p>\n<p>\u305c\u3072\u3001\u7686\u3055\u3093\u3082<code>livewire<\/code>\u306b\u6311\u6226\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4445 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2.png\" alt=\"\" width=\"370\" height=\"310\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2-300x251.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u306b\u8a18\u4e8b\u3092\u66f8\u304f\u305f\u3081\u306b\u666e\u6bb5\u304b\u3089\u3044\u308d\u3044\u308d\u306a\u60c5\u5831\u3092\u96c6\u3081\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u3067\u3082\u306f\u3084\u308a\u9650\u754c\u304c\u3042\u3063\u3066\u5168\u3066\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u306f\u96e3\u3057\u3044\u3082\u306e\u3067\u3059\u3002 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=4466\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel + livewire\u3067\u8a95\u751f\u65e5\u304b\u3089\u5e74\u9f62\u3092\u81ea\u52d5\u8a08\u7b97\u3059\u308b\u30b5\u30f3\u30d7\u30eb&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":4474,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[168],"class_list":["post-4466","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-livewire"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/4466","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=4466"}],"version-history":[{"count":13,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/4466\/revisions"}],"predecessor-version":[{"id":6293,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/4466\/revisions\/6293"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/4474"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}