#!/bin/bash

# Fix Laravel storage permissions
echo "Fixing storage and bootstrap/cache permissions..."

# Set ownership to the web server user (typically apache or nginx)
chown -R apache:apache storage bootstrap/cache

# Set directory permissions to 775
find storage -type d -exec chmod 775 {} \;
find bootstrap/cache -type d -exec chmod 775 {} \;

# Set file permissions to 664
find storage -type f -exec chmod 664 {} \;
find bootstrap/cache -type f -exec chmod 664 {} \;

echo "Permissions fixed!"
echo ""
echo "If you're still having issues, try:"
echo "  chmod -R 777 storage bootstrap/cache"
echo "(Note: 777 is less secure but useful for troubleshooting)"
