ユーザー登録する

Laravel10以降では、データベースにユーザーテーブルが作成されます。ユーザー情報を以下のようにして登録することが可能です。/ahoにプロジェクトがあると仮定して話を進めます。

$ cd /aho
$ php artisan tinker
Psy Shell v0.11.17 (PHP 8.2.6 — cli) by Justin Hileman
> $user = new User();
[!] Aliasing 'User' to 'App\Models\User' for this Tinker session.
= App\Models\User {#6212}

> $user->name = 'aho'
= "aho"

> $user->email = 'aho@ahoahopower.com'
= "aho@ahoahopower.com"

> $user->password = bcrypt('11111111');
= "$2y$10$I.xBdGWAvE3Ob7Mmdf2Vn.Z.kT9dQpBPN5IqdYDW1FeNknOPGyK5y"

> $user->save();
= true

> quit

ユーザー情報の確認は以下の手順で行います。

$ cd /aho
$ php artisan tinker
Psy Shell v0.11.17 (PHP 8.2.6 — cli) by Justin Hileman
> $users = User::all();
[!] Aliasing 'User' to 'App\Models\User' for this Tinker session.
= Illuminate\Database\Eloquent\Collection {#6950
    all: [
      App\Models\User {#6909
        id: 1,
        name: "aho",
        email: "aho@ahoahopower.com",
        email_verified_at: null,
        #password: "$2y$10$I.xBdGWAvE3Ob7Mmdf2Vn.Z.kT9dQpBPN5IqdYDW1FeNknOPGyK5y",
        #remember_token: null,
        created_at: "2023-05-15 01:25:37",
        updated_at: "2023-05-15 01:25:37",
      },
    ],
  }

>