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…
Tag: php
Surely noobie Laravel Question: Undefined id? Why? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 9 months ago. Improve this question I’m trying to edit the data saved in my DB, and I’m completel…
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 5.8: Weird Error Trying to get property ‘created_at’ of non-object
I’m using Laravel 5.8 to develop my project and in this project, I have a OneToMany relationship between Member Model & Student Model like this: Student.php: Member.php: Then at the Controller, I added this: Now at the view I want to get created_at timestamp like this: $customs->find($student->…
Select specific column from morph relation according to type in Laravel
I am trying to write a query that selects columns from a model then selects some columns from a morph relationship table. But I have no idea to select columns, and relation tables have different columns. So some column has no slug, some have. Models How can I select specific columns from morph relation with c…
Laravel migration shows column doesn’t exist for existing columns
I’ve written the above code in the up method of my migration but when running migrate command, it shows – Course table migration file I don’t have any idea why this error occurs because i’ve the userId column in my ‘course` table migration. Any help is much appreciated. EDIT Outp…
Replace text on click radio button and change it back to the original text if clicked on other radio button
String replace is working fine for me, But how to bring the last clicked radio button label text back to the original text? Here is my PHP,HTML Code: Answer I think you should add an extra attribute in the input instead (it can be data-origin or some thing like that). For example: And then make a function tri…
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 …