Skip to content

xteam-uz/lara-klean

Repository files navigation

Lara Klean

Lara Klean is a clean and modular Laravel 12 application that demonstrates best practices with authentication, blog posts, comments, policies, services, notifications, and localization support.


Table of Contents


Features

  • Authentication (register, login, logout, password reset)
  • Blog posts CRUD
  • Comments on posts with policy-based access
  • Service layer for clean business logic separation
  • Event-driven notifications on post creation
  • Factory & Seeder support for easy demo data
  • Localization (Uzbek and English by default)
  • Policies & middleware for secure authorization

Requirements

  • PHP 8.1+
  • Composer
  • MySQL/MariaDB (or another supported database)
  • Node.js & npm (or Yarn)
  • Laravel 10.x

Installation

Clone the repository and install dependencies:

git clone https://github.com/xteam-uz/lara-klean.git
cd lara-klean

# Install PHP dependencies
composer install

# Install JS dependencies
npm install && npm run build

Environment Setup

Copy the example environment file and generate the application key:

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

Update .env with your database and mail credentials:

Key Description
APP_URL Base URL of the application
DB_CONNECTION / DB_HOST / DB_DATABASE / DB_USERNAME / DB_PASSWORD Database settings
MAIL_* Mail settings for notifications/password reset

Database & Seeding

Run migrations and seeders:

php artisan migrate --seed

This will create users, posts, comments and other initial data using the included factories and seeders.

Project Structure

app/
├── Events/                # PostCreated event
├── Http/
│   ├── Controllers/       # Auth, Post, Comment controllers
│   ├── Middleware/
│   └── Requests/          # Form requests for validation
├── Listeners/             # SendPostNotification listener
├── Models/                # User, Post, Comment models
├── Notifications/         # Laravel notifications
├── Policies/              # PostPolicy, CommentPolicy
└── Services/              # AuthService, PostService, CommentService

database/
├── factories/             # Model factories
├── migrations/            # Migrations
└── seeders/               # Database seeders

resources/
├── lang/                  # Localization files (uz, en)
├── views/                 # Blade templates
└── js & css               # Frontend assets

routes/
├── web.php                # Web routes
└── api.php                # API routes (if any)

Routes & Controllers

The application provides web routes for:

  • Auth – login, registration, logout

  • Posts – index, create, store, edit, update, destroy

  • Comments – store, delete, update

Controllers handle these routes using dedicated service classes for the business logic.

Events & Listeners

The project uses Laravel’s event/listener system:

  • PostCreated event is fired after a new post is created.

  • SendPostNotification listener sends notifications to users.

This approach keeps controllers thin and easier to test.

Policies & Authorization

Policies under app/Policies manage access control:

  • PostPolicy controls who can create/edit/delete posts.

  • CommentPolicy controls who can add/edit/delete comments.

Apply policies in controllers or via middleware for fine-grained permissions.

Localization

The app supports multiple languages. Localization files are located in:

resources/lang/en/
resources/lang/uz/
resources/lang/ru/

Use the __() helper in Blade templates and controllers to render translated strings.

Contributing

Contributions are welcome:

  1. Fork the repository.

  2. Create a feature branch: git checkout -b feature/your-feature.

  3. Commit your changes and push: git push origin feature/your-feature.

  4. Create a Pull Request.

License

This project is open-source and available under the MIT License

About

Laravel-based website for a cleaning service company with service pages, orders, and blog features.

Topics

Resources

License

Stars

Watchers

Forks

Contributors