This is Service to handle Restaurant Menu Management Functionallity, This service made with Laravel 12
This service is using Laravel 12 base on PHP as Rest API and MySQL as Database
- Request : Focus on handle validation for every module/table
- Resource : Focus on Formatting Output
- Controller : Focus in Input Validation and Output
- Service : Focus on logical process
- Repository : Focus on integration with Model, like custom query, custom logical in model. something that related into database will focus in repository
-
Table name have some format :
- m_{table_name} for Master Table
- mt_{table_name} for Master Transaction Table
- trx_{table_name} for Transaction Table
-
But for this case, just showing mt_{table_name} and m_{table_name} to simplify the scope
- Menu list still not grouped by category because there is not requested. But its possible and better if grouped by category. Right now to just make it simple to speed up development
- Category is separated from menu table. Its because I think it will more controlled if its separated. Because it can reused for all menu in 1 restaurant. Category also have relation with Restaurant Table because i think all Restaurant have their own category of menu.
- This service use Soft Delete to handle if we still need data as a statistic or something like historical or make some submission offering to that restaurant in the future
- Before installation is required to install this :
- Composer
- MySQL
- Duplicate .env.example and make adjustments in several parts especially database connections
DB_CONNECTION=mysql
DB_HOST={your_host}
DB_PORT={yout_port}
DB_DATABASE={your_db_name}
DB_USERNAME={your_db_username}
DB_PASSWORD={your_db_password}- After that, please run :
composer install- After that, please run :
php artisan migrate --seed- After that, to make simple auth, we will use static API KEY, please run:
php artisan app:generate-api-keyit will generate static api key and add into .env
You can run this service with this command
php artisan servedefault port is 8000 If you need to custom the port you can add --port={your_port}
php artisan serve --port=8001- Before Doing a Test, please check or make adjustments in phpunit.xml to change DB_CONNECTION value into mysql, because this service using fulltext index that support in mySQL and not in SQLite, and make sure already make DB with name 'restaurant_management_test'
- After make sure the phpunit.xml, please run:
php artisan test- That command will show some test and the result (passed / failed)
http://localhost:8000/api/restaurants?order=name // to sort by name asc
http://localhost:8000/api/restaurants?order=-name // to sort by name descand just some column will allowed used as a sort column (whitelist)
- please follow instruction in readme.md for how to make x-api-key, and copy paste the x-api-key into header in the request create, update, or delete
- endpoint for get detail or get all still public endpoint
- page
- limit
- sort
- keyword (for restaurant)
- category (for menu)
- example
http://localhost:8000/api/restaurants?keyword=pizza&page=1&limit=10&order=name
http://localhost:8000/api/restaurants/1/menu_items?category=dessert&page=1&limit=10&order=-name