I have two columns in my database named dtp_s and dtp_e. Both of these columns hold strtotime() formatted ints which I then use in my PHP application to calculate hours/minutes between time intervals. I want to display the 5 most recent records in date order, which works fine when I use this: However, I now w…
Q: How to make conditional constructor statement within a controller in laravel
I have a controller which uses two models of authenticatable type of users, if i’m authenticated as an applicant it successfully renders the applicant.index view, and the same thing goes to if I’m authenticated as an Employer. The issue for me is when I’m not logged in and visits the /app it…
How to establish a one-to-many relationship to a model whose type is stored in db
I have a database that looks like this: Database Graphical Representation The dance_performer.perfomer_type field hosts values such at ‘AppDancer’, ‘AppCouple’ or ‘AppFormation’. How would you proceed to connect the dance_performer.perfomer_id to the different models? I am …
How to terminate script on any error? (Like the equivalent bash `set -e` option)
How can I terminate / halt a PHP script and return an error exit code if ANY errors occur? Basically the functionality that is provided by set -e in Bash? I’ve tried setting ini_set(‘error_reporting’, E_ALL); but this does not actually halt the script when an error occurs. Answer This seems …
WooCommerce get_cart() on null
Before I updated to WC at 4.3.1 ,I had this code and it worked well add_action( ‘rest_api_init’, function () { register_rest_route( ‘px-module-woocommerce’, ‘/px/cart’, array( …
Get the $request object in Laravel’s model events (ex. created, updated etc.)
I am using Eloquent’s model events to do some actions after model has been created/updated/deleted. I’m refering to these: The question: I need to access the $request object in any of these. Is it possible? The scenario I am trying to do is to insert some values in another database table once the …
Running a foreach loop within a Curl function
I need to run a foreach loop within a curl command but can’t quite get the syntax right. I’ve parsed other variables into it fine but it’s just formatting my array to fit. curl_setopt($ch, …
What’s the difference between upcoming PHP8’s spread operator and it’s pre-existing compact function? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question What’s the difference between upcoming PHP8’s spread operator and it’s pre-…
Docker Compose: Set variable in php.ini from Dockerfile
I have a small Docker network based on this package for Docker Compose and Laravel. I’d like to set the upload_max_filesize and post_max_size variables in php.ini to allow for larger file uploads. Is …
What status code for ressource that may or may not exist on REST API
I am working on a one page web application for an online shop in Angular which will rely on a REST API handled by Symfony. One of the first request I make is that I need to know if the customer has an active cart or not. So I have a route /get-user-cart which returns null if the user has