Use the following prompt in Antigravity. It covers a clean Laravel structure for **common layout/header/footer** and a scalable **contact/enrollment popup email flow** without affecting existing functionality.

Analyze the existing Laravel project completely before making any changes.

I need a proper implementation plan and then implementation for the following two areas:

## 1. Common Laravel Layout — Header, Footer and Main Layout

Create a clean, reusable Laravel Blade layout structure for the entire website.

### Requirements

* Inspect the existing:

  * routes
  * controllers
  * Blade views
  * CSS
  * JavaScript
  * images/assets
  * existing header
  * existing footer
* Do not duplicate header/footer code across individual pages.
* Create a common master layout using Blade.
* Suggested structure:

```text
resources/views/
├── layouts/
│   └── app.blade.php
├── components/
│   ├── header.blade.php
│   └── footer.blade.php
├── pages/
│   ├── home.blade.php
│   ├── contact.blade.php
│   └── ...
```

Use the existing project structure if there is already an established convention. Do not unnecessarily restructure the application.

### Master Layout

Create a common layout containing:

* HTML document structure
* `<head>`
* meta tags
* CSRF token
* common CSS
* common JavaScript
* header
* `@yield('content')`
* footer
* page-specific CSS/JS sections where required

Example concept:

```blade
@extends('layouts.app')

@section('content')
    ...
@endsection
```

Use Blade sections/stacks appropriately, such as:

```blade
@stack('styles')
@stack('scripts')
```

### Header

Move the common header/navigation into a reusable Blade component or partial.

The header should support:

* logo
* navigation menu
* active menu state
* mobile menu
* existing buttons/links
* authentication-dependent items if currently present

Do not break any existing URLs, routes, JavaScript, or responsive behavior.

### Footer

Move the common footer into a reusable Blade component or partial.

Preserve all existing:

* links
* copyright information
* social links
* scripts
* footer-specific functionality

Do not duplicate footer markup across pages.

### Important

Before changing anything:

1. Identify all pages currently using header/footer.
2. Identify duplicated markup.
3. Identify dependencies between header/footer JavaScript and individual pages.
4. Identify existing CSS selectors/classes that must remain unchanged.
5. Create a migration/implementation plan.
6. Implement only after validating the plan.

Do not redesign the website. This task is only about creating a maintainable common layout while preserving the current UI and functionality.

---

# 2. Contact / Enrollment Popup Email System

I need a proper and scalable Laravel approach for sending emails from both:

* Contact form
* Enrollment popup/form

Do NOT directly place mail-sending logic inside Blade files.

Recommended architecture:

```text
Blade Form
    ↓
Route
    ↓
Controller
    ↓
Form Request Validation
    ↓
Service / Mail Logic
    ↓
Laravel Mailable
    ↓
SMTP / Mail Provider
    ↓
Admin Email
```

## Forms

First inspect the existing contact and enrollment popup forms.

Identify:

* form fields
* popup implementation
* existing AJAX/fetch/jQuery submission
* current routes
* current controllers
* existing validation
* existing database tables, if any
* existing mail configuration
* existing success/error handling

Do not create duplicate functionality if an existing implementation already exists.

## Validation

Use Laravel validation/Form Request classes where appropriate.

Validate fields such as:

### Contact

* name
* email
* phone, if present
* subject, if present
* message

### Enrollment

* name
* email
* phone
* course/program
* message or additional fields, if present

Use appropriate:

* `required`
* `string`
* `email`
* `max`
* `nullable`

Do not trust user-submitted values.

## Email Architecture

Use Laravel Mailables rather than calling `Mail::send()` directly from controllers when a reusable implementation is appropriate.

Create separate mailables if the emails have different purposes:

```text
app/Mail/
├── ContactFormMail.php
└── EnrollmentFormMail.php
```

Create email Blade templates:

```text
resources/views/emails/
├── contact.blade.php
└── enrollment.blade.php
```

Keep email HTML clean and responsive.

## Configuration

Use `.env` for mail configuration.

Do NOT hardcode:

* SMTP username
* SMTP password
* API keys
* email credentials
* recipient credentials

