In my Symofny project I want for my entity to have timestamp field. I want to be saved in timestamp format? How can I accomplish that? Like // => 1387909800 I am on Symfony 4.3 version. Answer Try getTimestamp();
Tag: php
How can “round” return a float?
PHP float type is IEEE-754 binary64. The number 59.95 cannot be stored precisely in binary. In IEEE-754 binary64 the representation of 59.95 should be 59.9500000000000028421709430404007434844970703125. However, when I do It returns 59.95. How is that possible? Also the function round claims to return the roun…
How to upload picture when register in laravel?
I’m trying to upload an image in laravel default user registration. I’m using laravel ui package. Here is create method in RegisterController I’m getting this error Undefined variable: image” Answer In the User model:
OpenApi for php doesn’t render enum values correctly
I am building some documentation using OpenApi and Swagger, but I am unable to test it because of a js error. I want to define a parameter that will accept specific values so I added enum in the schema attribute. I am defining the orderBy parameter in a GET request like this When the documentation is generate…
ajax get data request url not found but already exist, Laravel 8
hello guys i have a problem with my ajax data json, i have a project about scan a barcode with a webcam but it just views the code of the barcode, the data in the database not call in my ajax, this is the code of blade, i’m using a modal this is the modal this is the jquery code
laravel feature tests with locales
I am new to Laravel and I am having an issue to write a test function that asserts that the HTTP response of my welcome page is 200 knowing that I have EN and FR locales defined, meaning that the test should test both localhost:8000/en and localhost:8000/fr. This is my exampletest.php: I don’t like writ…
How safe is to use mysqli_insert_id() and if not what should I use?
I have a very simple question I want to know the id of the last query that I inserted in my MySql DB. It’s safe and efficient to use mysqli_insert_id() and if not what should I use? Answer Yes, it’s the recommended way to retrieve an ID value generated by an insert when using auto-increment. But i…
PHP simpleXMLelment xpath returns unexpected results
I have executed the following code on the the sample XML at the bottom of the question and I am getting unexpected results. I would expect this to return only the two record nodes that are children of the current addresses node. But, it actually returns all 5 of the record nodes of the original $xml element. …
How to fix? PHP variable not shows values inside function
I want to pass the variable in a function but get an error : Working Example : Not Working : Answer What you are looking for is the “USE” keyword (for anonymous functions, as you are using in your second example). This allows additional variables from the parent scope to be passed into the closure…
Symfony Update data with a post request
I am currently trying to update a Person in a table. The Table looks the following: I want to be able to update the First-and Lastname and also the nin when I click on the Submit button. My twig file looks like this: And my controller is the following: Currently when I click update I just fill it what’s…