Skip to content

A comprehensive, modern eCommerce platform built with Laravel 12, featuring a beautiful storefront and powerful admin panel with role-based access control.

Notifications You must be signed in to change notification settings

needyamin/eCommerceLaravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛒 Laravel eCommerce System

A comprehensive, modern eCommerce platform built with Laravel 12, featuring a beautiful storefront and powerful admin panel with role-based access control.

Laravel PHP License

✨ Features

🛍️ Storefront

  • Product Catalog: Browse products by categories with advanced filtering & sorting
  • Live Search: Real-time product search with dropdown results (triggers after 3 characters, shows up to 20 products with images, prices, categories, and stock status)
  • Shopping Cart (AJAX): Add to cart, inline increase/decrease, and remove without page reload; live header count
  • Coupons: Apply/remove coupons (AJAX) with discount reflected in totals
  • Checkout Process: Secure checkout with validation and order creation, email notification
  • Payment Methods: Stripe, PayPal, and Cash on Delivery (COD) - all configurable from admin panel
  • Currency: Default currency enforced globally via @currency(...) (frontend switching disabled)
  • Coins (Loyalty Points): Earn coins for add‑to‑cart, order placement, COD choice, and referral sign‑ups. Balance shown on profile; admin can adjust/reset.
  • Product Reviews & Ratings: Customers can leave reviews with ratings (1-5 stars), verified purchase badges, and admin moderation
  • Newsletter: Email subscription system with double opt-in support and welcome emails
  • Pages System: Customizable content pages (Help Center, Shipping Info, Returns, Contact Us) with rich text editor
  • Wishlist: Add products to wishlist (supports both authenticated users and guests)
  • Responsive Design: Mobile-first Bootstrap 5 UI (storefront) with modern components
  • User Authentication: Login, register, profile update, password change
  • User Profile: View orders, addresses, reviews, and coin balance

🔧 Admin Panel

  • Dashboard: Stats tiles + 14‑day Orders/Revenue charts; Recent Orders; Low Stock
  • Products/Categories: Full CRUD with images, hierarchical categories, rich text editor for descriptions
  • Orders: Index/show/update; colored badges for Status/Payment/Shipping
  • Users: View user details, orders, cart items, wishlist, sessions; adjust/reset coins
  • Roles/Permissions: Spatie permissions with route‑based checks; route permissions auto-listed
  • Administrators: Manage admin users and assign roles (Admin → Administrators)
  • Pages Management: CRUD for custom pages (Help Center, Shipping Info, Returns, Contact Us) with rich text editor
  • Reviews Management: Approve/reject/delete product reviews; filter by status
  • Newsletter Subscribers: Manage newsletter subscribers, toggle subscription status
  • Site Settings: Comprehensive settings including:
    • Basic site information (name, tagline, logo, favicon)
    • SEO settings (meta title, description, keywords)
    • Legal & footer links (privacy, terms, cookies, customer service links)
    • Social media links
    • Feature toggles (wishlist, reviews, newsletter)
    • Review settings (enable/disable, require purchase, require approval, allow anonymous)
    • Newsletter settings (enable/disable, double opt-in, welcome email)
  • Payment Gateways: Stripe/PayPal/COD configure, enable/disable, test connection; logs
  • Currencies: CRUD, set default/toggle active, rates & formatting
  • Email Settings: Admin-managed SMTP applied at runtime
  • Coin Settings: Configure coin awards (add‑to‑cart award + daily cap, order award rate/minimum, COD bonus, referral signup bonus) and enable/disable features
  • Shipping Settings: Enable/disable shipping, free‑shipping threshold, per‑country/city rates (flat/percent), global fallback rate
  • OTP Settings: Configure email and SMS OTP settings
  • Server-Side DataTables: All admin tables use server-side processing for better performance with search, filters, and pagination
  • Breadcrumbs: Automatic breadcrumb navigation throughout admin panel

🔐 Security & Authorization

  • Role-Based Access Control (RBAC): Using Spatie Laravel Permission
  • Route-Based Permissions: Individual permissions for each admin route (automatically discovered)
  • User Authorization: Users can only access their own orders and data
  • CSRF Protection: Built-in Laravel security features
  • Input Validation: Comprehensive form validation and sanitization
  • XSS Protection: All user inputs are properly escaped

