Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️
On holiday

Duncan McClean duncanmcclean

🏖️
On holiday
View GitHub Profile
View Torchlight.php
<?php
namespace App\Tags;
use Statamic\Tags\Tags;
use Torchlight\Blade\BladeManager;
use Torchlight\Block;
class Torchlight extends Tags
{
View AutomaticallyLogin.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Statamic\Facades\User;
class AutomaticallyLogin
View Torchlight.php
<?php
namespace App\Tags;
use Statamic\Tags\Tags;
use Torchlight\Blade\BladeManager;
use Torchlight\Block;
class Torchlight extends Tags
{
@duncanmcclean
duncanmcclean / SalesExport.php
Last active Jan 22, 2022
Basic Sales Exporter for Simple Commerce
View SalesExport.php
<?php
namespace App\Exports;
use DoubleThreeDigital\SimpleCommerce\Facades\Order;
use DoubleThreeDigital\SimpleCommerce\Facades\Product;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Statamic\Facades\Entry;
@duncanmcclean
duncanmcclean / FormParameters.php
Created Jun 5, 2021
Generates & checks parameters are the same between creating & submitting a form. Inspiration from Livewire's checksum component: https://github.com/livewire/livewire/blob/master/src/ComponentChecksumManager.php
View FormParameters.php
<?php
namespace DoubleThreeDigital\SimpleCommerce\Tags\Concerns;
class FormParameters
{
// TODO: this isn't really a 'concern', so maybe we should move this elsewhere?
// Kept in sync with $knownParams on `FormBuilder`
private static $knownParams = [
@duncanmcclean
duncanmcclean / console.php
Last active Oct 25, 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
{