.PHONY: help setup install migrate seed fresh test queue horizon scheduler up down build clean logs

help: ## Show this help message
	@echo 'Usage: make [target]'
	@echo ''
	@echo 'Available targets:'
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

setup: ## Initial setup - install dependencies and prepare environment
	cp .env.example .env
	composer install
	php artisan key:generate
	php artisan storage:link
	make migrate
	make seed

install: ## Install PHP dependencies
	composer install

migrate: ## Run database migrations
	php artisan migrate

seed: ## Seed database with demo data
	php artisan db:seed

fresh: ## Fresh database with migrations and seeds
	php artisan migrate:fresh --seed

test: ## Run tests
	php artisan test

queue: ## Start queue worker
	php artisan queue:work redis --tries=3

horizon: ## Start Horizon dashboard
	php artisan horizon

scheduler: ## Start scheduler (for dev)
	php artisan schedule:work

up: ## Start Docker containers
	docker-compose up -d

down: ## Stop Docker containers
	docker-compose down

build: ## Build Docker images
	docker-compose build --no-cache

clean: ## Clean up caches and logs
	php artisan cache:clear
	php artisan config:clear
	php artisan route:clear
	php artisan view:clear

logs: ## Tail application logs
	tail -f storage/logs/laravel.log

optimize: ## Optimize for production
	composer install --optimize-autoloader --no-dev
	php artisan config:cache
	php artisan route:cache
	php artisan view:cache
