Skip to content

Tag: laravel

Import CSV data using Laravel

I’m trying to walk through as CSV file and extract all its contents. After the contents are imported I need to insert them into my mysql database table but before I can do that I need to check if these records exist. If a record does not, import this register. I’ve got headers and all content and …

I can’t add a column to a table with data in laravel

I’m doing this: create: Code: The migration runs without problems, but I am going to check the table and the column is not added, if I create a new migration and put a total to the new column, it says that the column already exists, what error is occurring? Answer go to the database table and delete the…

Laravel Resource controller

How do I tell my API to display a particular result based on another column? e.g. localhost:8000/api/gadgets/{{id}} Normally it returns the particular information of the specific gadget with that ID and localhost:8000/api/gadgets/{{imei_code}} does not return any value or an error whereas imei_code is a colum…

Laravel validate() method returns index html page when false

I’m building my first laravel API and when I try to validate some mock form data using Postman with POST method, the application returns to me the HTML of the index page and status 200. Here is my code The application returns the object that was inserted in the database if the validation was successful …

Relationship eloquent in laravel?

In user: In post: I handle in controller: Then I get an array and the result returned is exactly what I need. But when I query this way because I need to get a lot of data, the result is an empty array. What did I do wrong? In UserController.php: Please give me any comments. Answer You have to select