This project is a simple Laravel task API that allows users to create, retrieve, update, and delete tasks. The API is built using Laravel and SQlite for data storage.
- PHP
- Laravel Framework
- Composer
-
Clone the repository and navigate to the project root directory:
git clone https://github.com/InventorsDev/Laravel_SDG_2023_Beginners_Challenge.git
-
Install dependencies using Composer:
composer install
-
Set up the environment:
Navigate to database folder create a file named challengedb.sqlite Copy the .env.example file and rename it to .env. Configure the necessary environment variables in the .env file. Set the following: DB_CONNECTION=sqlite DB_HOST=127.0.0.1 DB_PORT=3306
You have been provided with the apiResource endpoints for basic CRUD and also the unit test which can be found in your_project_directory\tests\Feature\TaskControllerTest.php
.
Your work is to perform the following:
- Create a TaskController then ensure to link it to your api.php file to work well
- Create all the functions needed by for the test to run perfectly
- Run your test and ensure it works perfectly
- Use a tool such as Postman or Insomnia to test the API endpoints.
Complete the two question in the controller/Api/AlgorithmController. The getMaxSum and uniqueChars function
Write a function called getMaxSum that takes an array of integers as input and returns the maximum sum of any contiguous subarray of the given array. If the array is empty or contains only negative integers, the function should return 0. The getMaxSum function takes an array of integers as input and returns the maximum sum of any contiguous subarray of the given array. If the array is empty or contains only negative integers, the function should return 0.
Input
`getMaxSum([1, -3, 2, 1, -1]);`
Output
`3`
Complete the uniqueChars that takes a string as input and returns a new string containing only the unique characters in the input string, in the order that they first appear. If the input string is empty or contains only whitespaces, the function should return an empty string.
// For example, if the input string is "hello world", the function should return "helo wrd".
Input
`uniqueChars("hello world");`
Output
"helo wrd"
Input
`uniqueChars("");`
Output
""
Run php artisan test
A successful test should look like this in your Vs code terminal