Use Laravel's standard mail configuration:

```env
MAIL_MAILER=smtp
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=
```

If the project already has a configured mail provider, inspect and reuse it.

Do not change the production mail provider without confirmation.

## Recommended Email Flow

For Contact:

```text
User submits Contact form
        ↓
Validate request
        ↓
Process submission
        ↓
Send notification to configured admin email
        ↓
Return success response
```

For Enrollment:

```text
User opens Enrollment popup
        ↓
Fills enrollment form
        ↓
Validate request
        ↓
Send enrollment notification to configured admin email
        ↓
Return success response
```

If the project already stores leads/submissions in the database, preserve that functionality.

If there is no database storage, first determine whether storing submissions is required before introducing a new table.

## AJAX / Popup Handling

If the existing popup submits using AJAX:

* keep AJAX behavior
* return proper JSON responses
* show validation errors without unnecessarily closing the popup
* show success message after successful submission
* prevent duplicate submissions
* disable submit button while request is processing
* handle server errors gracefully

Do not convert an existing AJAX form into a normal page submission unless there is a specific reason.

Example response structure:

```json
{
    "success": true,
    "message": "Your request has been submitted successfully."
}
```

For validation errors, return Laravel's standard validation response where appropriate.

## Security

Implement basic protection:

* CSRF protection
* server-side validation
* email validation
* rate limiting/throttling where appropriate
* prevent duplicate submissions
* sanitize/escape email content
* never expose SMTP credentials
* never trust hidden form fields
* prevent email-header injection
* avoid accepting arbitrary recipient email addresses from the user

If reCAPTCHA or another anti-spam system already exists, inspect it and preserve it.

Recommend adding rate limiting if the forms are publicly accessible.

## Email Recipient

Do not hardcode the admin recipient inside controllers.

Prefer configuration such as:

```env
CONTACT_NOTIFICATION_EMAIL=
ENROLLMENT_NOTIFICATION_EMAIL=
```

or an existing application configuration mechanism.

Controllers should read configuration rather than contain email addresses.

## Logging and Error Handling

Implement proper error handling.

If email sending fails:

* log the actual server-side exception
* do not expose SMTP credentials or sensitive details to the user
* return a user-friendly error message
* preserve the submitted data where appropriate
* make debugging possible through Laravel logs

Example:

```text
User:
"Something went wrong. Please try again later."
```

Server log:

```text
Mail transport exception...
```

## Queue Recommendation

First determine whether the application already uses Laravel queues.

For a small application, synchronous email sending can be acceptable initially.

For production/scalable implementation, prefer queued mail:

```php
implements ShouldQueue
```

if the queue infrastructure is properly configured.

Do not enable queue-based mail if the project does not have a working queue worker/configuration without documenting the required setup.

---

# 3. Route Structure

Review existing routes before adding anything.

Prefer clear POST routes such as:

```text
POST /contact
POST /enrollment
```

Use named routes where appropriate:

```php
route('contact.submit')
route('enrollment.submit')
```

Do not create duplicate routes.

---

# 4. Controller Structure

Keep controllers thin.

Avoid putting:

* large HTML blocks
* email templates
* SMTP configuration
* complex business logic

inside controllers.

Use:

```text
Controller
    ↓
Validation
    ↓
Service / application logic
    ↓
Mailable
```

If a service layer is unnecessary for this project's size, keep the implementation simple rather than introducing unnecessary abstraction.

Use the simplest architecture that is maintainable and scalable.

---

# 5. Implementation Plan Before Coding

Before modifying files, provide a concise analysis containing:

### A. Existing Architecture

* Laravel version
* current Blade structure
* current layout/header/footer implementation
* current routes
* current controllers
* current contact form implementation
* current enrollment popup implementation
* current mail configuration

### B. Files That Need Changes

List exact files that will be:

* created
* modified
* left unchanged

### C. Proposed Architecture

Show the final request flow:

```text
Page
 ↓
Common Layout
 ↓
Header / Content / Footer

Contact Form
 ↓
Route
 ↓
Controller
 ↓
Validation
 ↓
Mailable
 ↓
SMTP
 ↓
Admin
```

