terminal — php artisan tinker
# Start the REPL
php artisan tinker
# Create a row (uses the employees table from LEP 01)
>>> use App\Models\Employee;
>>> Employee::create([
... 'name' => 'Asha Rao',
... 'age' => 29,
... 'email' => 'asha@example.com',
... 'address' => '12 MG Road',
... 'department' => 'Engineering',
... ]);
# Read it back
>>> Employee::count();
>>> Employee::where('department', 'Engineering')->get();
# Bulk-create with the factory
>>> Employee::factory()->count(3)->create();
Output
Psy Shell (PHP 8.3) — type help for help.
>>> Employee::create([...]);
=> App\Models\Employee { id: 1, name: "Asha Rao", department: "Engineering" }
>>> Employee::count();
=> 1
>>> Employee::factory()->count(3)->create();
=> Illuminate\Database\Eloquent\Collection (3 items)