Test Laravel Eloquent Basics

screenshot of Test Laravel Eloquent Basics

Overview

If you're looking to sharpen your Laravel Eloquent skills, this repository presents a practical and challenging exercise. It's an engaging way to validate your knowledge and troubleshoot your code writing abilities through a series of tasks focused on solving common scenarios that developers encounter. This hands-on approach not only tests your understanding of Eloquent but also allows you to debug and enhance your problem-solving skills in a structured manner.

The primary goal is to fix intentionally failing PHPUnit tests found in the tests/Feature/EloquentTest.php file. You will confront various tasks that range from creating models and retrieving data to updating and deleting records—each designed to bolster your competence with Laravel's Eloquent ORM.

Features

  • Model with Different Table Name: Adjust your model to work with a custom table named "morning_news," aligning it with the relevant migration.

  • Get Data List: Implement an Eloquent query to retrieve the three newest users who have verified emails, ensuring they are sorted from newest to oldest.

  • Get a Single Record: Enhance the user retrieval functionality to either fetch a user based on ID or display a Laravel 404 error page if not found.

  • Get a Single Record or Create a New Record: Add logic to check if a user exists by name and email; if not, create a new user with a randomized password.

  • Create a New Record: Troubleshoot and resolve issues that prevent successful project creation in the specified controller method.

  • Mass Update: Convert an SQL update statement into an Eloquent query to streamline project updates.

  • Update or New Record: Develop logic to either update an existing user by name or create a new record if one doesn’t exist, incorporating email and password generation.

  • Mass Delete Users: Implement functionality to delete multiple users based on a provided list in the request, ensuring bulk operations are handled efficiently.

postcss
Postcss

PostCSS is a popular open-source tool that enables web developers to transform CSS styles with JavaScript plugins. It allows for efficient processing of CSS styles, from applying vendor prefixes to improving browser compatibility, ultimately resulting in cleaner, faster, and more maintainable code.