By Michael Williams, Published on 10/07/2018
When changing symlinks, particularly as part as a deployment. The goal is generally to eliminate downtime. We often refer to these an atomic deployments.ln -sf release current
ls -lah
current -> release
By Michael Williams, Published on 10/07/2018
When changing symlinks, particularly as part as a deployment. The goal is generally to eliminate downtime. We often refer to these an atomic deployments.ln -sf release current
ls -lah
current -> release
By Michael Williams, Published on 06/23/2018
Since version 5.4.0. PHP comes with a built in web server. If you're doing anything significant, chances are that you'll likely use Vagrant or similar to manage your local environment(s).By Michael Williams, Published on 06/09/2018
When working with data such as users or user related records. Sometimes you may want to soft delete the data rather than permanently removing it. One advantage to soft deletes is easy restore in the event of an accidental delete by someone, but the use cases are unlimited. Luckily, in Laravel the setup for this is quite simple.Schema::table('users', function ($table) {
$table->softDeletes();
});
By Michael Williams, Published on 05/26/2018
Sometimes when you work with relations in Laravel, a need me arise to add a constraint to the relatioship data. In Laravel terms, this is referred to as Constraining Eager Loads.
Assumming that you have a User and Post Model. One might build a query as such to retrieve active posts for a specific user.
$this->posts->whereStatus('published')->whereUserId($userId)->get();
When loading the User with the Post relationship, we can also get the published posts only by running:
$this->user->with(['posts' => function ($query) {
$query->where('status', 'published');
}])->get();
By Michael Williams, Published on 05/22/2018
collections such as an arrays into individual function params and elements.In the first example, lets look at getting the max value from an array of numbers. That can simply be written as:
const array = [12, 34, 19, 84, 42, 5];
const maxValue = Math.max(...array);
console.log(maxValue); // 84
Alternately you may want to take a string of text and convert it to an array