Skip to content

animan01/Lucky-game-laravel

Repository files navigation

Preview

Kapture 2025-01-21 at 09 43 42

Lucky Game

A simple web-based game built with Laravel 11, PostgreSQL, and Redis.

Tech Stack

  • PHP 8.2
  • Laravel 11
  • PostgreSQL 15
  • Redis
  • Docker & Docker Compose
  • Tailwind CSS

Requirements

  • Docker
  • Docker Compose
  • Git

Installation

  1. Clone the repository:
git clone https://github.com/animan01/lucky-game-laravel.git
cd lucky-game-laravel
  1. Copy the environment file:
cp .env.example .env
  1. Start Docker containers:
docker-compose up -d
  1. Install PHP dependencies:
docker-compose exec app composer install
  1. Generate application key:
docker-compose exec app php artisan key:generate
  1. Run database migrations:
docker-compose exec app php artisan migrate
  1. Visit the application:
http://localhost:8000

Game Rules

  1. Register with username and phone number
  2. Get a unique link valid for 7 days
  3. Play the game by clicking "I'm Feeling Lucky"
  4. Win or lose based on random number:
    • Even number = Win
    • Odd number = Lose
  5. Win amount calculation:
    • Number > 900: 70% of the number
    • Number > 600: 50% of the number
    • Number > 300: 30% of the number
    • Number ≤ 300: 10% of the number

Container Management

View running containers:

docker-compose ps

View container logs:

docker-compose logs -f [service_name]

Stop containers:

docker-compose down

Rebuild containers:

docker-compose up -d --build

Database Management

Fresh migration:

docker-compose exec app php artisan migrate:fresh

Cache Management

Clear application cache:

docker-compose exec app php artisan cache:clear

Clear config cache:

docker-compose exec app php artisan config:clear

Troubleshooting

  1. If the site is not accessible:

    • Check if all containers are running: docker-compose ps
    • Check nginx logs: docker-compose logs nginx
    • Ensure port 8000 is not in use
  2. Database connection issues:

    • Verify database credentials in .env
    • Check if PostgreSQL container is running
    • Check database logs: docker-compose logs database
  3. Permission issues:

    • Run: docker-compose exec app chown -R www-data:www-data storage
    • Run: docker-compose exec app chmod -R 775 storage

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

The GPL-3.0 license. Please see License File for more information.

About

A small game that tests your luck.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published