Using Tinkerwell to working on Tinkerwell is a common use case at Beyond Code. This time, a customer with multiple licenses requested if we can make it work that all their license keys expire at the same time so that it becomes easier for them to renew all their keys at once.
All their licenses are still active but vary with their renewal date – so we decided to update all their keys. For this, we wanted to sum up all days of all their Tinkerwell licenses where they qualify for updates.
After that, we divide that by the number of licenses so that we get the number of days from now that we need to add to each key.
Before we run the command, we checked if the date is correct and used Magic Comments for this information. Magic Comments display the value of a variable during the execution of the line of code. If a line get's executed multiple times, every output is appended at the end of the line as well.
Everything looked correct, so we run the update.
With this code written in a couple of minutes, we were able to make our customer happy and it was much easier than doing all the calculations by hand and changing the values in the database. We also stored this as a Code Snippet in Tinkerwell so that we can use the code if an additional custom has the same request again.
“I’ve pretty much used Tinkerwell every day since it was released.”
Taylor Otwell
Creator of Laravel
“I open Tinkerwell together with my IDE to have an instant feedback loop when prototyping an implementation. I can't imagine a life without it now.”Kamau Wanyee
FullStack Developer
The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.
Buy now Learn more