In this project, you will build a Contact Management System using Laravel. The application will allow users to manage their contacts, store them in a database, and upload profile pictures.
Lesson Outline
- Setting Up the Environment
- Designing the Database
- Implementing CRUD for Contacts
- Handling File Uploads for Profile Pictures
- Styling and Validating the Application
- Enhancing Features and Best Practices
Step 1: Setting Up the Environment
1.1 Install Laravel
Follow the steps from Lesson 19 to install Laravel:
- Install Laravel using Composer:
- Navigate to the project directory:
1.2 Configure the Database
- Create a MySQL database named
contacts
. - Update the
.env
file with your database credentials: - Run the migration command to ensure Laravel’s default migrations are applied:
Step 2: Designing the Database
2.1 Create a Contacts Table
- Generate a migration file:
- Open the migration file in
database/migrations/
and define the schema: - Run the migration:
2.2 Create a Contact Model
Generate a model for contacts:
Step 3: Implementing CRUD for Contacts
3.1 Generate a Resource Controller
Run the command to create a controller for managing contacts:
3.2 Define Routes
Edit the routes/web.php
file to include routes for the ContactController
:
3.3 Add Methods in ContactController
Index: List All Contacts
Create: Show Form to Add Contact
Store: Save a New Contact
Edit: Show Form to Edit Contact
Update: Update a Contact
Destroy: Delete a Contact
Step 4: Handling File Uploads for Profile Pictures
4.1 Modify Store and Update Methods
Update the store
and update
methods in the ContactController
to handle file uploads.
Store with Profile Picture Upload
Update with Profile Picture Upload
4.2 Display Profile Pictures
Update the index and show views to display profile pictures.
Display in Index View
Step 5: Styling and Validating the Application
- Use Bootstrap or Tailwind CSS for styling forms and tables.
- Add Validation Feedback:
- Display error messages using
$errors
in views.
- Display error messages using
Activities and Exercises
- Enhance the Contact Manager:
- Add a “Notes” field to contacts.
- Implement search functionality.
- Pagination:
- Add pagination to the contacts list.
- Advanced Features:
- Allow users to bulk upload contacts from a CSV file.
Assignment
- Extend the Contact Management System to:
- Allow users to group contacts into categories.
- Generate a downloadable report (PDF) of all contacts.
- Test the application thoroughly:
- Write validation test cases for adding and updating contacts.
- Ensure file upload limits are enforced.
Summary
In this project, you:
- Built a Contact Management System with Laravel.
- Implemented CRUD operations for managing contacts.
- Handled file uploads for profile pictures.
- Enhanced the application with validation and file storage.
This project showcases Laravel’s capabilities in building a feature-rich application. Let me know if you’d like further guidance or additional features!
Leave a Reply