# Asset Versioning System

This project now uses a centralized asset versioning system for cache busting.

## How It Works

All CSS and JavaScript files now use a single environment variable `ASSET_VERSION` instead of hardcoded version numbers.

### Files Updated

-   **28 total files** now use `{{ env('ASSET_VERSION') }}`
-   All `.blade.php` files with CSS/JS links
-   Includes main app files, page-specific styles, and JavaScript modules

### Current Setup

-   **Environment Variable**: `ASSET_VERSION=2.0.1` in `.env`
-   **Config**: Available as `config('app.asset_version')`
-   **Helper Functions**: `asset_version()` and `versioned_asset()`

## Usage

### Quick Version Updates

```bash
# Increment patch version (2.0.1 -> 2.0.2)
php increment-version.php patch

# Increment minor version (2.0.1 -> 2.1.0)
php increment-version.php minor

# Increment major version (2.0.1 -> 3.0.0)
php increment-version.php major

# Default is patch if no argument provided
php increment-version.php
```

### Using Aliases (Optional)

Load the provided aliases for even easier usage:

```bash
# Load aliases (one time setup)
source version-aliases.sh

# Then use simple commands:
version-patch   # Increment patch version
version-minor   # Increment minor version
version-major   # Increment major version
version-current # Show current version
clear-cache     # Clear Laravel caches
```

### Helper Functions

```php
// Get current version
asset_version(); // Returns: "2.0.1"

// Generate versioned asset URL
versioned_asset('css/app.css'); // Returns: "https://site.com/css/app.css?v=2.0.1"
```

### Manual .env Update

You can also manually edit the version in `.env`:

```env
# Change this value to force all assets to reload
ASSET_VERSION=2.1.0
```

## Benefits

✅ **Single Point of Control** - Update all asset versions at once  
✅ **Cache Busting** - Force browser reloads when needed  
✅ **Easy Deployment** - Increment version during builds  
✅ **No More Hardcoding** - Centralized version management  
✅ **Laravel Integration** - Works with config caching

## Examples

### Before

```blade
<link href="{{ url('/css/app.css') }}?v=1.9" rel="stylesheet">
<script src="{{ url('/js/app.js') }}?v=1.3"></script>
```

### After

```blade
<link href="{{ url('/css/app.css') }}?v={{ env('ASSET_VERSION') }}" rel="stylesheet">
<script src="{{ url('/js/app.js') }}?v={{ env('ASSET_VERSION') }}"></script>
```

### In Production

When you run `php increment-version.php patch`, all assets automatically get the new version without touching individual files!

## Deployment Integration

Add to your deployment script:

```bash
# Before deploying
php increment-version.php patch
php artisan config:clear
```

This ensures all users get fresh assets after each deployment.
