This repository contains a simple CRUD (Create, Read, Update, Delete) application built using Laravel. The application manages tasks with just one field: "task_name."
-
Clone the repository to your local machine:
git clone [Repo URL](https://github.com/hassanshahzadaheer/crud.git) cd crud-app
-
Install project dependencies:
composer install
-
Create a new database for the application and update the database connection information in the
.env
file. -
Run database migrations to create the necessary table:
php artisan migrate
-
Seed the database with sample data for testing and development purposes:
php artisan db:seed
-
Routes: The application defines routes in
routes/web.php
for performing CRUD operations on tasks. -
Controllers: The
Tasks
controller handles all CRUD operations for tasks. It is located in theapp/Http/Controllers
directory. -
Models: The
Task
model represents the "tasks" table in the database. It is located in theapp/Models
directory. -
Views: The Blade views for the application are in the
resources/views/tasks
directory. The views allow users to create, view, edit, and delete tasks.
Start the development server to run the application:
php artisan serve
Visit http://localhost:8000
in your browser to see the list of tasks. From there, you can add new tasks, view task details, edit existing tasks, and delete tasks.
We have recently added AJAX-based functionality to improve user experience for viewing and editing tasks:
- When you click the "View" button next to a task in the list, a modal will open showing the task details, including the task ID and task name.
- When you click the "Edit" button next to a task in the list, a modal will open with an edit form.
- The form will display the current task name, and you can edit it.
- Upon clicking the "Save" button in the modal, an AJAX request will be sent to update the task name without refreshing the page.
The repository includes some basic test cases for the TaskController
. To run the tests, use the following command:
php artisan test
The application utilizes Laravel's model factories and database seeding to populate the database with sample data. The TaskFactory
generates random task names for seeding.
For more information on how to modify or extend the application, refer to the code and comments in the respective files.