0% found this document useful (0 votes)
3 views

Coding Test

The document outlines a coding test that requires the creation of a Laravel project with specific tasks. Tasks include implementing custom middleware for logging IP addresses, handling file uploads, explaining the Laravel service container, and defining Eloquent models with relationships, migrations, and CRUD functionalities. The completed project must be submitted via GitHub with separate repositories for Task 4 and the remaining tasks.

Uploaded by

ligojit600
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Coding Test

The document outlines a coding test that requires the creation of a Laravel project with specific tasks. Tasks include implementing custom middleware for logging IP addresses, handling file uploads, explaining the Laravel service container, and defining Eloquent models with relationships, migrations, and CRUD functionalities. The completed project must be submitted via GitHub with separate repositories for Task 4 and the remaining tasks.

Uploaded by

ligojit600
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Coding Test

Note:
 The completed project should be submitted by pushing the code to your own GitHub
and provide the link.
 Task 4 should have a separate repository and all remaining tasks should be done in a
single separate repository.

Task 1:

Create a custom middleware in Laravel that logs the IP address of incoming requests.
Apply this middleware to a route and demonstrate its functionality.

Task 2:

Write a Laravel route that handles file uploads. Allow users to upload a single file and
save it to a specified directory on the server.

Task 3:

Explain how the Laravel service container works and provide an example of how you
might bind a class to the service container and resolve it using dependency injection.

Task 4:

1. Define the following Eloquent models with the specified relationships:


 User model with a one-to-many relationship with the Post model (a user has many
posts).
 Post model with a one-to-many relationship with the Comment model (a post has
many comments).
 Comment model with a belongs-to relationship with both the User model (a
comment belongs to a user) and the Post model (a comment belongs to a post).
2. Create the necessary migration files for these models, including foreign key constraints.
3. Seed the database with some sample data for users, posts, and comments.
4. Implement the following functionality:
 A route to display all users along with their posts and comments (use eager
loading).
 A route to display a specific user's posts along with the comments on each post (use
lazy loading).
5. Create a form to add a new post for a specific user. Use dropdown menus to select the
user and enter the post details.
6. Ensure that the form validates the input data (e.g., the post title and content are
required).
7. Implement the logic to store the new post in the database and display a success
message upon successful submission.

Your solution should demonstrate your understanding of Laravel relationships,


migrations, seeding, validation, and basic CRUD operations. Use best practices and
follow Laravel conventions where applicable.

You might also like