{"id":79,"date":"2024-11-01T13:39:15","date_gmt":"2024-11-01T04:39:15","guid":{"rendered":"https:\/\/laravel.satoshis.jp\/?p=79"},"modified":"2024-11-22T15:44:35","modified_gmt":"2024-11-22T06:44:35","slug":"twitter%e3%81%ab%e4%bc%bc%e3%81%9f%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%88%e3%81%86","status":"publish","type":"post","link":"https:\/\/laravel.satoshis.jp\/?p=79","title":{"rendered":"Twitter\u306b\u4f3c\u305f\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046"},"content":{"rendered":"<h4>\u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210<\/h4>\n<p>Twitter\u306b\u4f3c\u305f\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u306f\u3001X\u3068Twitter\u306e\u4e21\u65b9\u3092\u30ea\u30b9\u30da\u30af\u30c8\u3057\u3066\u3001xtter\u3068\u3044\u3046\u540d\u524d\u3067\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt;  composer create-project laravel\/laravel xtter\r\n<\/pre>\n<h4>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u7528\u610f<\/h4>\n<p>xtter\u7528\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001MySQL\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; mysql -u root -p\r\n<\/pre>\n<p>MySQL\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u3001\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u30e6\u30fc\u30b6\u30fc\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30e6\u30fc\u30b6\u30fc\u3092\u5272\u308a\u5f53\u3066\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmysql&gt; create database xtter;\r\nQuery OK, 1 row affected (0.00 sec)\r\n \r\nmysql&gt; create user xtter@localhost identified by &#039;xtterdb&#039;;\r\nQuery OK, 0 rows affected (0.01 sec)\r\n \r\nmysql&gt; grant all privileges on xtter.* to xtter@localhost;\r\nQuery OK, 0 rows affected (0.00 sec)\r\n<\/pre>\n<p>VSCode\u3067 .env \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u8a2d\u5b9a\u90e8\u5206\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4fee\u6b63\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; first-line: 24; title: ; notranslate\" title=\"\">\r\nDB_CONNECTION=mysql\r\nDB_HOST=127.0.0.1\r\nDB_PORT=3306\r\nDB_DATABASE=xtter\r\nDB_USERNAME=xtter\r\nDB_PASSWORD=xtterdb\r\n<\/pre>\n<h4>\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210<\/h4>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u3001Laravel\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan migrate\r\n<\/pre>\n<p>mysql\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3067\u30c6\u30fc\u30d6\u30eb\u304c\u3067\u304d\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nMySQL &#x5B;(none)]&gt; use xtter;\r\nDatabase changed\r\nMySQL &#x5B;xtter]&gt; show tables;\r\n+-----------------------+\r\n| Tables_in_xtter       |\r\n+-----------------------+\r\n| cache                 |\r\n| cache_locks           |\r\n| failed_jobs           |\r\n| job_batches           |\r\n| jobs                  |\r\n| migrations            |\r\n| password_reset_tokens |\r\n| sessions              |\r\n| users                 |\r\n+-----------------------+\r\n9 rows in set (0.001 sec)\r\n<\/pre>\n<h4>\u30e6\u30fc\u30b6\u30fc\u8a8d\u8a3c\u6a5f\u80fd\u3092\u6709\u52b9\u306b\u3059\u308b<\/h4>\n<p>\u30ed\u30b0\u30a4\u30f3\u304c\u5fc5\u8981\u306a\u30b5\u30fc\u30d3\u30b9\u306a\u306e\u3067\u3001\u30e6\u30fc\u30b6\u30fc\u8a8d\u8a3c\u6a5f\u80fd\u3092\u6709\u52b9\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f5c\u6210\u3057\u305f xtter \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u95a2\u3057\u3066\u306e\u64cd\u4f5c\u3092\u884c\u3046\u305f\u3081\u306b\u3001xtter \u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; cd xtter\r\n<\/pre>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; composer require laravel\/breeze\r\n&gt; php artisan breeze:install\r\n<\/pre>\n<p>breeze:install \u3067\u306f\u3001\u6700\u521d\u306b\u9078\u629e\u80a2\u3092\u805e\u304b\u308c\u308b\u306e\u3067\u3001blade\u3068\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u305d\u306e\u3042\u3068\u306e\u8cea\u554f\u306b\u306f\u3001ENTER\u3060\u3051\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>Laravel\u306e\u8d77\u52d5<\/h4>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u3001Laravel\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan serv\r\n  forking is not supported on this platform\r\n\r\n   INFO  Server running on &#x5B;http:\/\/127.0.0.1:8000].\r\n\r\n  Press Ctrl+C to stop the server\r\n<\/pre>\n<p>Chrome\u3092\u8d77\u52d5\u3057\u3066\u3001http:\/\/127.0.0.1:8000 \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001Laravel\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Breeze\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308b\u3068\u3001\u753b\u9762\u53f3\u4e0a\u306b\u300cLog in\u300d\u3068\u300cRegister\u300d\u306e\u30ea\u30f3\u30af\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u300cRegister\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u30e6\u30fc\u30b6\u30fc\u767b\u9332\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u78ba\u8a8d<\/h4>\n<p>mysql\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30e6\u30fc\u30b6\u30fc\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; mysql -u root -p\r\nEnter password: *********\r\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\r\nYour MySQL connection id is 18\r\nServer version: 5.7.44-log MySQL Community Server (GPL)\r\n\r\nCopyright (c) 2000, 2023, Oracle and\/or its affiliates.\r\n\r\nOracle is a registered trademark of Oracle Corporation and\/or its\r\naffiliates. Other names may be trademarks of their respective\r\nowners.\r\n\r\nType &#039;help;&#039; or &#039;\\h&#039; for help. Type &#039;\\c&#039; to clear the current input statement.\r\n\r\nmysql&gt; use xtter;\r\nDatabase changed\r\nmysql&gt; select * from users;\r\n+----+----------+--------------------+-------------------+--------------------------------------------------------------+----------------+---------------------+---------------------+\r\n| id | name     | email              | email_verified_at | password                                                     | remember_token | created_at          | updated_at          |\r\n+----+----------+--------------------+-------------------+--------------------------------------------------------------+----------------+---------------------+---------------------+\r\n|  1 | satoshis | satoshis@example.com | NULL              | $2y$12$R2OOAoUymqnEfyX0v6pikOJS92RGFOIJ.uTBFmGnbh7.WJXgx1yqu | NULL           | 2024-11-01 05:11:19 | 2024-11-01 05:11:19 |\r\n+----+----------+--------------------+-------------------+--------------------------------------------------------------+----------------+---------------------+---------------------+\r\n1 row in set (0.00 sec)\r\n\r\nmysql&gt; quit\r\nBye\r\n<\/pre>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u5185\u5bb9\u306f\u3001tinker\u3092\u4f7f\u3046\u3053\u3068\u3067\u3082\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan tinker\r\nPsy Shell v0.12.4 (PHP 8.2.12 \u2014 cli) by Justin Hileman\r\n&gt; App\\Models\\User::all()\r\n= Illuminate\\Database\\Eloquent\\Collection {#5996\r\n    all: &#x5B;\r\n      App\\Models\\User {#5587\r\n        id: 1,\r\n        name: &quot;satoshis&quot;,\r\n        email: &quot;satoshis@example.com&quot;,\r\n        email_verified_at: null,\r\n        #password: &quot;$2y$12$R2OOAoUymqnEfyX0v6pikOJS92RGFOIJ.uTBFmGnbh7.WJXgx1yqu&quot;,\r\n        #remember_token: null,\r\n        created_at: &quot;2024-11-01 05:11:19&quot;,\r\n        updated_at: &quot;2024-11-01 05:11:19&quot;,\r\n      },\r\n    ],\r\n  }\r\n\r\n&gt;\r\n<\/pre>\n<h4>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306b\u30c4\u30a4\u30fc\u30c8\u3059\u308b\u30d5\u30a9\u30fc\u30e0\u3092\u8ffd\u52a0\u3059\u308b<\/h4>\n<p>resources\/views\/dashboard.blade.php \u3092\u958b\u304d\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [14,15,16,17,18,19,20,21]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;Dashboard&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    {{ __(&quot;You&#039;re logged in!&quot;) }}\r\n                &lt;\/div&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    &lt;form action=&quot;{{ route(&#039;tweet&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        &lt;textarea name=&quot;tweet&quot; required&gt;&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button&gt;\u30c4\u30a4\u30fc\u30c8\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<h4>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u8ffd\u52a0\u3059\u308b<\/h4>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt;  php artisan make:controller TweetController\r\n<\/pre>\n<p>app\/Http\/Controllers \u30d5\u30a9\u30eb\u30c0\u306b\u3001TweetController.php \u304c\u4f5c\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>POST\u30e1\u30bd\u30c3\u30c9\u3067\u306e\u30a2\u30af\u30bb\u30b9\u3092\u53d7\u3051\u53d6\u308b\u305f\u3081\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [9,10,11,12]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass TweetController extends Controller\r\n{\r\n    public function tweet(Request $request)\r\n    {\r\n        return redirect()-&gt;route(&#039;dashboard&#039;);\r\n    }\r\n}\r\n<\/pre>\n<h4>URL\u3068\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u95a2\u9023\u4ed8\u3051\u308b<\/h4>\n<p>routes\/web.php \u3092\u958b\u304d\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [4,15]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse App\\Http\\Controllers\\ProfileController;\r\nuse App\\Http\\Controllers\\TweetController;\r\nuse Illuminate\\Support\\Facades\\Route;\r\n\r\nRoute::get(&#039;\/&#039;, function () {\r\n    return view(&#039;welcome&#039;);\r\n});\r\n\r\nRoute::get(&#039;\/dashboard&#039;, function () {\r\n    return view(&#039;dashboard&#039;);\r\n})-&gt;middleware(&#x5B;&#039;auth&#039;, &#039;verified&#039;])-&gt;name(&#039;dashboard&#039;);\r\n\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;name(&#039;tweet&#039;);\r\n\r\nRoute::middleware(&#039;auth&#039;)-&gt;group(function () {\r\n    Route::get(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;edit&#039;])-&gt;name(&#039;profile.edit&#039;);\r\n    Route::patch(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;update&#039;])-&gt;name(&#039;profile.update&#039;);\r\n    Route::delete(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;destroy&#039;])-&gt;name(&#039;profile.destroy&#039;);\r\n});\r\n\r\nrequire __DIR__.&#039;\/auth.php&#039;;\r\n<\/pre>\n<h4>\u30c4\u30a4\u30fc\u30c8\u306b\u5bfe\u5fdc\u3059\u308b\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/h4>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u3066\u3001Tweet\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u300c-m\u300d\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u3064\u3051\u3066\u304a\u304f\u3068\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u3082\u540c\u6642\u306b\u4f5c\u6210\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan make:model Tweet -m\r\n<\/pre>\n<p>Tweet.php \u306b\u306f\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [9]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Tweet extends Model\r\n{\r\n    protected $fillable = &#x5B;&#039;user_id&#039;, &#039;text&#039;];\r\n}\r\n<\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306b\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [16,17]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nreturn new class extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\/\r\n    public function up(): void\r\n    {\r\n        Schema::create(&#039;tweets&#039;, function (Blueprint $table) {\r\n            $table-&gt;id();\r\n            $table-&gt;bigInteger(&#039;user_id&#039;);\r\n            $table-&gt;string(&#039;text&#039;);\r\n            $table-&gt;timestamps();\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\/\r\n    public function down(): void\r\n    {\r\n        Schema::dropIfExists(&#039;tweets&#039;);\r\n    }\r\n};\r\n<\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan migrate\r\n<\/pre>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u65b0\u3057\u304f tweets \u30c6\u30fc\u30d6\u30eb\u304c\u4f5c\u3089\u308c\u3066\u3044\u308b\u306e\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nMySQL &#x5B;(none)]&gt; use xtter;\r\nDatabase changed\r\nMySQL &#x5B;xtter]&gt; show tables;\r\n+-----------------------+\r\n| Tables_in_xtter       |\r\n+-----------------------+\r\n| cache                 |\r\n| cache_locks           |\r\n| failed_jobs           |\r\n| job_batches           |\r\n| jobs                  |\r\n| migrations            |\r\n| password_reset_tokens |\r\n| sessions              |\r\n| tweets                |\r\n| users                 |\r\n+-----------------------+\r\n10 rows in set (0.000 sec)\r\n\r\nMySQL &#x5B;xtter]&gt; desc tweets;\r\n+------------+---------------------+------+-----+---------+----------------+\r\n| Field      | Type                | Null | Key | Default | Extra          |\r\n+------------+---------------------+------+-----+---------+----------------+\r\n| id         | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |\r\n| user_id    | bigint(20)          | NO   |     | NULL    |                |\r\n| text       | varchar(255)        | NO   |     | NULL    |                |\r\n| created_at | timestamp           | YES  |     | NULL    |                |\r\n| updated_at | timestamp           | YES  |     | NULL    |                |\r\n+------------+---------------------+------+-----+---------+----------------+\r\n5 rows in set (0.001 sec)\r\n<\/pre>\n<h4>\u30c4\u30a4\u30fc\u30c8\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b<\/h4>\n<p>TweetController \u306e tweet() \u30e1\u30bd\u30c3\u30c9\u3067\u30c4\u30a4\u30fc\u30c8\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [12,13,14,15,16]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\nuse App\\Models\\Tweet;\r\n\r\nclass TweetController extends Controller\r\n{\r\n    public function tweet(Request $request)\r\n    {\r\n        $user = \\Auth::user();\r\n        Tweet::create(&#x5B;\r\n            &#039;user_id&#039; =&gt; $user-&gt;id,\r\n            &#039;text&#039; =&gt; $request-&gt;input(&#039;tweet&#039;),\r\n        ]);\r\n        return redirect()-&gt;route(&#039;dashboard&#039;);\r\n    }\r\n}\r\n<\/pre>\n<h4>\u904e\u53bb\u306e\u30c4\u30a4\u30fc\u30c8\u3092\u8868\u793a\u3059\u308b<\/h4>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u753b\u9762\u306b\u904e\u53bb\u306e\u30c4\u30a4\u30fc\u30c8\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30c4\u30a4\u30fc\u30c8\u30c7\u30fc\u30bf\u3092\u6e21\u3059\u305f\u3081\u306b\u3001web.php \u3092\u5909\u66f4\u3057\u307e\u3059\u3002<br \/>\n\u3082\u3068\u3082\u3068\u3042\u3063\u305f \/dashboard \u306b\u95a2\u3059\u308b\u8a2d\u5b9a\u306f\u524a\u9664\u3057\u306611\u884c\u76ee\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [11]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse App\\Http\\Controllers\\ProfileController;\r\nuse App\\Http\\Controllers\\TweetController;\r\nuse Illuminate\\Support\\Facades\\Route;\r\n\r\nRoute::get(&#039;\/&#039;, function () {\r\n    return view(&#039;welcome&#039;);\r\n});\r\n\r\nRoute::get(&#039;\/dashboard&#039;, &#x5B;TweetController::class, &#039;index&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;dashboard&#039;);\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;tweet&#039;);\r\n\r\nRoute::middleware(&#039;auth&#039;)-&gt;group(function () {\r\n    Route::get(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;edit&#039;])-&gt;name(&#039;profile.edit&#039;);\r\n    Route::patch(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;update&#039;])-&gt;name(&#039;profile.update&#039;);\r\n    Route::delete(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;destroy&#039;])-&gt;name(&#039;profile.destroy&#039;);\r\n});\r\n\r\nrequire __DIR__.&#039;\/auth.php&#039;;\r\n<\/pre>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306b index() \u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [10,11,12,13,14]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\nuse App\\Models\\Tweet;\r\n\r\nclass TweetController extends Controller\r\n{\r\n    public function index()\r\n    {\r\n        $tweets = Tweet::orderBy(&#039;created_at&#039;, &#039;desc&#039;)-&gt;get();\r\n        return view(&#039;dashboard&#039;, compact(&#039;tweets&#039;));\r\n    }\r\n\r\n    public function tweet(Request $request)\r\n    {\r\n        $user = \\Auth::user();\r\n        Tweet::create(&#x5B;\r\n            &#039;user_id&#039; =&gt; $user-&gt;id,\r\n            &#039;text&#039; =&gt; $request-&gt;input(&#039;tweet&#039;),\r\n        ]);\r\n        return redirect()-&gt;route(&#039;dashboard&#039;);\r\n    }\r\n}\r\n<\/pre>\n<p>dashboard.blade.php \u3067\u306f\u3001\u6e21\u3055\u308c\u305f tweets \u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [22,23,24,25,26,27,28,29]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;Dashboard&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    {{ __(&quot;You&#039;re logged in!&quot;) }}\r\n                &lt;\/div&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    &lt;form action=&quot;{{ route(&#039;tweet&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        &lt;textarea name=&quot;tweet&quot; required&gt;&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button&gt;\u30c4\u30a4\u30fc\u30c8\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                &lt;\/div&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($tweets as $tweet)\r\n                    &lt;div&gt;\r\n                        &lt;div&gt;{!! nl2br($tweet-&gt;text) !!}&lt;\/div&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;created_at }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<h4>\u30c4\u30a4\u30fc\u30c8\u306b\u6295\u7a3f\u8005\u306e\u540d\u524d\u3092\u8868\u793a\u3059\u308b<\/h4>\n<p>\u3044\u307e\u306e\u307e\u307e\u3067\u306f\u3001\u8ab0\u304c\u30c4\u30a4\u30fc\u30c8\u3057\u305f\u306e\u304b\u304c\u308f\u304b\u308a\u307e\u305b\u3093\u306e\u3067\u3001\u30c4\u30a4\u30fc\u30c8\u306e\u4e0a\u306b\u6295\u7a3f\u3057\u305f\u4eba\u306e\u540d\u524d\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>Tweet\u30af\u30e9\u30b9\u306b\u306f\u3001user_id \u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u540d\u524d\u306f\u308f\u304b\u308a\u307e\u305b\u3093\u3002<br \/>\nTweet\u30af\u30e9\u30b9\u304b\u3089 user_id \u3092\u5143\u306b User \u3092\u53d6\u5f97\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [6,12,13,14,15]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\nuse App\\Models\\User;\r\n\r\nclass Tweet extends Model\r\n{\r\n    protected $fillable = &#x5B;&#039;user_id&#039;, &#039;text&#039;];\r\n\r\n    public function user()\r\n    {\r\n        return $this-&gt;belongsTo(User::class);\r\n    }\r\n}\r\n<\/pre>\n<p>tinker\u3092\u4f7f\u3063\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# php artisan tinker\r\nPsy Shell v0.12.4 (PHP 8.2.12 \u2014 cli) by Justin Hileman\r\n&gt; $t = App\\Models\\Tweet::find(1)\r\n= App\\Models\\Tweet {#6004\r\n    id: 1,\r\n    user_id: 1,\r\n    text: &quot;\u306f\u3058\u3081\u307e\u3057\u3066\uff01&quot;,\r\n    created_at: &quot;2024-11-01 06:51:47&quot;,\r\n    updated_at: &quot;2024-11-01 06:51:47&quot;,\r\n  }\r\n\r\n&gt; $t-&gt;user\r\n= App\\Models\\User {#5954\r\n    id: 1,\r\n    name: &quot;satoshis&quot;,\r\n    email: &quot;satoshis@example.com&quot;,\r\n    email_verified_at: null,\r\n    #password: &quot;$2y$12$R2OOAoUymqnEfyX0v6pikOJS92RGFOIJ.uTBFmGnbh7.WJXgx1yqu&quot;,\r\n    #remember_token: null,\r\n    created_at: &quot;2024-11-01 05:11:19&quot;,\r\n    updated_at: &quot;2024-11-01 05:11:19&quot;,\r\n  }\r\n\r\n&gt;\r\n<\/pre>\n<p>Tweet\u304b\u3089User\u304c\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u3053\u308c\u3092bashboard\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 22; highlight: [25]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($tweets as $tweet)\r\n                    &lt;div&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;user-&gt;name }}\r\n                        &lt;div&gt;{!! nl2br($tweet-&gt;text) !!}&lt;\/div&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;created_at }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n<\/pre>\n<p>\u3053\u308c\u3067\u6295\u7a3f\u8005\u306e\u540d\u524d\u3082\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u3069\u3053\u304b\u3089\u3069\u3053\u307e\u3067\u304c\u3072\u3068\u3064\u306e\u30c4\u30a4\u30fc\u30c8\u306a\u306e\u304b\u304c\u308f\u304b\u308a\u306b\u304f\u3044\u306e\u3067\u3001CSS\u3067\u5c11\u3057\u3060\u3051\u30c7\u30b6\u30a4\u30f3\u3092\u8abf\u6574\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30c4\u30a4\u30fc\u30c8\u5358\u4f4d\u306e div \u306b class=&#8221;tweet&#8221; \u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 22; highlight: [24]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($tweets as $tweet)\r\n                    &lt;div class=&quot;tweet&quot;&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;user-&gt;name }}&lt;\/div&gt;\r\n                        &lt;div&gt;{!! nl2br($tweet-&gt;text) !!}&lt;\/div&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;created_at }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n<\/pre>\n<p>app.blade.php \u306bCSS\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [14,15,16,17,18,19]; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;{{ str_replace(&#039;_&#039;, &#039;-&#039;, app()-&gt;getLocale()) }}&quot;&gt;\r\n    &lt;head&gt;\r\n        &lt;meta charset=&quot;utf-8&quot;&gt;\r\n        &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\r\n        &lt;meta name=&quot;csrf-token&quot; content=&quot;{{ csrf_token() }}&quot;&gt;\r\n\r\n        &lt;title&gt;{{ config(&#039;app.name&#039;, &#039;Laravel&#039;) }}&lt;\/title&gt;\r\n\r\n        &lt;!-- Fonts --&gt;\r\n        &lt;link rel=&quot;preconnect&quot; href=&quot;https:\/\/fonts.bunny.net&quot;&gt;\r\n        &lt;link href=&quot;https:\/\/fonts.bunny.net\/css?family=figtree:400,500,600&amp;display=swap&quot; rel=&quot;stylesheet&quot; \/&gt;\r\n        &lt;style&gt;\r\n            .tweet {\r\n                border: 2px solid gray;\r\n                border-radius: 5px;\r\n                margin: 2px;\r\n                padding-left: 5px;\r\n            }\r\n        &lt;\/style&gt;\r\n        &lt;!-- Scripts --&gt;\r\n        @vite(&#x5B;&#039;resources\/css\/app.css&#039;, &#039;resources\/js\/app.js&#039;])\r\n    &lt;\/head&gt;\r\n<\/pre>\n<h4>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u3092\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/h4>\n<p>\u30c4\u30a4\u30fc\u30c8\u306e\u4e0a\u306b\u3042\u308b\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306b\u9077\u79fb\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f web.php \u306b\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u7528\u306eURL\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 11; highlight: [13]; title: ; notranslate\" title=\"\">\r\nRoute::get(&#039;\/dashboard&#039;, &#x5B;TweetController::class, &#039;index&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;dashboard&#039;);\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;tweet&#039;);\r\nRoute::get(&#039;\/prof\/{name}&#039;, &#x5B;TweetController::class, &#039;profile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;profile&#039;);\r\n<\/pre>\n<p>URL\u3092\u7528\u610f\u3057\u305f\u306e\u3067\u3001blade \u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\u306e\u90e8\u5206\u3092 a \u30bf\u30b0\u306b\u3057\u3066 href \u5c5e\u6027\u306e\u5024\u3092\u4e0a\u8a18 web.php \u3067\u8ffd\u52a0\u3057\u305f\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 22; highlight: [25]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($tweets as $tweet)\r\n                    &lt;div class=&quot;tweet&quot;&gt;\r\n                        &lt;div&gt;&lt;a href=&quot;{{ route(&#039;profile&#039;, $tweet-&gt;user-&gt;name) }}&quot;&gt;{{ $tweet-&gt;user-&gt;name }}&lt;\/a&gt;&lt;\/div&gt;\r\n                        &lt;div&gt;{!! nl2br($tweet-&gt;text) !!}&lt;\/div&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;created_at }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n<\/pre>\n<p>\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u30ea\u30f3\u30af\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u30af\u30ea\u30c3\u30af\u3057\u3066\u307f\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u898b\u308b\u3068\u3001\u300cCall to undefined method App\\Http\\Controllers\\TweetController::profile()\u300d\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>TweetController\u306bprofile()\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: php; highlight: [7,27,28,29,30,31]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\nuse App\\Models\\Tweet;\r\nuse App\\Models\\User;\r\n\r\nclass TweetController extends Controller\r\n{\r\n    public function index()\r\n    {\r\n        $tweets = Tweet::orderBy(&#039;created_at&#039;, &#039;desc&#039;)-&gt;get();\r\n        return view(&#039;dashboard&#039;, compact(&#039;tweets&#039;));\r\n    }\r\n\r\n    public function tweet(Request $request)\r\n    {\r\n        $user = \\Auth::user();\r\n        Tweet::create(&#x5B;\r\n            &#039;user_id&#039; =&gt; $user-&gt;id,\r\n            &#039;text&#039; =&gt; $request-&gt;input(&#039;tweet&#039;),\r\n        ]);\r\n        return redirect()-&gt;route(&#039;dashboard&#039;);\r\n    }\r\n\r\n    public function profile($name)\r\n    {\r\n        $user = User::where(&#039;name&#039;, $name)-&gt;first();\r\n        return view(&#039;profile&#039;, compact(&#039;user&#039;));\r\n    }\r\n}\r\n<\/pre>\n<p>profile() \u30e1\u30bd\u30c3\u30c9\u3092\u7528\u610f\u3057\u305f\u306e\u3067\u3001\u3082\u3046\u4e00\u5ea6\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u3059\u308b\u3068\u300cView [profile] not found.\u300d\u306e\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30d3\u30e5\u30fc profile \u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan make:view profile\r\n\r\n   INFO  View &#x5B;C:\\Users\\teacher\\Documents\\php\\xtter\\resources\\views\\profile.blade.php] created successfully.\r\n<\/pre>\n<p>\u30da\u30fc\u30b8\u3092\u518d\u8aad\u307f\u8fbc\u307f\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306f\u51fa\u306a\u304f\u306a\u308a\u3001\u771f\u3063\u767d\u306a\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>profile.blade.php \u306e\u5185\u5bb9\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3060\u3051\u3092\u8868\u793a\u3059\u308b\u30da\u30fc\u30b8\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;Profile&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<h4>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306b\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u3092\u8ffd\u52a0\u3059\u308b<\/h4>\n<p>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306b\u8868\u793a\u540d\uff08\u30c4\u30a4\u30c3\u30bf\u30fc\u3067\u306e\u30ed\u30b0\u30a4\u30f3ID\u3068\u306f\u5225\u306b\u3001\u30c4\u30a4\u30c3\u30bf\u30fc\u4e0a\u3067\u8868\u793a\u3059\u308b\u540d\u524d\u3092\u8a2d\u5b9a\u3067\u304d\u308b\uff09\u3068\u81ea\u5df1\u7d39\u4ecb\u3092\u8ffd\u52a0\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e Profile \u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan make:model Profile -m\r\n<\/pre>\n<p>Profile\u30af\u30e9\u30b9\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c6\u30fc\u30d6\u30eb\u306b\u4fdd\u5b58\u3059\u308b\u30ab\u30e9\u30e0\u306b\u5bfe\u3059\u308b\u30a2\u30af\u30bb\u30b9\u8a31\u53ef\u3092\u8a18\u5165\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Profile extends Model\r\n{\r\n    protected $fillable = &#x5B;&#039;user_id&#039;, &#039;name&#039;, &#039;description&#039;];\r\n}\r\n<\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306b\u306f\u3001\u305d\u308c\u3089\u306e\u30ab\u30e9\u30e0\u306e\u8ffd\u52a0\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [16,17,18]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nreturn new class extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\/\r\n    public function up(): void\r\n    {\r\n        Schema::create(&#039;profiles&#039;, function (Blueprint $table) {\r\n            $table-&gt;id();\r\n            $table-&gt;bigInteger(&#039;user_id&#039;);\r\n            $table-&gt;string(&#039;name&#039;);\r\n            $table-&gt;string(&#039;description&#039;);\r\n            $table-&gt;timestamps();\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\/\r\n    public function down(): void\r\n    {\r\n        Schema::dropIfExists(&#039;profiles&#039;);\r\n    }\r\n};\r\n<\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan migrate\r\n   INFO  Running migrations.\r\n\r\n  2024_11_08_151854_create_profiles_table .......... 24.84ms DONE\r\n<\/pre>\n<p>TweetController\u304b\u3089\u30d3\u30e5\u30fc\u306b\u5bfe\u3057\u3066 Profile \u3082\u6e21\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [6,31,32]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\nuse App\\Models\\Profile;\r\nuse App\\Models\\Tweet;\r\nuse App\\Models\\User;\r\n\r\nclass TweetController extends Controller\r\n{\r\n    public function index()\r\n    {\r\n        $tweets = Tweet::orderBy(&#039;created_at&#039;, &#039;desc&#039;)-&gt;get();\r\n        return view(&#039;dashboard&#039;, compact(&#039;tweets&#039;));\r\n    }\r\n\r\n    public function tweet(Request $request)\r\n    {\r\n        $user = \\Auth::user();\r\n        Tweet::create(&#x5B;\r\n            &#039;user_id&#039; =&gt; $user-&gt;id,\r\n            &#039;text&#039; =&gt; $request-&gt;input(&#039;tweet&#039;),\r\n        ]);\r\n        return redirect()-&gt;route(&#039;dashboard&#039;);\r\n    }\r\n\r\n    public function profile($name)\r\n    {\r\n        $user = User::where(&#039;name&#039;, $name)-&gt;first();\r\n        $profile = Profile::where(&#039;user_id&#039;, $user-&gt;id)-&gt;first();\r\n        return view(&#039;profile&#039;, compact(&#039;user&#039;, &#039;profile&#039;));\r\n    }\r\n}\r\n<\/pre>\n<p>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u3092\u4fee\u6b63\u3057\u307e\u3059\u3002<br \/>\nProfile\u3092\u767b\u9332\u3057\u3066\u3044\u306a\u3044\u30e6\u30fc\u30b6\u30fc\u3082\u3044\u308b\u306e\u3067\u3001\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 11; highlight: [12,13,14,15,16,17,18]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @if(empty($profile))\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                    &lt;div&gt;\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u306f\u672a\u8a2d\u5b9a\u3067\u3059\u3002&lt;\/div&gt;\r\n                    @else\r\n                    &lt;h2&gt;{{ $profile-&gt;name }}\u3055\u3093 ({{ $user-&gt;name }})&lt;\/h2&gt;\r\n                    &lt;div&gt;{!! nl2br($profile-&gt;description) !!}&lt;\/div&gt;\r\n                    @endif\r\n                &lt;\/div&gt;\r\n<\/pre>\n<p>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u3068\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306e\u30e6\u30fc\u30b6\u30fc\u304c\u4e00\u81f4\u3057\u3066\u3044\u308b\u6642\u3060\u3051\u7de8\u96c6\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30fc\u30e0\u306f\u6700\u521d\u306f\u96a0\u3057\u3066\u304a\u304d\u300c\u7de8\u96c6\u3059\u308b\u300d\u30dc\u30bf\u30f3\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u3089\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 11; highlight: [19,20,21,22,23,24,25,26,27,28,29,30,31,37,38,39,40,41,42,43]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @if(empty($profile))\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                    &lt;div&gt;\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u306f\u672a\u8a2d\u5b9a\u3067\u3059\u3002&lt;\/div&gt;\r\n                    @else\r\n                    &lt;h2&gt;{{ $profile-&gt;name }}\u3055\u3093 ({{ $user-&gt;name }})&lt;\/h2&gt;\r\n                    &lt;div&gt;{!! nl2br($profile-&gt;description) !!}&lt;\/div&gt;\r\n                    @endif\r\n                    @if(\\Auth::user()-&gt;id == $user-&gt;id)\r\n                    &lt;button class=&quot;form-edit btn&quot;&gt;\u7de8\u96c6\u3059\u308b&lt;\/button&gt;\r\n                    &lt;form id=&quot;form-profile&quot; action=&quot;&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        \u8868\u793a\u540d: &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;{{ old(&#039;name&#039;) }}&quot; required \/&gt;\r\n                        &lt;br \/&gt;\r\n                        \u81ea\u5df1\u7d39\u4ecb:\r\n                        &lt;br \/&gt;\r\n                        &lt;textarea name=&quot;description&quot; required&gt;{{ old(&#039;profile&#039;) }}&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button class=&quot;btn&quot;&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                    @endif\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script&gt;\r\n    $(function() {\r\n        $(&#039;#form-profile&#039;).hide();\r\n        $(&#039;.form-edit&#039;).click(function() {\r\n            $(&#039;#form-profile&#039;).show();\r\n        })\r\n    })\r\n    &lt;\/script&gt;\r\n<\/pre>\n<p>app.blade.php \u306b jQuery \u306e\u8aad\u307f\u8fbc\u307f\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 27; highlight: [28]; title: ; notranslate\" title=\"\">\r\n        &lt;!-- Scripts --&gt;\r\n        &lt;script src=&quot;https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.7.1\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n        @vite(&#x5B;&#039;resources\/css\/app.css&#039;, &#039;resources\/js\/app.js&#039;])\r\n<\/pre>\n<p>\u30d5\u30a9\u30fc\u30e0\u304c\u7528\u610f\u3067\u304d\u305f\u306e\u3067\u3001\u5165\u529b\u5185\u5bb9\u3092\u4fdd\u5b58\u3059\u308b\u90e8\u5206\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306fpost\u30e1\u30bd\u30c3\u30c9\u3092\u53d7\u3051\u53d6\u308b\u305f\u3081\u306eURL\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 11; highlight: [14]; title: ; notranslate\" title=\"\">\r\nRoute::get(&#039;\/dashboard&#039;, &#x5B;TweetController::class, &#039;index&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;dashboard&#039;);\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;tweet&#039;);\r\nRoute::get(&#039;\/prof\/{name}&#039;, &#x5B;TweetController::class, &#039;profile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;profile&#039;);\r\nRoute::post(&#039;\/updateProfile&#039;, &#x5B;TweetController::class, &#039;updateProfile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;updateProfile&#039;);\r\n<\/pre>\n<p>TweetController\u306b updateProfile() \u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 35; title: ; notranslate\" title=\"\">\r\n    public function updateProfile(Request $request)\r\n    {\r\n        $user = \\Auth::user();\r\n        $profile = Profile::where(&#039;user_id&#039;, $user-&gt;id)-&gt;first();\r\n        if (empty($profile)) {\r\n            $profile = new Profile;\r\n        }\r\n        $profile-&gt;user_id = $user-&gt;id;\r\n        $profile-&gt;name = $request-&gt;input(&#039;name&#039;);\r\n        $profile-&gt;description = $request-&gt;input(&#039;description&#039;);\r\n        $profile-&gt;save();\r\n        return redirect()-&gt;route(&#039;profile&#039;, $user-&gt;name);\r\n    }\r\n<\/pre>\n<p>profile.blade.php \u306e form \u306e action \u5c5e\u6027\u306e\u5024\u3092\u3055\u304d\u307b\u3069 web.php \u306b\u6307\u5b9a\u3057\u305f\u3082\u306e\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 19; highlight: [21]; title: ; notranslate\" title=\"\">\r\n                    @if(\\Auth::user()-&gt;id == $user-&gt;id)\r\n                    &lt;button class=&quot;form-edit btn&quot;&gt;\u7de8\u96c6\u3059\u308b&lt;\/button&gt;\r\n                    &lt;form id=&quot;form-profile&quot; action=&quot;{{ route(&#039;updateProfile&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        \u8868\u793a\u540d: &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;{{ old(&#039;name&#039;) }}&quot; required \/&gt;\r\n                        &lt;br \/&gt;\r\n                        \u81ea\u5df1\u7d39\u4ecb:\r\n                        &lt;br \/&gt;\r\n                        &lt;textarea name=&quot;description&quot; required&gt;{{ old(&#039;profile&#039;) }}&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button class=&quot;btn&quot;&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                    @endif\r\n<\/pre>\n<h4>\u307b\u304b\u306e\u4eba\u3092\u30d5\u30a9\u30ed\u30fc\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/h4>\n<p>\u4ed6\u306e\u4eba\u3092\u30d5\u30a9\u30ed\u30fc\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u307e\u305a\u306f\u30d5\u30a9\u30ed\u30fc\u30dc\u30bf\u30f3\u3092\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [31,32,33,34,35,36,37]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;Profile&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @if(empty($profile))\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                    &lt;div&gt;\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u306f\u672a\u8a2d\u5b9a\u3067\u3059\u3002&lt;\/div&gt;\r\n                    @else\r\n                    &lt;h2&gt;{{ $profile-&gt;name }}\u3055\u3093 ({{ $user-&gt;name }})&lt;\/h2&gt;\r\n                    &lt;div&gt;{!! nl2br($profile-&gt;description) !!}&lt;\/div&gt;\r\n                    @endif\r\n                    @if(\\Auth::user()-&gt;id == $user-&gt;id)\r\n                    &lt;button class=&quot;form-edit btn&quot;&gt;\u7de8\u96c6\u3059\u308b&lt;\/button&gt;\r\n                    &lt;form id=&quot;form-profile&quot; action=&quot;{{ route(&#039;updateProfile&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        \u8868\u793a\u540d: &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;{{ old(&#039;name&#039;) }}&quot; required \/&gt;\r\n                        &lt;br \/&gt;\r\n                        \u81ea\u5df1\u7d39\u4ecb:\r\n                        &lt;br \/&gt;\r\n                        &lt;textarea name=&quot;description&quot; required&gt;{{ old(&#039;profile&#039;) }}&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button class=&quot;btn&quot;&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                    @else\r\n                    &lt;form id=&quot;form-follow&quot; action=&quot;{{ route(&#039;follow&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        &lt;input type=&quot;hidden&quot; name=&quot;user_id&quot; value=&quot;{{ \\Auth::user()-&gt;id }}&quot; \/&gt;\r\n                        &lt;input type=&quot;hidden&quot; name=&quot;follow_id&quot; value=&quot;{{ $user-&gt;id }}&quot; \/&gt;\r\n                        &lt;button id=&quot;follow-button&quot; class=&quot;btn&quot;&gt;\u30d5\u30a9\u30ed\u30fc\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                    @endif\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script&gt;\r\n    $(function() {\r\n        $(&#039;#form-profile&#039;).hide();\r\n        $(&#039;.form-edit&#039;).click(function() {\r\n            $(&#039;#form-profile&#039;).show();\r\n        })\r\n    })\r\n    &lt;\/script&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<p>\u30d5\u30a9\u30ed\u30fc\u30dc\u30bf\u30f3\u304c\u62bc\u3055\u308c\u305f\u6642\u306e\u53d7\u3051\u53d6\u308b\u5834\u6240\u3092\u30b5\u30fc\u30d0\u30fc\u5074\u306b\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [15]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse App\\Http\\Controllers\\ProfileController;\r\nuse App\\Http\\Controllers\\TweetController;\r\nuse Illuminate\\Support\\Facades\\Route;\r\n\r\nRoute::get(&#039;\/&#039;, function () {\r\n    return view(&#039;welcome&#039;);\r\n});\r\n\r\nRoute::get(&#039;\/dashboard&#039;, &#x5B;TweetController::class, &#039;index&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;dashboard&#039;);\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;tweet&#039;);\r\nRoute::get(&#039;\/prof\/{name}&#039;, &#x5B;TweetController::class, &#039;profile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;profile&#039;);\r\nRoute::post(&#039;\/updateProfile&#039;, &#x5B;TweetController::class, &#039;updateProfile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;updateProfile&#039;);\r\nRoute::post(&#039;\/follow&#039;, &#x5B;TweetController::class, &#039;follow&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;follow&#039;);\r\n\r\nRoute::middleware(&#039;auth&#039;)-&gt;group(function () {\r\n    Route::get(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;edit&#039;])-&gt;name(&#039;profile.edit&#039;);\r\n    Route::patch(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;update&#039;])-&gt;name(&#039;profile.update&#039;);\r\n    Route::delete(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;destroy&#039;])-&gt;name(&#039;profile.destroy&#039;);\r\n});\r\n\r\nrequire __DIR__.&#039;\/auth.php&#039;;\r\n<\/pre>\n<p>\u3053\u306e\u72b6\u614b\u3067\u300c\u30d5\u30a9\u30ed\u30fc\u3059\u308b\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001TweetController::follow()\u30e1\u30bd\u30c3\u30c9\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u30d6\u30e9\u30a6\u30b6\u4e0a\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>TweetController\u306bfollow()\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f\u4f55\u3082\u8a18\u9332\u3059\u308b\u3053\u3068\u306f\u3057\u306a\u3044\u3067\u3001\u540c\u3058\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 49; title: ; notranslate\" title=\"\">\r\n    public function follow(Request $request)\r\n    {\r\n        $follow_id = $request-&gt;input(&#039;follow_id&#039;);\r\n        $user = User::find($follow_id);\r\n        return redirect()-&gt;route(&#039;profile&#039;, $user-&gt;name);\r\n    }\r\n<\/pre>\n<p>\u8ab0\u304b\u304c\u8ab0\u304b\u3092\u30d5\u30a9\u30ed\u30fc\u3059\u308b\u64cd\u4f5c\u3092\u3057\u305f\u3068\u304d\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u305d\u306e\u5185\u5bb9\u3092\u8a18\u9332\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>Follow\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3001\u5185\u5bb9\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nphp artisan make:model Follow -m\r\n\r\n   INFO  Model &#x5B;C:\\Users\\teacher\\Documents\\php\\xtter\\app\\Models\\Follow.php] created successfully.\r\n\r\n   INFO  Migration &#x5B;C:\\Users\\teacher\\Documents\\php\\xtter\\database\\migrations\/2024_11_15_141610_create_follows_table.php] created successfully.\r\n<\/pre>\n<p>Follow\u30af\u30e9\u30b9\u3067\u306f\u3001$fillable \u3092\u5b9a\u7fa9\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3067\u304d\u308b\u30ab\u30e9\u30e0\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\n\r\nclass Follow extends Model\r\n{\r\n    protected $fillable = &#x5B;&#039;user_id&#039;, &#039;follow_id&#039;];\r\n}\r\n<\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u3067\u306f\u3001user_id \u3068 follow_id \u3092\u8ffd\u52a0\u3059\u308b\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [16,17]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse Illuminate\\Database\\Migrations\\Migration;\r\nuse Illuminate\\Database\\Schema\\Blueprint;\r\nuse Illuminate\\Support\\Facades\\Schema;\r\n\r\nreturn new class extends Migration\r\n{\r\n    \/**\r\n     * Run the migrations.\r\n     *\/\r\n    public function up(): void\r\n    {\r\n        Schema::create(&#039;follows&#039;, function (Blueprint $table) {\r\n            $table-&gt;id();\r\n            $table-&gt;bigInteger(&#039;user_id&#039;);\r\n            $table-&gt;bigInteger(&#039;follow_id&#039;);\r\n            $table-&gt;timestamps();\r\n        });\r\n    }\r\n\r\n    \/**\r\n     * Reverse the migrations.\r\n     *\/\r\n    public function down(): void\r\n    {\r\n        Schema::dropIfExists(&#039;follows&#039;);\r\n    }\r\n};\r\n<\/pre>\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n php artisan migrate\r\n\r\n   INFO  Running migrations.\r\n\r\n  2024_11_15_141610_create_follows_table ........... 40.00ms DONE\r\n<\/pre>\n<p>TweetController\u306b\u3001\u30d5\u30a9\u30ed\u30fc\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 52; title: ; notranslate\" title=\"\">\r\n    public function follow(Request $request)\r\n    {\r\n        $user_id = $request-&gt;input(&#039;user_id&#039;);\r\n        $follow_id = $request-&gt;input(&#039;follow_id&#039;);\r\n        $user = User::find($follow_id);\r\n        Follow::create(&#x5B;\r\n            &#039;user_id&#039; =&gt; $user_id,\r\n            &#039;follow_id&#039; =&gt; $follow_id,\r\n        ]);\r\n        return redirect()-&gt;route(&#039;profile&#039;, $user-&gt;name);\r\n    }\r\n<\/pre>\n<p>\u30c6\u30fc\u30d6\u30eb\u304c\u4f5c\u3089\u308c\u305f\u306e\u3067\u300c\u30d5\u30a9\u30ed\u30fc\u3059\u308b\u300d\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u3001\u30c6\u30fc\u30d6\u30eb\u306b\u305d\u306e\u5185\u5bb9\u304c\u8a18\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n php artisan tinker\r\nPsy Shell v0.12.4 (PHP 8.2.12 \u2014 cli) by Justin Hileman\r\n&gt; App\\Models\\Follow::all()\r\n= Illuminate\\Database\\Eloquent\\Collection {#6002\r\n    all: &#x5B;\r\n      App\\Models\\Follow {#5593\r\n        id: 1,\r\n        user_id: 2,\r\n        follow_id: 1,\r\n        created_at: &quot;2024-11-15 14:27:48&quot;,\r\n        updated_at: &quot;2024-11-15 14:27:48&quot;,\r\n      },\r\n    ],\r\n  }\r\n\r\n&gt;\r\n<\/pre>\n<p>\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u30e6\u30fc\u30b6\u30fc\u304c\u3001\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u3001profile.blade.php \u306b\u6e21\u3059\u305f\u3081\u306b\u3001<br \/>\n\u65b0\u3057\u304f following \u3068\u3044\u3046\u5909\u6570\u3092\u7528\u610f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 29; highlight: [33,34,35]; title: ; notranslate\" title=\"\">\r\n    public function profile($name)\r\n    {\r\n        $user = User::where(&#039;name&#039;, $name)-&gt;first();\r\n        $profile = Profile::where(&#039;user_id&#039;, $user-&gt;id)-&gt;first();\r\n        $user_id = \\Auth::user()-&gt;id;\r\n        $following = Follow::where(&#039;user_id&#039;, $user_id)-&gt;where(&#039;follow_id&#039;, $user-&gt;id)-&gt;first();\r\n        return view(&#039;profile&#039;, compact(&#039;user&#039;, &#039;profile&#039;, &#039;following&#039;));\r\n    }\r\n<\/pre>\n<p>profile.blade.php \u3067\u306f\u3001following \u5909\u6570\u3092\u53c2\u7167\u3057\u3066\u300c\u30d5\u30a9\u30ed\u30fc\u3059\u308b\u300d\u307e\u305f\u306f\u300c\u30d5\u30a9\u30ed\u30fc\u89e3\u9664\u3059\u308b\u300d\u306e\u30dc\u30bf\u30f3\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d5\u30a9\u30ed\u30fc\u89e3\u9664\u3059\u308b\u5074\u306e\u30d5\u30a9\u30fc\u30e0\u306f id \u3068 action \u306e\u5024\u3092\u5909\u66f4\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;Profile&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @if(empty($profile))\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                    &lt;div&gt;\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u306f\u672a\u8a2d\u5b9a\u3067\u3059\u3002&lt;\/div&gt;\r\n                    @else\r\n                    &lt;h2&gt;{{ $profile-&gt;name }}\u3055\u3093 ({{ $user-&gt;name }})&lt;\/h2&gt;\r\n                    &lt;div&gt;{!! nl2br($profile-&gt;description) !!}&lt;\/div&gt;\r\n                    @endif\r\n                    @if(\\Auth::user()-&gt;id == $user-&gt;id)\r\n                    &lt;button class=&quot;form-edit btn&quot;&gt;\u7de8\u96c6\u3059\u308b&lt;\/button&gt;\r\n                    &lt;form id=&quot;form-profile&quot; action=&quot;{{ route(&#039;updateProfile&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        \u8868\u793a\u540d: &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;{{ old(&#039;name&#039;) }}&quot; required \/&gt;\r\n                        &lt;br \/&gt;\r\n                        \u81ea\u5df1\u7d39\u4ecb:\r\n                        &lt;br \/&gt;\r\n                        &lt;textarea name=&quot;description&quot; required&gt;{{ old(&#039;profile&#039;) }}&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button class=&quot;btn&quot;&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                    @else\r\n                        @if(empty($following))\r\n                        &lt;form id=&quot;form-follow&quot; action=&quot;{{ route(&#039;follow&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                            @csrf\r\n                            &lt;input type=&quot;hidden&quot; name=&quot;user_id&quot; value=&quot;{{ \\Auth::user()-&gt;id }}&quot; \/&gt;\r\n                            &lt;input type=&quot;hidden&quot; name=&quot;follow_id&quot; value=&quot;{{ $user-&gt;id }}&quot; \/&gt;\r\n                            &lt;button id=&quot;follow-button&quot; class=&quot;btn&quot;&gt;\u30d5\u30a9\u30ed\u30fc\u3059\u308b&lt;\/button&gt;\r\n                        &lt;\/form&gt;\r\n                        @else\r\n                        &lt;div&gt;\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u307e\u3059\u3002&lt;\/div&gt;\r\n                        @endif\r\n                    @endif\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script&gt;\r\n    $(function() {\r\n        $(&#039;#form-profile&#039;).hide();\r\n        $(&#039;.form-edit&#039;).click(function() {\r\n            $(&#039;#form-profile&#039;).show();\r\n        })\r\n    })\r\n    &lt;\/script&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<p>web.php \u306b unfollow \u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [16]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse App\\Http\\Controllers\\ProfileController;\r\nuse App\\Http\\Controllers\\TweetController;\r\nuse Illuminate\\Support\\Facades\\Route;\r\n\r\nRoute::get(&#039;\/&#039;, function () {\r\n    return view(&#039;welcome&#039;);\r\n});\r\n\r\nRoute::get(&#039;\/dashboard&#039;, &#x5B;TweetController::class, &#039;index&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;dashboard&#039;);\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;tweet&#039;);\r\nRoute::get(&#039;\/prof\/{name}&#039;, &#x5B;TweetController::class, &#039;profile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;profile&#039;);\r\nRoute::post(&#039;\/updateProfile&#039;, &#x5B;TweetController::class, &#039;updateProfile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;updateProfile&#039;);\r\nRoute::post(&#039;\/follow&#039;, &#x5B;TweetController::class, &#039;follow&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;follow&#039;);\r\nRoute::post(&#039;\/unfollow&#039;, &#x5B;TweetController::class, &#039;unfollow&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;unfollow&#039;);\r\n\r\nRoute::middleware(&#039;auth&#039;)-&gt;group(function () {\r\n    Route::get(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;edit&#039;])-&gt;name(&#039;profile.edit&#039;);\r\n    Route::patch(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;update&#039;])-&gt;name(&#039;profile.update&#039;);\r\n    Route::delete(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;destroy&#039;])-&gt;name(&#039;profile.destroy&#039;);\r\n});\r\n\r\nrequire __DIR__.&#039;\/auth.php&#039;;\r\n<\/pre>\n<p>TweetController\u306bunfollow()\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<p>unfollow() \u5185\u3067\u306f\u3001Follow\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 64; title: ; notranslate\" title=\"\">\r\n    public function unfollow(Request $request)\r\n    {\r\n        $user_id = $request-&gt;input(&#039;user_id&#039;);\r\n        $follow_id = $request-&gt;input(&#039;follow_id&#039;);\r\n        $user = User::find($follow_id);\r\n        $f = Follow::where(&#039;user_id&#039;, $user_id)-&gt;where(&#039;follow_id&#039;, $follow_id)-&gt;first();\r\n        $f-&gt;delete();\r\n        return redirect()-&gt;route(&#039;profile&#039;, $user-&gt;name);\r\n    }\r\n<\/pre>\n<h4>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306b\u305d\u306e\u4eba\u306e\u30c4\u30a4\u30fc\u30c8\u3092\u8868\u793a\u3059\u308b<\/h4>\n<p>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u3067\u306f\u3001\u305d\u306e\u4eba\u306e\u30c4\u30a4\u30fc\u30c8\u306e\u4e00\u89a7\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u3092\u8868\u793a\u3057\u3066\u3044\u308b\u30e1\u30bd\u30c3\u30c9\u306fTweetController\u306eprofile()\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u305d\u306e\u4eba\u306e\u30c4\u30a4\u30fc\u30c8\u3092\u691c\u7d22\u3057\u3066\u3001profile.blade.php \u306b\u6e21\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 29; highlight: [35,36]; title: ; notranslate\" title=\"\">\r\n    public function profile($name)\r\n    {\r\n        $user = User::where(&#039;name&#039;, $name)-&gt;first();\r\n        $profile = Profile::where(&#039;user_id&#039;, $user-&gt;id)-&gt;first();\r\n        $user_id = \\Auth::user()-&gt;id;\r\n        $following = Follow::where(&#039;user_id&#039;, $user_id)-&gt;where(&#039;follow_id&#039;, $user-&gt;id)-&gt;first();\r\n        $tweets = Tweet::where(&#039;user_id&#039;, $user-&gt;id)-&gt;orderBy(&#039;created_at&#039;, &#039;desc&#039;)-&gt;get();\r\n        return view(&#039;profile&#039;, compact(&#039;user&#039;, &#039;profile&#039;, &#039;following&#039;, &#039;tweets&#039;));\r\n    }\r\n<\/pre>\n<p>profile.blade.php \u3067\u306f\u3001\u6e21\u3055\u308c\u305f $tweets \u5909\u6570\u306b\u683c\u7d0d\u3055\u308c\u305f\u30c4\u30a4\u30fc\u30c8\u3092\u30eb\u30fc\u30d7\u3067\u8868\u793a\u3057\u3066\u3084\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 11; highlight: [50,51,52,53,54,55,56,57,58]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @if(empty($profile))\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                    &lt;div&gt;\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u306f\u672a\u8a2d\u5b9a\u3067\u3059\u3002&lt;\/div&gt;\r\n                    @else\r\n                    &lt;h2&gt;{{ $profile-&gt;name }}\u3055\u3093 ({{ $user-&gt;name }})&lt;\/h2&gt;\r\n                    &lt;div&gt;{!! nl2br($profile-&gt;description) !!}&lt;\/div&gt;\r\n                    @endif\r\n                    @if(\\Auth::user()-&gt;id == $user-&gt;id)\r\n                    &lt;button class=&quot;form-edit btn&quot;&gt;\u7de8\u96c6\u3059\u308b&lt;\/button&gt;\r\n                    &lt;form id=&quot;form-profile&quot; action=&quot;{{ route(&#039;updateProfile&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                        @csrf\r\n                        \u8868\u793a\u540d: &lt;input type=&quot;text&quot; name=&quot;name&quot; value=&quot;{{ old(&#039;name&#039;) }}&quot; required \/&gt;\r\n                        &lt;br \/&gt;\r\n                        \u81ea\u5df1\u7d39\u4ecb:\r\n                        &lt;br \/&gt;\r\n                        &lt;textarea name=&quot;description&quot; required&gt;{{ old(&#039;profile&#039;) }}&lt;\/textarea&gt;\r\n                        &lt;br \/&gt;\r\n                        &lt;button class=&quot;btn&quot;&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;\r\n                    &lt;\/form&gt;\r\n                    @else\r\n                        @if(empty($following))\r\n                        &lt;form id=&quot;form-follow&quot; action=&quot;{{ route(&#039;follow&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                            @csrf\r\n                            &lt;input type=&quot;hidden&quot; name=&quot;user_id&quot; value=&quot;{{ \\Auth::user()-&gt;id }}&quot; \/&gt;\r\n                            &lt;input type=&quot;hidden&quot; name=&quot;follow_id&quot; value=&quot;{{ $user-&gt;id }}&quot; \/&gt;\r\n                            &lt;button id=&quot;follow-button&quot; class=&quot;btn&quot;&gt;\u30d5\u30a9\u30ed\u30fc\u3059\u308b&lt;\/button&gt;\r\n                        &lt;\/form&gt;\r\n                        @else\r\n                        &lt;div&gt;\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u307e\u3059\u3002&lt;\/div&gt;\r\n                        &lt;form id=&quot;form-unfollow&quot; action=&quot;{{ route(&#039;unfollow&#039;) }}&quot; method=&quot;post&quot;&gt;\r\n                            @csrf\r\n                            &lt;input type=&quot;hidden&quot; name=&quot;user_id&quot; value=&quot;{{ \\Auth::user()-&gt;id }}&quot; \/&gt;\r\n                            &lt;input type=&quot;hidden&quot; name=&quot;follow_id&quot; value=&quot;{{ $user-&gt;id }}&quot; \/&gt;\r\n                            &lt;button id=&quot;unfollow-button&quot; class=&quot;btn&quot;&gt;\u30d5\u30a9\u30ed\u30fc\u89e3\u9664\u3059\u308b&lt;\/button&gt;\r\n                        &lt;\/form&gt;\r\n                        @endif\r\n                    @endif\r\n                &lt;\/div&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($tweets as $tweet)\r\n                    &lt;div class=&quot;tweet&quot;&gt;\r\n                        &lt;div&gt;&lt;a href=&quot;{{ route(&#039;profile&#039;, $tweet-&gt;user-&gt;name) }}&quot;&gt;{{ $tweet-&gt;user-&gt;name }}&lt;\/a&gt;&lt;\/div&gt;\r\n                        &lt;div&gt;{!! nl2br($tweet-&gt;text) !!}&lt;\/div&gt;\r\n                        &lt;div&gt;{{ $tweet-&gt;created_at }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n<\/pre>\n<h4>\u30d5\u30a9\u30ed\u30fc\u4e2d\u3068\u30d5\u30a9\u30ed\u30ef\u30fc\u306e\u4e00\u89a7\u3092\u8868\u793a\u3059\u308b<\/h4>\n<p>\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u30da\u30fc\u30b8\u306b\u30d5\u30a9\u30ed\u30fc\u4e2d\u3068\u30d5\u30a9\u30ed\u30ef\u30fc\u306e\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0\u3057\u3066\u3001\u305d\u308c\u305e\u308c\u306e\u4e00\u89a7\u3092\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; first-line: 11; highlight: [19,20,21,22]; title: ; notranslate\" title=\"\">\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @if(empty($profile))\r\n                    &lt;h2&gt;{{ $user-&gt;name }}\u3055\u3093&lt;\/h2&gt;\r\n                    &lt;div&gt;\u8868\u793a\u540d\u3068\u81ea\u5df1\u7d39\u4ecb\u306f\u672a\u8a2d\u5b9a\u3067\u3059\u3002&lt;\/div&gt;\r\n                    @else\r\n                    &lt;h2&gt;{{ $profile-&gt;name }}\u3055\u3093 ({{ $user-&gt;name }})&lt;\/h2&gt;\r\n                    &lt;div&gt;{!! nl2br($profile-&gt;description) !!}&lt;\/div&gt;\r\n                    @endif\r\n                    &lt;div&gt;\r\n                        &lt;a href=&quot;{{ route(&#039;follows&#039;) }}&quot; id=&quot;btn-follows&quot;&gt;\u30d5\u30a9\u30ed\u30fc\u4e2d&lt;\/a&gt;\r\n                        &lt;a href=&quot;{{ route(&#039;followers&#039;) }}&quot; id=&quot;btn-followers&quot;&gt;\u30d5\u30a9\u30ed\u30ef\u30fc&lt;\/a&gt;\r\n                    &lt;\/div&gt;\r\n<\/pre>\n<pre class=\"brush: php; highlight: [17,18]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nuse App\\Http\\Controllers\\ProfileController;\r\nuse App\\Http\\Controllers\\TweetController;\r\nuse Illuminate\\Support\\Facades\\Route;\r\n\r\nRoute::get(&#039;\/&#039;, function () {\r\n    return view(&#039;welcome&#039;);\r\n});\r\n\r\nRoute::get(&#039;\/dashboard&#039;, &#x5B;TweetController::class, &#039;index&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;dashboard&#039;);\r\nRoute::post(&#039;\/tweet&#039;, &#x5B;TweetController::class, &#039;tweet&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;tweet&#039;);\r\nRoute::get(&#039;\/prof\/{name}&#039;, &#x5B;TweetController::class, &#039;profile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;profile&#039;);\r\nRoute::post(&#039;\/updateProfile&#039;, &#x5B;TweetController::class, &#039;updateProfile&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;updateProfile&#039;);\r\nRoute::post(&#039;\/follow&#039;, &#x5B;TweetController::class, &#039;follow&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;follow&#039;);\r\nRoute::post(&#039;\/unfollow&#039;, &#x5B;TweetController::class, &#039;unfollow&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;unfollow&#039;);\r\nRoute::get(&#039;\/follows&#039;, &#x5B;TweetController::class, &#039;follows&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;follows&#039;);\r\nRoute::get(&#039;\/followers&#039;, &#x5B;TweetController::class, &#039;followers&#039;])-&gt;middleware(&#039;auth&#039;)-&gt;name(&#039;followers&#039;);\r\n\r\nRoute::middleware(&#039;auth&#039;)-&gt;group(function () {\r\n    Route::get(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;edit&#039;])-&gt;name(&#039;profile.edit&#039;);\r\n    Route::patch(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;update&#039;])-&gt;name(&#039;profile.update&#039;);\r\n    Route::delete(&#039;\/profile&#039;, &#x5B;ProfileController::class, &#039;destroy&#039;])-&gt;name(&#039;profile.destroy&#039;);\r\n});\r\n\r\nrequire __DIR__.&#039;\/auth.php&#039;;\r\n<\/pre>\n<p>TweetController\u306bfollows()\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 75; title: ; notranslate\" title=\"\">\r\n    public function follows()\r\n    {\r\n        $user = \\Auth::user();\r\n        $follows = Follow::where(&#039;user_id&#039;, $user-&gt;id)-&gt;orderBy(&#039;created_at&#039;, &#039;desc&#039;)-&gt;get();\r\n        return view(&#039;follows&#039;, compact(&#039;follows&#039;));\r\n    }\r\n<\/pre>\n<p>follows.blade.php \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan make:view follows\r\n<\/pre>\n<p>follows.blade.php \u3067\u306f\u3001\u3068\u308a\u3042\u3048\u305a\u30d5\u30a9\u30ed\u30fc\u3057\u3066\u3044\u308b\u4eba\u306eID\u3060\u3051\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [12,13,14,15,16]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;\u30d5\u30a9\u30ed\u30fc\u4e2d&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($follows as $follow)\r\n                    &lt;div class=&quot;&quot;&gt;\r\n                        &lt;div&gt;{{ $follow-&gt;follow_id }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<p>Follow\u30af\u30e9\u30b9\u304b\u3089\u30d5\u30a9\u30ed\u30fc\u4e2d\u306eUser\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; highlight: [17,18,19,20]; title: ; notranslate\" title=\"\">\r\n&lt;?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\nuse App\\Models\\User;\r\n\r\nclass Follow extends Model\r\n{\r\n    protected $fillable = &#x5B;&#039;user_id&#039;, &#039;follow_id&#039;];\r\n\r\n    public function user()\r\n    {\r\n        return $this-&gt;belongsTo(User::class);\r\n    }\r\n\r\n    public function follow()\r\n    {\r\n        return $this-&gt;hasOne(User::class, &#039;id&#039;, &#039;follow_id&#039;);\r\n    }\r\n}\r\n<\/pre>\n<p>follows.blade.php \u3067\u3001\u30e6\u30fc\u30b6\u30fc\u540d\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [14]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;\u30d5\u30a9\u30ed\u30fc\u4e2d&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($follows as $follow)\r\n                    &lt;div class=&quot;&quot;&gt;\r\n                        &lt;div&gt;{{ $follow-&gt;follow-&gt;name }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n<p>\u540c\u69d8\u306b\u3057\u3066\u3001\u30d5\u30a9\u30ed\u30ef\u30fc\u306e\u4e00\u89a7\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p>TweetController\u306bfollowers()\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: php; first-line: 82; title: ; notranslate\" title=\"\">\r\n    public function followers()\r\n    {\r\n        $user = \\Auth::user();\r\n        $followers = Follow::where(&#039;follow_id&#039;, $user-&gt;id)-&gt;orderBy(&#039;created_at&#039;, &#039;desc&#039;)-&gt;get();\r\n        return view(&#039;followers&#039;, compact(&#039;followers&#039;));\r\n    }\r\n<\/pre>\n<p>followers.blade.php \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; php artisan make:view followers\r\n<\/pre>\n<p>followers.blade.php \u306e\u5185\u5bb9\u306f follows.blade.php \u3092\u30b3\u30d4\u30fc\u3057\u3066\u3001\u5fc5\u8981\u306a\u90e8\u5206\u3060\u3051\u5909\u66f4\u3059\u308b\u3068\u697d\u3067\u3059\u3002<\/p>\n<pre class=\"brush: xml; highlight: [4,12,14]; title: ; notranslate\" title=\"\">\r\n&lt;x-app-layout&gt;\r\n    &lt;x-slot name=&quot;header&quot;&gt;\r\n        &lt;h2 class=&quot;font-semibold text-xl text-gray-800 leading-tight&quot;&gt;\r\n            {{ __(&#039;\u30d5\u30a9\u30ed\u30ef\u30fc&#039;) }}\r\n        &lt;\/h2&gt;\r\n    &lt;\/x-slot&gt;\r\n\r\n    &lt;div class=&quot;py-12&quot;&gt;\r\n        &lt;div class=&quot;max-w-7xl mx-auto sm:px-6 lg:px-8&quot;&gt;\r\n            &lt;div class=&quot;bg-white overflow-hidden shadow-sm sm:rounded-lg&quot;&gt;\r\n                &lt;div class=&quot;p-6 text-gray-900&quot;&gt;\r\n                    @foreach($followers as $follower)\r\n                    &lt;div class=&quot;&quot;&gt;\r\n                        &lt;div&gt;{{ $follower-&gt;user-&gt;name }}&lt;\/div&gt;\r\n                    &lt;\/div&gt;\r\n                    @endforeach\r\n                &lt;\/div&gt;\r\n            &lt;\/div&gt;\r\n        &lt;\/div&gt;\r\n    &lt;\/div&gt;\r\n&lt;\/x-app-layout&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210 Twitter\u306b\u4f3c\u305f\u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u65b0\u3057\u3044\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u306f\u3001X\u3068Twitter\u306e\u4e21\u65b9\u3092\u30ea\u30b9\u30da\u30af\u30c8\u3057\u3066\u3001xtter\u3068\u3044\u3046\u540d\u524d\u3067\u4f5c\u6210\u3057\u307e &#8230; <\/p>\n","protected":false},"author":1,"featured_media":11,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-basics"],"_links":{"self":[{"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79"}],"version-history":[{"count":56,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/79\/revisions\/139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=\/wp\/v2\/media\/11"}],"wp:attachment":[{"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laravel.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}