Skip to content

developermithu/api-blog-laravel

Repository files navigation

Blog Backend API

A Laravel-based RESTful API for managing blog posts and categories.

Features

  • Authentication with Laravel Sanctum
  • Post management (CRUD operations)
  • Category management
  • Role-based access control (Admin/User)
  • Soft deletes for posts
  • Media uploads for post images

Frontend Repository

Installation Steps

  1. Clone the repository:
git clone https://github.com/developermithu/api-blog-laravel.git
  1. Change directory:
cd api-blog-laravel
  1. Install dependencies:
composer install
  1. Copy the .env.example file to .env:
cp .env.example .env
  1. Generate the application key:
php artisan key:generate
  1. Update the database configuration in the .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=api-blog-laravel
DB_USERNAME=root
DB_PASSWORD=
  1. Migrate and seed the database:
php artisan migrate:fresh --seed
  1. Start the development server:
php artisan serve 
  1. Open the application in your web browser at http://localhost:8000.

API Documentation

Authentication

Register

POST /api/register
Parameter Type Description
name string Required. User's name
email string Required. User's email
password string Required. User's password

Login

POST /api/login
Parameter Type Description
email string Required. User's email
password string Required. User's password

Posts

Get All Posts

GET /api/posts

Get Single Post

GET /api/posts/{id}

Create Post (Admin Only)

POST /api/posts
Parameter Type Description
title string Required. Post title
slug string Required. Post slug
content string Required. Post content
category_id integer Required. Category ID
status string Required. Post status (draft/published)
cover image file Optional. Post image

Update Post (Admin Only)

PUT /api/posts/{slug}

Delete Post (Admin Only)

DELETE /api/posts/{slug}

Categories

Get All Categories

GET /api/categories

Get Single Category

GET /api/categories/{id}

Create Category (Admin Only)

POST /api/categories
Parameter Type Description
name string Required. Category name
slug string Required. Category slug

Update Category (Admin Only)

PUT /api/categories/{id}

Delete Category (Admin Only)

DELETE /api/categories/{id}

Authentication

All admin-only endpoints require authentication using a Bearer token. Include the token in the Authorization header:

Authorization: Bearer <your_token>

About

Blog backend - Laravel 12, Inertia v2, React 19

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy