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.
git clone [email protected]:tvarga94/ominimo-laravel-blog.git
cd ominimo-laravel-blog
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
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
)
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.
- 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
📂 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)
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:
[email protected]
password
You can now access the application at http://127.0.0.1:8000
.