{"id":3194,"date":"2026-08-28T13:15:34","date_gmt":"2026-08-28T04:15:34","guid":{"rendered":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/?page_id=3194"},"modified":"2026-08-28T13:21:34","modified_gmt":"2026-08-28T04:21:34","slug":"laravel-07","status":"publish","type":"page","link":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/programming\/php\/laravel-07","title":{"rendered":"\u8a8d\u53ef\u3068\u30a2\u30af\u30bb\u30b9\u5236\u5fa1"},"content":{"rendered":"<details>\n  <summary>\n    \u524d\u56de\u7d42\u4e86\u6642\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\n  <\/summary>\n  <p>Laravel\u3092\u4f7f\u3063\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n<div class='console'><pre>\n$ git clone https:\/\/kiku3.tsbio.info\/git\/study-laravel.git study_laravel\n<\/pre><\/div>\n\n<p>\u3053\u306e\u7ae0\u958b\u59cb\u6642\u70b9\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f chapt7 \u30d6\u30e9\u30f3\u30c1\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<div class='console'><pre>\n$ git switch chapt7\n<\/pre><\/div>\n\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u81ea\u5206\u3067\u66f8\u3044\u3066\u3044\u304f\u5834\u5408\u306f\u3001\u81ea\u5206\u7528\u306e\u30d6\u30e9\u30f3\u30c1\u3092\u3064\u304f\u308b\u3068\u3088\u3044\u3067\u3059\u3002<\/p>\n<div class='console'><pre>\n$ git switch -c my7 chapt7\n<\/pre><\/div>\n\n<p>Laravel\u306e\u30b3\u30fc\u30c9\u306fsrc\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089\u306e\u76f8\u5bfe\u30d1\u30b9\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<\/details>\n\n\n<h2>\u8a8d\u53ef (Authorization) \u3068<\/h2>\n<p>\u524d\u7ae0\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u8a8d\u8a3c (authentication) \u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\n\u6b21\u306f\u3069\u306e\u30e6\u30fc\u30b6\u30fc\u306f\u4f55\u304c\u3067\u304d\u308b\u306e\u304b\u3092\u8a8d\u53ef (authorization) \u3059\u308b\u3057\u304f\u307f\u3092\u3064\u304f\u308a\u307e\u3059\u3002\nLaravel\u3067\u306f\u5f79\u5272 (role) \u3068\u6a29\u9650 (permission) \u3067\u30e6\u30fc\u30b6\u30fc\u306e\u30a2\u30af\u30bb\u30b9\u3092\u5236\u5fa1\u3057\u307e\u3059\u3002<\/p>\n<p>\u6a29\u9650\u306f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u6a5f\u80fd(\u4e3b\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3059\u308b\u64cd\u4f5c)\u306b\u5bfe\u3057\u3066\u8a2d\u5b9a\u3057\u307e\u3059\u3002\noligo\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3057\u3066\u3001select\u3067\u304d\u308b\u6a29\u9650\u3001insert\u3067\u304d\u308b\u6a29\u9650\u3001\u3068\u3044\u3046\u3088\u3046\u611f\u3058\u3067\u3059\u3002\n\u4f8b\u3048\u3070select\u3067\u3042\u308c\u3070\u3001<code>Oligo::all()<\/code> \u3068\u3044\u3046\u5f62\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u4e2d\u306b\u73fe\u308c\u308b\u306e\u3067\u3001\u3053\u306e\u90e8\u5206\u3092\u5b9f\u884c\u3067\u304d\u308b\u304b\u3069\u3046\u304b\u3068\u3044\u3046\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>oligo\u30c6\u30fc\u30d6\u30eb\u306b\u5bfe\u3057\u3066select\u3067\u304d\u308b\u6a29\u9650\u3092oligo.read\u3068\u540d\u4ed8\u3051\u305f\u3068\u3057\u307e\u3059\u3002\n\u3053\u306e\u540d\u79f0\u81ea\u4f53\u304c\u306a\u306b\u304b\u306e\u52b9\u679c\u3092\u6301\u3064\u3082\u306e\u3067\u306f\u306a\u3044\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u6a29\u9650\u540d\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u95a2\u9023\u4ed8\u3051\u308b\u306e\u306f\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u8cac\u4efb\u3067\u3059\u3002\n<code>Oligo::all()<\/code>\u304c\u3042\u308b\u306e\u306fOligoController\u306eindex\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\noligo.read\u306e\u6a29\u9650\u3092\u3082\u3064\u30e6\u30fc\u30b6\u30fc\u306b\u306e\u307f <code>Oligo::all()<\/code> \u3092\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001<code>if($user-&gt;can('oligo.read')) Oligo::all();<\/code> \u3068\u3044\u3046\u3088\u3046\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3059\u3002\n\u8a8d\u53ef\u306f\u3001<strong>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3067\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u30e1\u30bd\u30c3\u30c9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u5236\u5fa1\u3059\u308b\u65b9\u6cd5<\/strong>\u3001<strong>\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30b3\u30fc\u30c9\u306e\u5b9f\u884c\u3092\u5236\u5fa1\u3059\u308b\u65b9\u6cd5<\/strong>\u3001<strong>\u30d3\u30e5\u30fc\u3067\u8868\u793a\u3092\u5236\u5fa1\u3059\u308b\u65b9\u6cd5<\/strong>\u3001\u306a\u3069\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u3054\u3068\u306b\u6a29\u9650\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304f\u306e\u306f\u5927\u5909\u306a\u306e\u3067\u3001\u3044\u304f\u3064\u304b\u306e\u6a29\u9650\u3092\u30bb\u30c3\u30c8\u306b\u3057\u3066\u5f79\u5272 (role) \u3068\u3057\u307e\u3059\u3002\n\u3053\u306e\u5f79\u5272\u3092\u30e6\u30fc\u30b6\u30fc\u306b\u308f\u308a\u3042\u3066\u308b\u3053\u3068\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u3068\u6a29\u9650\u304c\u7d50\u3073\u4ed8\u3051\u3089\u308c\u3001\u6a29\u9650\u306e\u6709\u7121\u3092\u5224\u5b9a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>spatie\/laravel-permission\u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u306f permissions\u3001roles\u306a\u3069\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u3064\u304f\u308a\u3001users\u3068\u7d50\u5408\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<h3>spatie\/laravel-permission\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h3>\n<p>spatie\/laravel-permission\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002\n\u7d9a\u3044\u3066\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059 (migrate)\u3002<\/p>\n<div class='console'><pre>\n# composer require spatie\/laravel-permission\n# artisan vendor:publish --provider=\"Spatie\\Permission\\PermissionServiceProvider\"\n# .\/artizan migrate\n<\/pre><\/div>\n<h3>\u30e6\u30fc\u30b6\u30fc\u30e2\u30c7\u30eb\u306e\u4fee\u6b63<\/h3>\n<p>Spatie\u304c\u63d0\u4f9b\u3059\u308b\u6a29\u9650\u306e\u78ba\u8a8d\u306e\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3092Model\/User\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p><\/p>\n<div class='code'>\n  <h5 class=\"source-file\">app\/Models\/User.php<\/h5>\n<pre >\n&lt;?php\n \nnamespace App\\Models;\n \n\/\/ use Illuminate\\Contracts\\Auth\\MustVerifyEmail;\nuse Database\\Factories\\UserFactory;\nuse Illuminate\\Database\\Eloquent\\Attributes\\Fillable;\nuse Illuminate\\Database\\Eloquent\\Attributes\\Hidden;\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse Illuminate\\Notifications\\Notifiable;\nuse Spatie\\Permission\\Traits\\HasRoles;  \/\/ \u8a8d\u53ef\u306b\u95a2\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\n \n#[Fillable([&#039;name&#039;, &#039;email&#039;, &#039;password&#039;])]\n#[Hidden([&#039;password&#039;, &#039;remember_token&#039;])]\nclass User extends Authenticatable\n{\n    \/** @use HasFactory&lt;UserFactory&gt; *\/\n    use HasFactory, Notifiable, HasRoles; \/\/ HasRoles\u3092\u8ffd\u52a0\n \n    \/**\n     * Get the attributes that should be cast.\n     *\n     * @return array&lt;string, string&gt;\n     *\/\n    protected function casts(): array\n    {\n        return [\n            &#039;email_verified_at&#039; =&gt; &#039;datetime&#039;,\n            &#039;password&#039; =&gt; &#039;hashed&#039;,\n        ];\n    }\n}\n<\/pre>\n<\/div>\n<h3>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u767b\u9332<\/h3>\n<p>tinker\u3067\u8a66\u3057\u307e\u3059\u3002<\/p>\n<div class='console'><pre>\n# .\/artisan tinker\n> use Spatie\\Permission\\Models\\Permission\n> $ow = Permission::create(['name' => 'oligo.write'])  # oligo.write\u3068\u3044\u3046\u6a29\u9650\u3092\u8ffd\u52a0\n= Spatie\\Permission\\Models\\Permission {#294\n  guard_name: \"web\",\n  name: \"oligo.write\",\n  updated_at: \"2026-08-28 01:48:37\",\n  created_at: \"2026-08-28 01:48:37\",\n  id: 25,\n}\n> $or = Permission::create(['name' => 'oligo.read']) # oligo.read\u3068\u3044\u3046\u6a29\u9650\u3092\u8ffd\u52a0\n= Spatie\\Permission\\Models\\Permission {#7546\n  guard_name: \"web\",\n  name: \"oligo.read\",\n  updated_at: \"2026-08-28 01:48:48\",\n  created_at: \"2026-08-28 01:48:48\",\n  id: 26,\n}\n> use Spatie\\Permission\\Models\\Role\n> $role = Role::create(['name' => 'oligo.user']) # oligo.user\u3068\u3044\u3046\u5f79\u5272\u3092\u8ffd\u52a0\n= Spatie\\Permission\\Models\\Role {#8044\n  guard_name: \"web\",\n  name: \"oligo.user\",\n  updated_at: \"2026-08-28 01:49:36\",\n  created_at: \"2026-08-28 01:49:36\",\n  id: 2,\n}\n> $role->syncPermissions($or)  # oligo.user\u306boligo.read\u3092\u4ed8\u4e0e\n= Spatie\\Permission\\Models\\Role {#8044\n  guard_name: \"web\",\n  name: \"oligo.user\",\n  updated_at: \"2026-08-28 01:49:36\",\n  created_at: \"2026-08-28 01:49:36\",\n  id: 2,\n}\n> use App\\Models\\User\n> $user = User::first()\n= App\\Models\\User {#8891\n  id: 2,\n  name: \"test user\",\n  email: \"test@example.com\",\n  email_verified_at: null,\n  #password: \"\\$2yxxx\",\n  #remember_token: null,\n  created_at: \"2026-08-26 02:14:30\",\n  updated_at: \"2026-08-26 02:14:30\",\n}\n> $user->syncRoles($role)  # test user\u306boligo.user\u3068\u3044\u3046\u5f79\u5272\u3092\u4ed8\u4e0e\n> $user->can('oligo.read') # test user\u306foligo.read\u6a29\u9650\u3092\u6301\u3064\u304b? -> true\n= true\n>\u3000$user->can('oligo.write') # test user\u306foligo.write\u6a29\u9650\u3092\u6301\u3064\u304b? -> false\n= false\n<\/pre><\/div>\n<h2>\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/h2>\n<h3>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u6bb5\u968e\u3067\u306e\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/h3>\n<p>\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306b can:oligo.read \u3092\u8ffd\u52a0\u3059\u308b\u3002\noligo.write\u306b\u3059\u308b\u3068\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u304f\u306a\u308b\u3002<\/p>\n<p><\/p>\n<div class='code'>\n  <h5 class=\"source-file\">routes\/oligo.php<\/h5>\n<pre >\n&lt;?php\n \nuse Illuminate\\Support\\Facades\\Route;\nuse App\\Http\\Controllers\\OligoController;\n \n\/\/ \u30aa\u30ea\u30b4DNA\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\nRoute::middleware([&#039;auth&#039;, &#039;verified&#039;, &#039;can:oligo.read&#039;])\n    \/* can\u306fAuthorize\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u5225\u540d\u3068\u3057\u3066\u767b\u9332\u3055\u308c\u3066\u3044\u308b\n     * oligo.read\u3092oligo.write\u306b\u5909\u3048\u308b\u3068 \/oligo \u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u304f\u306a\u308b\n     *\/\n    -&gt;prefix(&#039;\/oligo&#039;)\n    -&gt;as(&#039;web.oligo.&#039;)\n    -&gt;group(function (){\n        Route::get(&#039;\/&#039;, [OligoController::class, &#039;index&#039;])-&gt;name(&#039;index&#039;);\n        Route::get(&#039;\/search&#039;, [OligoController::class, &#039;search&#039;])-&gt;name(&#039;search&#039;);\n        Route::get(&#039;\/create&#039;, [OligoController::class, &#039;create&#039;])-&gt;name(&#039;create&#039;);\n        Route::post(&#039;\/&#039;, [OligoController::class, &#039;store&#039;])-&gt;name(&#039;store&#039;);\n \n        \/\/ \u7de8\u96c6\u30d5\u30a9\u30fc\u30e0\u3068\u30c7\u30fc\u30bf\u66f4\u65b0\n        Route::get(&#039;\/edit&#039;, [OligoController::class, &#039;edit&#039;])-&gt;name(&#039;edit&#039;);\n        Route::put(&#039;\/{item}&#039;, [OligoController::class, &#039;update&#039;])-&gt;name(&#039;update&#039;);\n    });\n<\/pre>\n<\/div>\n<h3>\u30c7\u30fc\u30bf\u53d6\u5f97\u6bb5\u968e\u3067\u306e\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/h3>\n<p>Request\u304b\u3089User\u3092\u53d6\u5f97\u3057\u3066\u3001can\u3092\u4f7f\u3046\u3002\n\u307e\u305f\u306f Gate\u306eauthorize\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<p><\/p>\n<div class='code'>\n  <h5 class=\"source-file\">app\/Http\/Controllers\/OligoController.php<\/h5>\n<pre >\n&lt;?php\n \nnamespace App\\Http\\Controllers;\n \nuse App\\Models\\Oligo;\nuse App\\Services\\OligoService;\nuse App\\Http\\Requests\\OligoRequest;\nuse App\\Http\\Requests\\OligoSearchRequest;\nuse App\\Http\\Requests\\OligosRequest;\n \nclass OligoController\n{\n    public function __construct(\n        private OligoService $service\n    ) {\n    }\n \n    public function index(){\n \n        \/*\n         * oligo.read\u6a29\u9650\u304c\u4ed8\u4e0e\u3055\u308c\u3066\u3044\u308c\u3070\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u308b\u3002\n         *\/\n        if(request()-&gt;user()-&gt;can(&#039;oligo.read&#039;)){\n            $items = Oligo::all();\n        }else{\n            $items = [];\n        }\n \n        return view(&#039;oligo.index&#039;, compact(&#039;items&#039;))\n            -&gt;fragmentIf(request()-&gt;hasHeader(&#039;HX-Request&#039;), &quot;feature-oligo-index&quot;)\n        ;\n    }\n \n    public function create(){\n        return view(&#039;oligo.create&#039;)\n            -&gt;fragmentIf(request()-&gt;hasHeader(&#039;HX-Request&#039;), &quot;feature-oligo-create&quot;)\n        ;\n    }\n \n    public function store(OligosRequest $request){\n \n        \/*\n         * oligo.write\u6a29\u9650\u304c\u306a\u3051\u308c\u3070HTTP \u30ec\u30b9\u30dd\u30f3\u30b9 403\u3092\u51fa\u3057\u3066\u7d42\u4e86\u3059\u308b\n         *\/\n        \\Illuminate\\Support\\Facades\\Gate::authorize(&#039;oligo.write&#039;);\n        \n        try{\n            $oligos = $request-&gt;validOligos;\n            $data = $this-&gt;service-&gt;create($oligos);\n \n            return response()-&gt;json(array_merge($data, [\n                &#039;status&#039; =&gt; &#039;success&#039;, \n                &#039;input&#039; =&gt; $oligos,\n            ]), 200);\n        }catch(\\Throwable $e){\n            return response()-&gt;json([&#039;status&#039; =&gt; &#039;error&#039;, &#039;message&#039; =&gt; $e-&gt;getMessage()], 400);\n        }\n    }\n \n    \/\/ \u691c\u7d22\n    public function search(OligoSearchRequest $request)\n    {\n        try{\n            $query = $request-&gt;validated();\n\t    $query[&#039;use_regex&#039;] = $query[&#039;use_regex&#039;] ?? false;\n            return response()-&gt;json([\n                &#039;status&#039; =&gt; &#039;success&#039;,\n                &#039;data&#039; =&gt; $this-&gt;service-&gt;search($query),\n            ], 200);\n \n        }catch(\\Throwable $e){\n            return response()-&gt;json([&#039;status&#039; =&gt; &#039;error&#039;, &#039;message&#039; =&gt; $e-&gt;getMessage()], 400);\n        }\n    }\n \n    public function edit(){\n        return view(&#039;oligo.edit&#039;)\n            -&gt;fragmentIf(request()-&gt;hasHeader(&#039;HX-Request&#039;), &quot;feature-oligo-edit&quot;)\n        ;\n    }\n \n    public function update(OligoRequest $request, Oligo $item){\n        try{\n            $item-&gt;update($request-&gt;validated());\n \n            return response()-&gt;json([\n                &#039;status&#039; =&gt; &#039;success&#039;, \n                &#039;item&#039; =&gt; $item,\n            ], 200);\n        }catch(\\Throwable $e){\n            return response()-&gt;json([&#039;status&#039; =&gt; &#039;error&#039;, &#039;message&#039; =&gt; $e-&gt;getMessage()], 400);\n        }\n    }\n}\n<\/pre>\n<\/div>\n<h3>\u30d3\u30e5\u30fc\u3067\u306e\u30a2\u30af\u30bb\u30b9\u5236\u5fa1<\/h3>\n<p><\/p>\n<div class='code'>\n  <h5 class=\"source-file\">resources\/views\/oligo\/module.blade.php<\/h5>\n<pre >\n@extends(&#039;layouts.app&#039;)\n \n@section(&#039;module&#039;)\n  @php($module = &#039;oligo&#039;)  {{-- \u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u3092\u5909\u6570\u306b\u8a2d\u5b9a --}}\n  &lt;x-module id=&#039;{{ $module }}&#039;&gt;\n    &lt;!-- \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30e1\u30cb\u30e5\u30fc --&gt;\n    &lt;nav&gt;\n      &lt;ul class=&#039;feature-tabs&#039; role=&#039;tablist&#039;&gt;\n        @foreach([\n          {{-- \u30d5\u30a3\u30fc\u30c1\u30e3\u30fc\u3054\u3068\u306e\u8a2d\u5b9a --}}\n          &#039;index&#039; =&gt; [&#039;label&#039; =&gt; &#039;\u4e00\u89a7&#039;, &#039;permission&#039; =&gt; &#039;read&#039;],\n          &#039;create&#039; =&gt; [&#039;label&#039; =&gt; &#039;\u8ffd\u52a0&#039;, &#039;permission&#039; =&gt; &#039;write&#039;],\n          &#039;edit&#039; =&gt; [&#039;label&#039; =&gt; &#039;\u7de8\u96c6&#039;, &#039;permission&#039; =&gt; &#039;write&#039;],\n        ] as $page =&gt; $conf)\n          {{-- \u6a29\u9650\u306e\u6709\u7121\u3067\u9805\u76ee\u3092\u8868\u793a\u30fb\u975e\u8868\u793a\u306b\u3059\u308b --}}\n          @can(&quot;$module.${conf[&#039;permission&#039;]}&quot;)\n            &lt;li class=&#039;feature-tab&#039;\n              :class=&quot;{\n                &#039;bg-white&#039;: activeFeature === &#039;{{ $module }}-{{ $page }}&#039;,\n                &#039;bg-gray-400 hover:bg-gray-200&#039;: activeFeature !== &#039;{{ $module }}-{{ $page }}&#039;\n              }&quot;\n            &gt;\n              &lt;a href=&#039;{{ route(&quot;web.{$module}.{$page}&quot;) }}&#039; id=&#039;{{ $module }}-{{ $page }}-tab&#039; role=&#039;tab&#039;\n                @click.prevent=&quot;selectTab(event)&quot;\n              &gt;\n                {{ $conf[&#039;label&#039;] }}\n              &lt;\/a&gt;\n            &lt;\/li&gt;\n          @endcan\n        @endforeach\n        &lt;li class=&#039;feature-tab bg-gray-400&#039; x-text=&quot;activeFeature&quot;&gt;\n        &lt;\/li&gt;\n      &lt;\/ul&gt;\n    &lt;\/nav&gt;\n    \n    &lt;div class=&#039;features&#039;\n      {{-- oligo\u30e2\u30b8\u30e5\u30fc\u30eb\u5168\u4f53\u3067\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3053\u3053\u306bx-data\u3092\u5b9a\u7fa9\u3059\u308b --}}\n      x-data=&quot;{\n        items: [], \/\/ \u30c6\u30fc\u30d6\u30eb\u304b\u3089\u62bd\u51fa\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3002\u4eca\u5f8c\u66f4\u65b0\u3084\u524a\u9664\u306e\u6a5f\u80fd\u3067\u3082\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u3053\u3053(#features)\u306b\u5b9a\u7fa9\u3059\u308b\u3002\n        query: {}, \/\/ \u691c\u7d22\u306e\u6761\u4ef6\u3002x-model\u3068\u3057\u3066\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u5165\u529b\u30d5\u30a9\u30fc\u30e0\u306e\u5024\u304c\u305d\u306e\u307e\u307eJavascript\u3067\u4f7f\u7528\u3067\u304d\u308b\n \n        \/\/ \u691c\u7d22 fetch\u306f\u975e\u540c\u671f(async)\u306b\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067\u3001\u305d\u308c\u306b\u305d\u308d\u3048\u308b\n        async search(){\n          const parameter = new URLSearchParams(this.query);  \/\/ \u540c\u3058x-data\u5185\u306a\u306e\u3067 this.query\u3068\u306a\u308b\u3002\u3053\u308c\u3092GET\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc(?key1=value1&amp;key2=value2)\u306b\u5909\u63db\u3059\u308b\n          console.log(&#039;parameter:&#039;, parameter.toString());  \/\/ \u52d5\u4f5c\u78ba\u8a8d\n          const options = {\n            method: &#039;GET&#039;,\n            headers: {\n              &#039;Accept&#039;: &#039;application\/json&#039;,  \/\/ \u8fd4\u308a\u5024\u306e\u8a2d\u5b9a\u3002Laravel\u304c\u5224\u65ad\u3059\u308b\u306e\u306b\u4f7f\u3046\u3002\n              &#039;Content-Type&#039;: &#039;application\/json&#039;,\n            },\n          };\n \n          return fetch(&#039;{{ route(&quot;web.{$module}.search&quot;) }}?&#039; + parameter.toString(), options)\n            .then(response =&gt; response.json())\n            .then(response =&gt; {\n              console.log(&#039;search done&#039;, response);  \/\/ \u52d5\u4f5c\u78ba\u8a8d\n              return this.append(response.data.items);  \/\/ items\u3092\u7f6e\u304d\u63db\u3048\u308bappend\u3092\u547c\u3076\n            })\n            .catch(error =&gt; {debug(error)})\n          ;\n        },\n \n        \/\/ \u691c\u7d22\u7d50\u679c\u3092items\u306b\u53cd\u6620\u3055\u305b\u308b\u3002\u4eca\u5f8c\u3001\u65b0\u3057\u3044\u691c\u7d22\u7d50\u679c\u3067\u7f6e\u304d\u63db\u3048\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u8ffd\u52a0\u3059\u308b\u3088\u3046\u306b\u4fee\u6b63\u3057\u3066\u3044\u304f\u306e\u3067\u3001append\u3068\u3057\u3066\u3042\u308b\u3002\n        append(items){\n          console.log(&#039;append:&#039;, items);\n          this.items = items;\n        },\n \n        \/\/ \u30c1\u30a7\u30c3\u30af\u304c\u3044\u308c\u3089\u308c\u305f\u3082\u306e\u3060\u3051\u3092\u53d6\u5f97\u3059\u308b\u3002\n        get checked(){\n          return this.items.filter(item =&gt; item.checked);\n        },\n        get hasChecked(){\n          return this.checked.length &gt; 0;\n        }\n      }&quot;\n    &gt;\n      @yield(&#039;feature&#039;)\n    &lt;\/div&gt;\n  &lt;\/x-module&gt;\n@endsection\n<\/pre>\n<\/div>\n<h2>\u6a29\u9650\u306b\u95a2\u3059\u308b\u30a6\u30a7\u30d6\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9<\/h2>\n<p>\u3053\u308c\u306f\u3044\u305a\u308c\u3064\u304f\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u304c\u3001\u5f8c\u56de\u3057\u306b\u3059\u308b\u3002<\/p>\n\n\n\n<div style='display: flex; justify-content: center; gap: 4rem;\n  background-color: #ffefd5;\n  '\n>\n  <a href='laravel-06'>\u524d\u3078<\/a>\n\n<a href='.\/'>PHP\u306e\u5b66\u7fd2 \u76ee\u6b21<\/a>\n\n  <a href='laravel-08'>\u6b21\u3078<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u524d\u56de\u7d42\u4e86\u6642\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9 Laravel\u3092\u4f7f\u3063\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 $ git clone https:\/\/kiku3.tsbio.info\/git\/st [&hellip;]","protected":false},"author":2,"featured_media":0,"parent":2658,"menu_order":7,"comment_status":"closed","ping_status":"closed","template":"page-programming.php","meta":{"footnotes":""},"class_list":["post-3194","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/pages\/3194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/comments?post=3194"}],"version-history":[{"count":4,"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/pages\/3194\/revisions"}],"predecessor-version":[{"id":3200,"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/pages\/3194\/revisions\/3200"}],"up":[{"embeddable":true,"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/pages\/2658"}],"wp:attachment":[{"href":"https:\/\/biochemistry.isc.chubu.ac.jp\/labo\/suzuki\/wp-json\/wp\/v2\/media?parent=3194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}