Skip to content

Instantly share code, notes, and snippets.

View SebKay's full-sized avatar

Seb Kay SebKay

View GitHub Profile
@mpociot
mpociot / CanBeReplicated.php
Created June 12, 2019 12:32
Add the ability to replicate Laravel models to other models.
<?php
use Illuminate\Support\Arr;
trait CanBeReplicated
{
public function replicateTo(string $model, array $with = null, array $except = null)
{
$defaults = [
$this->getKeyName(),
@joshuadavidnelson
joshuadavidnelson / add-yoast-redirect.php
Last active November 26, 2024 06:51
Programmatically add a redirect to the Yoast SEO Premium redirects.
<?php
/**
* Create a new redirect within the Yoast redirect system.
*
* @param string $origin_url redirecting from.
* @param string $destination_url redirecting to.
* @param int $type redirect code, defaults to 301.
* @param string $format the format, either 'plain' or 'regex', defaults to 'plain'.
* @return void
*/