📊 Technical Features

  • Eloquent ORM: Clean, expressive database interactions
  • Database Migrations: Version-controlled database schema
  • Model Factories: Automated test data generation
  • Pagination: Efficient data loading with Bootstrap 5 pagination
  • Server-Side Processing: DataTables with AJAX for large datasets
  • API Ready: RESTful API endpoints for mobile app integration
  • Session Management: Secure cart and user session handling
  • Referral System: Shareable /r/{code} links; awards referrer on successful signup
  • Rich Text Editor: Quill editor for product descriptions and page content
  • Live Search: AJAX-powered real-time product search with debouncing

🚀 Why Use This eCommerce System?

For Developers

  • Clean Architecture: Follows Laravel best practices and MVC pattern
  • Extensible: Easy to add new features and customize functionality
  • Well Documented: Comprehensive code comments and structure
  • Modern Stack: Built with latest Laravel 12 and PHP 8.3+
  • Security First: Implements industry-standard security practices
  • Performance Optimized: Server-side processing, eager loading, efficient queries

For Business Owners

  • Complete Solution: Everything needed to start selling online
  • Professional Design: Modern, responsive interface that builds trust
  • Easy Management: Intuitive admin panel for non-technical users
  • Customer Engagement: Reviews, ratings, newsletter, and loyalty points
  • Scalable: Built to handle growth from startup to enterprise
  • Cost Effective: Open source solution with no licensing fees

For Customers

  • Fast Performance: Optimized for speed and user experience
  • Mobile Friendly: Perfect shopping experience on all devices
  • Secure Checkout: Safe and reliable payment processing
  • Order Tracking: Complete visibility into order status and history
  • Product Reviews: Read and write reviews to make informed decisions
  • Live Search: Quick product discovery with instant results

📋 Requirements

  • PHP: 8.3 or higher
  • Composer: Latest version
  • Database: MySQL, PostgreSQL, or SQLite
  • Web Server: Apache, Nginx, or Laravel Valet
  • Node.js: For asset compilation (optional)

🛠️ Installation

1. Clone the Repository

git clone https://github.com/needyamin/eCommerceLaravel
cd eCommerceLaravel

2. Install Dependencies

composer install
npm install

3. Environment Setup

cp .env.example .env
php artisan key:generate

4. Database Configuration

Update your .env file with database credentials:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ecommerce_laravel
DB_USERNAME=your_username
DB_PASSWORD=your_password

5. Run Migrations and Seeders

php artisan migrate --seed

This will:

  • Create admin and test user accounts
  • Set up roles and permissions (automatically discovers all admin routes)
  • Seed categories, products, currencies, coupons
  • Configure default site settings (reviews, newsletter, etc.)
  • Create default customer service pages (Help Center, Shipping Info, Returns, Contact Us)

Optional seeders (recommended for admin RBAC and payments):

php artisan db:seed --class=Database\Seeders\AdminRoutePermissionsSeeder
php artisan db:seed --class=Database\Seeders\PaymentGatewaySettingsSeeder
php artisan db:seed --class=Database\Seeders\PageSeeder

5.1 Feature Migrations (Coins, Referral, Shipping, Reviews, Pages)

If you're upgrading an existing install, run these specific migrations:

php artisan migrate --path=database/migrations/2025_10_24_130000_add_coins_to_users_and_create_user_points_table.php
php artisan migrate --path=database/migrations/2025_10_24_131000_create_coin_settings_table.php
php artisan migrate --path=database/migrations/2025_10_24_132000_add_referral_fields_to_users_table.php
php artisan migrate --path=database/migrations/2025_10_24_133000_add_flags_to_coin_settings_table.php
php artisan migrate --path=database/migrations/2025_10_24_134000_create_shipping_settings_table.php
php artisan migrate --path=database/migrations/2025_10_24_134500_add_global_rate_to_shipping_settings_table.php
php artisan migrate --path=database/migrations/2025_11_07_022231_create_product_reviews_table.php
php artisan migrate --path=database/migrations/2025_11_07_022251_add_review_settings_to_site_settings_table.php
php artisan migrate --path=database/migrations/2025_11_07_023046_add_newsletter_settings_to_site_settings_table.php
php artisan migrate --path=database/migrations/2025_11_07_024826_add_customer_service_links_to_site_settings_table.php
php artisan migrate --path=database/migrations/2025_11_07_025029_create_pages_table.php

