Skip to content

Problem with create table Category and get the url correctly PHP

I am creating an ecommerce, which can have Men’s Fashion, Women’s Fashion or Children’s Fashion, it could also have more in the fure like Sports, Electronics, etc. But I don’t know if I have, for example, to repeat the categories clothes, etc for each one or not, I don’t know if …

REST convention when transforming data

I use Laravel as a REST API service for uploading and storing books. The book service follows the standard REST convention: GET: /api/books and /api/books/<book_id> for retrieving book(s) PUT: /api/books/<book_id> for updating a book POST: /api/books for adding a new book DELETE: /api/books/<bo…

Extract a YYYmmDD in PHP

I have images and videos from my camera which are uploaded to my server. In order to properly organize them I need to extract the year month and day. But I cant seem to get this pregmatch right.. Input would be 20211215_083437.jpg Output would be Year2021 Month11 Day15 Answer You need to remove the $ anchor i…

Merge every 2 arrays in a Multidimensional array PHP

So, this is a complicated question for me. Let’s say we have an array that goes like this: supposed to be FAQs question and answer are more than 1, the arrays above separates the faq question and faq answer in 2 different arrays and given that the array is a result of a 3rd party API (which you cannot c…

Populate Dropdown from Zoho Response

I am trying to populate a dropdown from the ZOHO API response I am getting with my request. I have two files. request.php and zoho.php. I am receiving the response from request.php as below. in order to get the result I am decoding the object as below I am having a popup in zoho.php. The way I am looping the

Laravel create custom exception with parameters & return as JSON

I want to throw a custom exception if the variable is null and return it as JSON. I’ve tried like this: Controller Custom Exception But when I am trying to test it using postman, the return I got is not the same as I wrote in NullException. It becomes like this: Answer In your case you are returning the…