### D. Risk Assessment

Identify anything that could affect:

* existing pages
* CSS
* JavaScript
* responsive design
* routes
* popup behavior
* authentication
* email configuration

### E. Implementation

Only after analysis, implement the changes.

---

# 6. Testing Checklist

After implementation, test all existing pages to ensure:

* header displays correctly
* footer displays correctly
* desktop layout works
* mobile layout works
* navigation works
* existing links still work
* existing JavaScript still works
* no console errors
* no Laravel errors
* no duplicated header/footer
* contact popup/form opens correctly
* enrollment popup/form opens correctly
* validation works
* invalid email is rejected
* required fields are validated
* successful submission works
* admin receives email
* email subject is correct
* email content is correct
* SMTP failure is handled
* duplicate submission is prevented
* CSRF protection works

Check:

```bash
php artisan route:list
php artisan optimize:clear
php artisan config:clear
php artisan view:clear
```

Also inspect:

```text
storage/logs/laravel.log
```

for errors.

## Critical Rule

Do not blindly create a new architecture.

First inspect the existing Laravel project and reuse existing:

* layouts
* components
* controllers
* routes
* mail configuration
* JavaScript
* CSS
* database functionality

Avoid unnecessary changes and do not break existing functionality.

The final implementation should be clean, reusable, secure, maintainable, and easy to extend for additional forms in the future.


1. Common Laravel Layout Architecture
Master Layout (
resources/views/layouts/app.blade.php
): Master Blade layout containing standard HTML <head> tags, CSRF meta tag, asset bundles (Bootstrap 5, FontAwesome, Google Fonts, css/style.css), @yield('content'), and Blade @stack hooks.
Header Component (
resources/views/components/header.blade.php
): Modular navigation bar with logo, dropdown menus, responsive collapse, and "Enroll Now" trigger buttons.
Footer Component (
resources/views/components/footer.blade.php
): Modular footer with site links, copyright, social icons, and legal pages.
Enrollment Modal Component (
resources/views/components/enrollment-modal.blade.php
): Reusable enrollment popup modal with CSRF, validation containers, and submit button state management.
Home View (
resources/views/pages/home.blade.php
): Clean page extending layouts.app while preserving 100% of existing CSS classes, HTML IDs, images, and responsive styling.
2. Contact / Enrollment Popup Email System
Form Requests: Created 
ContactFormRequest
 and 
EnrollmentFormRequest
 for strict server-side validation (name, email, website, message).
Controllers: Created 
ContactController
 and 
EnrollmentController
 with try-catch blocks and error logging to storage/logs/laravel.log.
Mailables & Templates: Created 
ContactFormMail
 and 
EnrollmentFormMail
 with responsive HTML templates (
emails/contact.blade.php
, 
emails/enrollment.blade.php
).
Routes & Config: Registered named routes contact.submit (POST /contact) and enrollment.submit (POST /enrollment) with rate-limiting middleware (throttle:6,1) in 
routes/web.php
. Added CONTACT_NOTIFICATION_EMAIL and ENROLLMENT_NOTIFICATION_EMAIL settings to 
.env
 and 
config/mail.php
.
AJAX Interactivity: Enhanced 
public/css/script.js
 to submit forms asynchronously via fetch(), pass X-CSRF-TOKEN, display button spinners, show inline 422 validation errors, and display success notifications.
Verification
Automated Tests: Added 
tests/Feature/FormSubmissionTest.php
 testing page load, form validation failures, and successful email dispatching. All 7 test assertions passed cleanly (php artisan test).
Routes & Caches: Cleared all caches (php artisan optimize:clear & config:clear) and verified routes via php artisan route:list.





Analyze the existing Laravel project and create an implementation plan only. Do not modify any code yet.

I need a proper SEO structure for each Laravel page, with dynamically managed:

* SEO Title
* Meta Description
* Meta Keywords
* Canonical URL

### Requirements

