I am using symfony 3.4 (I know, needs to be upgraded, we are working on it). I have written a shell command to run every month as a cron job. I have the following code: In the uploadInventoryReport method, it connects to an FTP server, uploads a file, and when the file is successfully uploaded, it executes th…
Carbon object in mockery php test
Thank you for your time. I have stripped out the fluff from the code/test. The furthest I have got with this is that setAttribute requires two strings as param´s, but i am passing in an Carbon object, which Mockery as a test suite does not like? Is this the case, is there a better way to test dates with Mocke…
Symfony 3.4 Functional tests
I have been stuck for some time on an error to do my functional tests with symfony 3.4. My app run a custom GuardAuthenticator for authenticate my users within CAS authentication. This is just for explain the context. In my tests, I don’t want to use it, I want to use a specific authentication system. I…
Convert a json to multi-dimensional PHP array
I have the following json sent to my API endpoint {“key”:”levels”,”value”:”[{role_id:1, access_level_id:3}, {role_id:2, access_level_id:1}, {role_id:3, access_level_id:2}]”,”description”:””} at the backend, I receive it as a Laravel reque…
Returning null instead of “Call to undefined relationship” error for Laravel relationships
When I use ModelName::with(‘somerelation’)->get() with Laravel Eloquent, if the model doesn’t have this relationship I get Call to undefined relationship [somerelation] on model [AppSomeModel] error. But for polymorphic relations, I get collection of all related models and I would like to…
Eloquent complex relationship for a chat message system in laravel
I am writing a chat system and I have the following tables: chat_conversations: id, name chat_messages: id, chat_conversation_id, message, deleted_at chat_message_user: id, chat_message_id, user_id, …
How to get two minimum values from a price column (database). [Laravel]
I’m doing an online store and I have a “sale” section. In this section I want to place two products with the minimum price. I can get one product using the min () function, but I do not understand how to get two minimum values from the database.Thank you in advance. Answer you can use it l…
Access data in nested array with PHP
From a web service I am reading an xml file with the following structure I then use the following php code to parse through the data I would expect the code above to display Instead my output is I am real beginner in php and cant really figure this out… Any help please? Answer $productsArray[‘Stor…
How do I call a php file with axios?
I am doing a CRUD with vue.js and php. I installed the axios and I believe it is working. I just don’t know how to call the php file that connects to the database and creates, read … The folder structure: An excerpt from my script: Answer In axios you are referencing a file which will not work Axi…
Get elements by tag name starting with string in PHP
I need to get all tag elements in PHP that are starting with a certain string, similar to this: $dom = new DOMDocument(); $dom->loadHTML( $content ); $domPre = $dom->…