After migrating, visit Admin → Site Settings, Admin → Coin Settings, and Admin → Shipping Settings to configure.

6. Compile Assets (Optional)

npm run dev
# or for production
npm run build

7. Start the Server

php artisan serve

Visit http://localhost:8000 to see your eCommerce store!

👤 Default Accounts

Admin Account

Test User Account

📁 Project Structure

├── app/
│   ├── Http/Controllers/
│   │   ├── Admin/           # Admin panel controllers
│   │   │   ├── DataTableController.php  # Server-side DataTables handler
│   │   │   ├── PageController.php       # Pages CRUD
│   │   │   ├── ReviewController.php     # Reviews management
│   │   │   └── ...                     # Other admin controllers
│   │   ├── Api/             # API controllers
│   │   ├── ProductController.php        # Frontend products (includes search)
│   │   ├── ReviewController.php          # Frontend reviews
│   │   ├── PageController.php            # Frontend pages
│   │   └── NewsletterController.php     # Newsletter subscription
│   ├── Models/              # Eloquent models
│   │   ├── ProductReview.php            # Product reviews model
│   │   ├── Page.php                     # Pages model
│   │   └── ...
│   └── Providers/           # Service providers
├── database/
│   ├── migrations/          # Database schema
│   │   ├── create_product_reviews_table.php
│   │   ├── create_pages_table.php
│   │   ├── add_review_settings_to_site_settings_table.php
│   │   ├── add_newsletter_settings_to_site_settings_table.php
│   │   └── add_customer_service_links_to_site_settings_table.php
│   ├── seeders/             # Sample data
│   │   ├── PageSeeder.php               # Default pages seeder
│   │   └── ...
│   └── factories/           # Model factories
├── resources/
│   ├── views/
│   │   ├── admin/           # Admin panel views
│   │   │   ├── pages/                  # Pages CRUD views
│   │   │   ├── reviews/                # Reviews management views
│   │   │   └── ...
│   │   ├── pages/           # Frontend page views
│   │   ├── layouts/         # Layout templates
│   │   ├── partials/        # Partial views
│   │   │   └── nav.blade.php           # Navigation with live search
│   │   └── ...             # Frontend views
│   └── css/                # Stylesheets
├── routes/
│   ├── web.php             # Web routes
│   └── api.php             # API routes
└── public/
    └── admin-assets/       # Admin theme assets

🔧 Configuration

Admin Panel Customization

The admin panel uses AdminLTE theme. Customize the appearance by modifying:

  • resources/views/admin/layouts/app.blade.php
  • resources/views/admin/partials/sidebar.blade.php
  • public/admin-assets/css/adminlte.css

Permission System

  • Admin routes are protected by route‑name permissions (e.g., admin.products.edit).
  • Use Admin → Role & Permission to assign both named and route‑based permissions.
  • Route permissions are automatically discovered and created by AdminRoutePermissionsSeeder.
  • Seed all current admin route permissions and grant to Super Admin:
php artisan db:seed --class=Database\Seeders\AdminRoutePermissionsSeeder

Site Settings

Configure all site-wide settings from Admin → Site Settings:

  • Basic Information: Site name, tagline, logo, favicon
  • SEO: Meta title, description, keywords
  • Legal & Footer: Footer text, privacy/terms/cookies URLs, customer service links
  • Social Media: Facebook, Twitter, Instagram, LinkedIn links
  • Feature Toggles: Enable/disable wishlist, reviews, newsletter
  • Review Settings: Control review requirements (purchase, approval, anonymous)
  • Newsletter Settings: Configure double opt-in and welcome emails

Pages Management

