Skip to content

Tag: php

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…

RPI Launch VLC via php on local machine

I am trying to open a .mp4 file in VLC via the PHP exec command on a RPI 3 SITUATION I access localhost and select the .mp4 file I want to play on a mobile device. RESULT I want PHP to open the video file using VLC on the host machine, which is connected via HDMI to a display. The

Add class to loop iteration php

I’m stumped here. I have six CSS classes that I want to dynamically apply to my loop. grid1,grid2,grid3,grid4,grid5,grid6 How do I apply that when I run on the 7th iteration it would apply “grid1” and so and so forth? What would be the best way? Answer The easiest and imo cleanest way to ach…

Remove the comma and number of a string

I tried to find a solution, but no luck so far. I need to remove the comma and third number (,1482.36 / ,73.50 / ,-472.15 / ,472.15) of each ‘block’ in a given string like the example bellow: Any clues of how I could do it in PHP? Thanks Answer You will need to use preg_split actually to split the

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 …