Skip to content

tvarga94/ominimo-laravel-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Logo

Build Status Total Downloads Latest Stable Version License

Ominimo Test Task - Laravel Blog

Requirements

PHP 8.2+
Node 18+
NPM 9+

This is a Laravel-based blog project designed as a test task for Ominimo. The application includes user authentication, blog post management, comments, and role-based access control (RBAC) with an admin role.

Getting Started

1️⃣ Clone the Repository

git clone [email protected]:tvarga94/ominimo-laravel-blog.git
cd ominimo-laravel-blog

2️⃣ Create the .env File

Copy the .env.example file and update the database credentials.

cp .env.example .env

Modify the database credentials in .env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_user
DB_PASSWORD=your_database_password

3️⃣ Make the Setup Script Executable

Make sure the setup script is executable and then run it.

chmod +x setup.sh
./setup.sh

Now create the database with:

php artisan migrate

And run the seeder files:

php artisan db:seed

The script will:

  • Install dependencies (composer install)
  • Run database migrations with seeders (php artisan migrate --seed)
  • Start the local development server (php artisan serve)

4️⃣ Running Tests

To run unit and feature tests, execute:

php artisan test

!!!IMPORTANT!!! Since we don't have different database for testing, before we run the tests we purge the database. So after we are finished with the test run we need to rerun the seeder files so we will have the orginal seeder data.


Features

  • User Authentication (Laravel Breeze-based login/register)
  • Blog Posts (Create, read, update, delete)
  • Comments (Users can comment on posts)
  • Role-Based Access Control (Admin can manage everything, users can only edit their content)
  • Repository Pattern for clean and scalable code
  • Authorization Policies to restrict access to post and comment actions
  • Unit Tests for core functionalities

Project Structure

📂 app
 ├── Http
 │   ├── Controllers (All controllers)
 │   ├── Requests (Validation requests)
 │   ├── Repositories (Repository pattern implementation)
 │   ├── Middleware (Custom middleware)
 │
 ├── Models (Eloquent models)

📂 database
 ├── factories (Model factories for seeders)
 ├── migrations (Database schema definitions)
 ├── seeders (Database seeders for users, posts, and comments)

📂 resources/views
 ├── posts (All post-related views)
 ├── comments (Comment section views)

📂 tests
 ├── Unit (Unit tests for repositories)

Useful Commands

Command Description
php artisan migrate Run database migrations
php artisan migrate:rollback Rollback last migration
php artisan db:seed Seed the database with test data
php artisan route:list Show all available routes
php artisan test Run all tests
php artisan serve Start Laravel's local development server

Every user generated by the seeders have the password 'password' added to them. Admin credentials:

You can now access the application at http://127.0.0.1:8000.


About

Laravel Blog Application for Ominimo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages