#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
command -v php >/dev/null
command -v composer >/dev/null
if [ ! -f .env ]; then
  cp .env.example .env
  echo 'Created .env. Set APP_URL, DB credentials, Redis password and other secrets; rerun this script.'
  exit 1
fi
composer install --no-dev --prefer-dist --no-interaction --optimize-autoloader
php artisan platform:setup-check
php artisan migrate --force
php artisan db:seed --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
echo 'Setup completed. Create the owner with: php artisan platform:create-user owner@example.com --owner'
