# Laravel 12 + Livewire 4 Employee CRUD

A simple Employee Management project demonstrating a complete CRUD operation using Laravel and Livewire.

## Features

- Add employee
- List employees
- Edit employee
- Delete employee with confirmation
- Live search without full page reload
- Bootstrap pagination
- Server-side validation
- Unique email validation during create and update
- MySQL migration and sample seeder
- PHPUnit/Livewire CRUD tests
- Bootstrap 5 interface

## Requirements

- PHP 8.2 or newer
- Composer 2
- MySQL/MariaDB
- Laravel 12
- Livewire 4

## Windows XAMPP Installation

Extract the project inside:

```text
C:\xampp8.2\htdocs\laravel-livewire-employee-crud
```

Open PowerShell in the project folder:

```powershell
cd C:\xampp8.2\htdocs\laravel-livewire-employee-crud
composer install
Copy-Item .env.example .env
php artisan key:generate
```

Create a MySQL database named `livewire_crud` in phpMyAdmin.

Confirm these `.env` values:

```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=livewire_crud
DB_USERNAME=root
DB_PASSWORD=
```

Run the migration and seed sample data:

```powershell
php artisan migrate --seed
php artisan serve
```

Open:

```text
http://127.0.0.1:8000/employees
```

## Alternative: Import SQL

You may import `database.sql` in phpMyAdmin instead of running the employee migration and seeder. Laravel still needs its other database tables if you later change cache, session, or queue drivers to database.

## Important Livewire Behavior

Create, update, delete, search, and pagination do not perform a full browser page refresh. Livewire sends background requests and updates only the required HTML.

## Main Files

```text
app/Livewire/Employees/EmployeeManager.php
app/Models/Employee.php
database/migrations/2026_08_06_000000_create_employees_table.php
database/seeders/EmployeeSeeder.php
resources/views/livewire/employees/employee-manager.blade.php
resources/views/layouts/app.blade.php
routes/web.php
```

## Run Tests

```powershell
php artisan test
```

## Clear Cache After Changes

```powershell
php artisan optimize:clear
```
