Skip to content

Instantly share code, notes, and snippets.

Avatar

Duncan McClean duncanmcclean

View GitHub Profile
@duncanmcclean
duncanmcclean / console.php
Last active Apr 16, 2021
Identify & fix Duplicate IDs in Statamic 3.
View console.php
<?php // copy everything after this line
Artisan::command('identify-duplicates', function () {
$duplicates = [];
$shouldFixDuplicates = $this->confirm('Should Duplicate IDs be replaced with fresh IDs?');
$items = collect(\Illuminate\Support\Facades\File::allFiles(__DIR__.'/../content'))
->filter(function ($file) {
return $file->isFile();
})
View CreateFakeEntries.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Faker\Factory;
use Statamic\Facades\Entry;
use Illuminate\Support\Str;
class CreateFakeEntries extends Command
@duncanmcclean
duncanmcclean / README.md
Last active May 8, 2020
Statamify to Simple Commerce migrator
View README.md

Statamify Importer

This command should import most things like products, orders, customers etc for you but there are still some things that you'll need to configure by yourself.

If there's anything you neeed to customise for your store, just do it. It's why I didn't ship this as a package.

  1. Copy over the site directory of the site that used Statamify.
  2. Install Statamic's Migrator addon (this import script uses it) composer require statamic/migrator --dev
  3. Create a file in your App\Console\Commands folder called StatamifyImportCommand.php.
  4. Copy the whole of the script (the other Gist file) and paste it in as the command's contents.
View heroku-fathom-lite.sh
# Installs Fathom Lite on Heroku
APPNAME=$1
EMAIL=$2
PASS=$3
heroku create $APPNAME --buildpack https://github.com/ph3nx/heroku-binary-buildpack.git
heroku git:clone -a $APPNAME
cd $APPNAME
View LoginTest.php
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class LoginTest extends TestCase
{
View LoginTest.php
$response = $this->post('/login', [
'email' => $user->email,
'password' => 'secret'
]);
$response->assertStatus(302)
->assertRedirect('/articles');
View UserFactory.php
<?php
use Illuminate\Support\Str;
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
View LoginTest.php
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class LoginTest extends TestCase
{
View phpunit.xml
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
View .env
TESTING_DB_HOST=
TESTING_DB_DATABASE=
TESTING_DB_USERNAME=
TESTING_DB_PASSWORD=