Create and manage custom pages from Admin → Pages:

  • Use rich text editor (Quill) for content
  • Set SEO meta tags per page
  • Control visibility with active/inactive status
  • Sort pages with sort order
  • Default pages: Help Center, Shipping Info, Returns, Contact Us

Reviews System

  • Frontend: Customers can leave reviews on product pages (if enabled)
  • Settings: Control via Admin → Site Settings → Review Settings
  • Management: Approve/reject/delete reviews from Admin → Reviews
  • Features: Star ratings (1-5), verified purchase badges, admin moderation

Email Configuration

You can configure SMTP at runtime from Admin → Email Settings (no .env edit required). For local setup via .env, use:

MAIL_MAILER=smtp
MAIL_HOST=your-smtp-host
MAIL_PORT=587
MAIL_USERNAME=your-email
MAIL_PASSWORD=your-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="Your Store"

Coins Configuration

  • Admin → Coin Settings: toggle coins system on/off and configure awards
  • Profile shows coin balance; admin user page allows Adjust and Reset

Shipping Configuration

  • Admin → Shipping Settings: enable shipping, set free shipping minimum, define per‑country/city rates, and a global fallback rate
  • Checkout totals include dynamic shipping and currency formatting

Payment Gateways

  • Stripe: Configure API keys, enable/disable, test connection
  • PayPal: Configure client ID/secret, enable/disable, sandbox mode
  • Cash on Delivery (COD): Enable/disable from Admin → Payment Gateways → COD
  • All payment methods are configurable from Admin → Payment Gateways

📚 API Documentation

The system includes RESTful API endpoints for mobile app integration:

Authentication

  • POST /api/register - User registration
  • POST /api/login - User login
  • POST /api/logout - User logout

Products & Categories

  • GET /api/categories - List categories
  • GET /api/products - List products
  • GET /api/products/{id} - Get product details
  • GET /products/search?q={query} - Live search (returns JSON, requires 3+ characters)

Cart & Orders

  • GET /api/cart - Get user cart
  • POST /api/cart/add - Add item to cart
  • GET /api/orders - List user orders
  • GET /api/orders/{id} - Get order details

Reviews

  • POST /products/{product}/reviews - Submit a product review (authenticated)
  • DELETE /reviews/{review} - Delete own review (authenticated)

Pages

  • GET /page/{slug} - View a custom page

Newsletter

  • POST /newsletter/subscribe - Subscribe to newsletter
  • POST /newsletter/unsubscribe - Unsubscribe from newsletter
  • GET /newsletter/confirm/{token} - Confirm subscription (double opt-in)

OTP

  • Email & SMS OTP request/verify endpoints (UI available under /otp/email and /otp/sms)

🧪 Testing

Run the test suite:

php artisan test

Note: If using SQLite for tests, ensure pdo_sqlite is installed; or configure tests to use MySQL by setting DB_CONNECTION=mysql for the testing environment.

Generate test data:

php artisan db:seed --class=DatabaseSeeder

🚀 Deployment

Production Deployment

  1. Set APP_ENV=production in .env
  2. Run php artisan config:cache
  3. Run php artisan route:cache
  4. Run php artisan view:cache
  5. Set up proper web server configuration
  6. Configure SSL certificate
  7. Set up database backups

🐳 Docker Deployment

Quick Start with Docker

  1. Copy environment file:

    cp .env.docker.example .env
  2. Update .env file with your configuration

  3. Build and start containers:

    docker-compose up -d --build
  4. Install dependencies and setup:

    docker-compose exec app composer install
    docker-compose exec app php artisan key:generate
    docker-compose exec app php artisan migrate --seed
    docker-compose exec app php artisan storage:link
  5. Access the application:

Production Deployment with Docker

For production deployment, use the production override:

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build

See DOCKER.md for detailed Docker setup instructions, SSL configuration, backup strategies, and troubleshooting.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

For support, email [email protected] or create an issue on GitHub.


Built with ❤️ using Laravel 12

About

A comprehensive, modern eCommerce platform built with Laravel 12, featuring a beautiful storefront and powerful admin panel with role-based access control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published