1. Identify all existing pages/routes and group them as:

   * Home
   * Static pages
   * Course/product pages
   * Blog/listing pages
   * Blog/detail pages
   * Contact/enrollment pages
   * Any dynamic/detail pages

2. Recommend the best Laravel approach to manage SEO data dynamically without duplicating `<title>` and meta tags in every Blade file.

3. Suggest a common SEO Blade component/partial, for example:

```text
resources/views/components/seo.blade.php
```

or another structure if better suited to the existing project.

4. Plan how each page can pass its own SEO values to the common layout, such as:

```text
$title
$description
$keywords
$canonical
```

5. For dynamic pages, explain how SEO data should be generated from database content, for example:

   * Course title
   * Course description
   * Blog title/content
   * Slug
   * Category
   * Other relevant fields

6. Recommend what additional SEO elements should be implemented:

* Open Graph title
* Open Graph description
* Open Graph image
* Open Graph URL
* Twitter/X card metadata
* Robots meta
* Schema.org structured data / JSON-LD
* Breadcrumb schema
* Course schema where applicable
* Article schema for blogs
* Organization/Website schema
* Sitemap.xml
* Robots.txt
* Canonical URL handling
* Pagination SEO
* Image alt attributes
* H1/H2 heading structure
* Clean SEO-friendly URLs
* 404/noindex handling

7. Recommend sensible fallback/default SEO values when a page does not have custom SEO data.

8. Explain whether SEO fields should be:

   * hardcoded in Blade
   * passed from controllers
   * stored in database
   * managed through an admin panel

Recommend the best option for this existing Laravel application.

9. Provide a page-by-page SEO implementation plan showing which SEO fields should be static and which should be dynamically generated.

10. Check for potential duplicate-title, duplicate-description, canonical, and indexing issues in the current application.

### Important

Do not implement anything yet.

First provide:

* Current SEO structure
* Problems found
* Recommended architecture
* Database changes required, if any
* Files that would need to be created/modified
* Page-by-page SEO strategy
* Dynamic SEO flow
* Additional SEO recommendations
* Implementation steps in order

The plan must preserve the existing Laravel functionality and avoid unnecessary changes.
==============================================================================================================
Review the existing Laravel dynamic page implementation, especially:

```php
Route::get('/{slug}', [PageController::class, 'show'])
    ->name('page.show')
    ->where('slug', '[a-zA-Z0-9\-]+');
```

Also inspect:

* `PageController`
* `programmatic.php`
* `public/dynamic_page`
* Related Blade views
* Assets
* Routes
* Models/database queries
* CSS/JS dependencies

The dynamic page functionality is currently working. **Do not change its behavior or break any existing pages.**

### Goal

Separate the dynamic page layout and related files into a clean, understandable folder structure.

Suggest a structure similar to:

```text
resources/views/
├── layouts/
├── components/
└── dynamic-pages/
    ├── layouts/
    ├── pages/
    └── components/
```

And organize dynamic-page-specific assets separately where appropriate, while keeping existing public URLs/assets working.

### Requirements

1. First analyze the current implementation.
2. Identify which files belong specifically to dynamic pages.
3. Suggest the cleanest folder structure.
4. Check whether `programmatic.php` should remain as it is or be moved/refactored.
5. Check how `public/dynamic_page` is currently referenced.
6. Ensure the catch-all `/{slug}` route does not conflict with existing routes.
7. Do not change the existing route behavior unless absolutely necessary.
8. Preserve all existing:

   * URLs
   * slugs
   * database functionality
   * CSS
   * JavaScript
   * images/assets
   * forms
   * SEO functionality
   * page content
9. Avoid duplicate layouts/components.
10. Use Laravel Blade layouts/components where appropriate.
11. Keep common website header/footer in the existing common layout rather than duplicating them inside every dynamic page.

### Before implementation

Provide only an implementation plan containing:

* Current structure
* Problems/duplication found
* Recommended folder structure
* Files to move/create/update
* Route impact
* Asset impact
* Risk of breaking existing functionality
* Step-by-step migration approach

Do not implement anything yet.

The priority is **better organization and maintainability without affecting the existing dynamic page functionality**.
