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 …
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
How can I place PHP anonymous function to execute CSS inside another function in WordPress
I am not a programmer so I’m sure this is a no brainer. I am trying to disable a popup if WordPress users are not logged in. I am using CSS to disable the popup for a specific Woocommerce plugin. The CSS code works fine if I use it by itself. However, when I try to use it with the
Cannot inject foreign repository into my controller
I’ve got a problem concerning a plugin I’m writing for Typo3. I want to have access to a repository (and the content of that) of a plugin in a different plugin. Like importing the stuff from one plugin to another. What I tried was using @inject in my controller, but the result is null. And my acti…