Tinker is a Laravel intractive command line shell and scripting interface. Tinker core includes many helpful commands and generators; we’ll utilise Tinker to create a user in Laravel.
To start using Tinker we run this command
1
|
php artisan tinker or php artisan ti
|
To create the user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
php artisan tinker
Psy Shell v0.11.15 (PHP 8.2.1 — cli) by Justin Hileman
> $user = new User
[!] Aliasing 'User' to 'App\Models\User' for this Tinker session.
= App\Models\User {#6211}
> $user->name ="admin"
= "admin"
> $user->email="[email protected]"
= "[email protected]"
> $user->password = bcrypt('!password')
= "$2y$10$3zn5Ags0QyJXPe4ESbuBV.qISX4m/ZsTpScELZBAAHg4hjqXeEBW2"
|
Then to presist this data in the users table we call $user->save()
1
2
|
> $user->save()
= true
|
Here’s how the data in the users table is saved.