terminal — php artisan tinker
# 1) Start Tinker (run in your terminal)
php artisan tinker
# 2) Inside Tinker, paste these — 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 v0.12 (PHP 8.2 — cli) by Justin Hileman
> Employee::create([...]);
=> App\Models\Employee {#1234 id: 1, name: "Asha Rao", department: "Engineering"}
> Employee::count();
=> 1
> Employee::factory()->count(3)->create();
=> Illuminate\Database\Eloquent\Collection {#1240 all: 3 items}