prasetiyo28 / laravel-blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blogs

This README provides instructions for setting up and running the Laravel 10 project with user authentication and different roles (admin and user).

Requirements

Before running the project, ensure your development environment meets the following requirements:

  • PHP >= 7.4
  • Composer
  • Node.js >= 14.x
  • npm or Yarn
  • Apache or Nginx web server
  • MySQL or PostgreSQL database

Installation

Follow these steps to set up the Laravel project:

  1. Clone the Repository

    git clone https://github.com/prasetiyo28/laravel-blog.git
    cd laravel-blog
  2. Install Composer Dependencies

 git clone composer install
  1. Install npm Dependencies
   npm install
  1. Create a Copy of the .env File
  cp .env.example .env
  1. Generate Application Key
   php artisan key:generate   
  1. Set Up Database
  • Create a new database for your project.
  • Update .env file with database credentials:
   DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password   
  • Run database migrations to create tables:
  1. Set Up Database
  • If you want to seed the database with dummy data (e.g., admin and user roles):
  php artisan db:seed 

Usage

  • Development Server Start the Laravel development server:
php artisan serve
npm run dev

Access the application in your web browser at http://localhost:8000.

Test

php artisan test

Features

Authentication and Authorization

  • Roles: There are two types of users: admin and user.
  • Admin Privileges:
    • Create, read, update, and delete posts. Manage users (optional).
  • User Privileges:
    • Read posts.
    • Comment on posts.

Routes

  • /login: Login page for users.
  • /register: Registration page for new -users.
  • /posts: List of posts visible to users.
  • /posts/{id}: View a specific post.
  • /posts/create (Admin): Create a new post.
  • /posts/{id}/edit (Admin): Edit an existing post.
  • /posts/{id}/delete (Admin): Delete a post.

Additional Features

  • Comments: Users can comment on posts.
  • Pagination: Paginate posts for better navigation.
  • Middleware: Use middleware to manage access control based on user roles.

API

  • postman collection link

About


Languages

Language:PHP 77.2%Language:Blade 18.9%Language:CSS 1.8%Language:JavaScript 1.5%Language:Vue 0.4%Language:SCSS 0.2%