A RESTful API built with Laravel to manage user authentication, profiles, posts, likes, and comments. This project demonstrates common features like CRUD operations, user authentication, and relational database design.
- Authentication:
- Register, Login, Logout
- User Profile:
- Update, Delete
- Posts:
- Create, Update, Delete
- Like/Unlike a post
- Comment on posts
id BIGINT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL UNIQUE,
password VARCHAR(50) NOT NULL,
profile_pic VARCHAR(50) NOT NULL,
bio TEXT NULLABLEid BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT FOREIGN KEY REFERENCES User(id),
caption TEXT NOT NULL,
image VARCHAR NULLABLEid BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT FOREIGN KEY REFERENCES User(id),
post_id BIGINT FOREIGN KEY REFERENCES Post(id)id BIGINT PRIMARY KEY AUTO_INCREMENT,
user_id BIGINT FOREIGN KEY REFERENCES User(id),
post_id BIGINT FOREIGN KEY REFERENCES Post(id),
text TEXT NOT NULLGenerate the necessary migrations for the User, Post, Like, and Comment tables:
php artisan make:migration create_users_table
php artisan make:migration create_posts_table
php artisan make:migration create_likes_table
php artisan make:migration create_comments_tableDefine models for the application:
php artisan make:model User
php artisan make:model Post
php artisan make:model Like
php artisan make:model CommentGenerate factories for testing with fake data:
php artisan make:factory UserFactory
php artisan make:factory PostFactory
php artisan make:factory LikeFactory
php artisan make:factory CommentFactoryInstall Laravel Passport for handling API authentication:
composer require laravel/passport
php artisan passport:install-
User Authentication:
php artisan make:controller AuthController
-
Post CRUD:
php artisan make:controller PostController
-
Like Operations:
php artisan make:controller LikeController
-
Comment Operations:
php artisan make:controller CommentController
- Register:
POST /api/register - Login:
POST /api/login - Logout:
POST /api/logout - Profile:
- View Profile:
GET /api/user - Update Profile:
PUT /api/user - Delete Profile:
DELETE /api/user
- View Profile:
- Get All Posts:
GET /api/posts - Create Post:
POST /api/posts - Update Post:
PUT /api/posts/{id} - Delete Post:
DELETE /api/posts/{id} - Like Post:
POST /api/posts/{id}/like - Comment on Post:
POST /api/posts/{id}/comment
- Like a Post:
POST /api/posts/{post_id}/like - Unlike a Post:
DELETE /api/posts/{post_id}/like
- Add Comment:
POST /api/posts/{post_id}/comment - Delete Comment:
DELETE /api/posts/{post_id}/comment/{comment_id}
-
Clone the repository:
git clone https://github.com/Smey09/Laravel-project-api.git cd laravel-project-api -
Install dependencies:
composer install
-
Set up your
.envfile and configure the database connection:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT
-
Run migrations:
php artisan migrate
-
Serve the application:
php artisan serve
You can explore the front-end built with Flutter by visiting the GitHub repository or cloning the project using the following commands:
-
View on GitHub: front-end-app-flutter
-
Clone the repository:
git clone https://github.com/Smey09/front-end-app-flutter.git
This project is open-source and licensed under the MIT License.