Skip to content

Instantly share code, notes, and snippets.

View bmadigan's full-sized avatar

Brad Madigan bmadigan

View GitHub Profile
@bmadigan
bmadigan / Install Imagemagick PHP 7.0
Created August 15, 2018 17:30 — forked from grumpysi/Install Imagemagick PHP 7.0
Install Imagemagick on Laravel Homestead box Ubuntu 14 + PHP 7.0
sudo apt-get update && sudo apt-get install -y imagemagick php-imagick && sudo service php7.0-fpm restart && sudo service nginx restart
@bmadigan
bmadigan / FakePaymentGateway.php
Last active October 26, 2017 12:58
Laravel TDD - FakePayment Gateway
<?php
namespace App\Billing;
class FakePaymentGateway implements PaymentGateway
{
const TEST_CARD_NUMBER = '4242424242424242';
private $charges;
private $tokens;
@bmadigan
bmadigan / FastSpring.php
Last active August 24, 2017 15:43
A sample FastSpring connection attempt
<?php
namespace App;
use GuzzleHttp\Client;
class FastSpring {
function __construct()
{
@bmadigan
bmadigan / sample-collection-array.php
Created August 4, 2017 21:39
Laravel - An array to a collection with a loop
// Setup some developer accounts to test with
$developers = [
['name' => 'Tony Richards', 'email' => '[email protected]', 'password' => 'secret'],
['name' => 'Brad Madigan', 'email' => '[email protected]', 'password' => 'secret']
];
collect($developers)->each(function($dev) {
factory(\App\Models\User::class)->create([
'name' => $dev['name'],
'email' => $dev['email'],
@bmadigan
bmadigan / RememberQueryStrings.php
Created August 4, 2017 20:10 — forked from reinink/RememberQueryStrings.php
Remember query strings
<?php
namespace App\Http\Middleware;
use Closure;
class RememberQueryStrings
{
public function handle($request, Closure $next)
{
@bmadigan
bmadigan / AppServiceProvider.php
Created August 4, 2017 20:09 — forked from reinink/AppServiceProvider.php
Eloquent addSubSelect()
<?php
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@bmadigan
bmadigan / WebhooksTest.php
Created June 16, 2017 02:19 — forked from Vasiliy-Bondarenko/WebhooksTest.php
Webhooks testing experiment. Just for fun :)
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Tests\withTestingEnvironment;
use Zttp\Zttp;
class WebhooksTest extends TestCase
{
@bmadigan
bmadigan / assets.php
Last active May 29, 2017 16:13
Remove Multiple Assets
<?php
public function destroy(Request $request, $id = null)
{
abort_unless($this->authUser->hasPermissionTo('manage assets'), 403);
$requestData = $id ?
[$request->all() + ['id' => $id]] :
json_decode($request->getContent(), true);
$assets = Asset::findOrFail(collect($requestData)->pluck('id')->toArray());
@bmadigan
bmadigan / stream-s3-as-zip.php
Created February 15, 2017 15:38 — forked from tillkruss/stream-s3-as-zip.php
Stream files from S3 as ZIP file.
<?php
use Aws\S3\S3Client;
use ZipStream\ZipStream; // https://github.com/maennchen/ZipStream-PHP
protected function streamPhotosetAsZip($files)
{
$s3 = S3Client::factory('...');
$zip = new ZipStream("foobar.zip");
@bmadigan
bmadigan / sample.php
Created September 12, 2016 16:06
Steelhead Soap Request
<?php
//$wsdl_url = 'https://www.steelroads.com/wsdl/com/steelroads/ws/model/TatService.wsdl';
$wsdl_url = 'https://www.steelroads.com/services/TatService';
$username = 'username1';
$password = 'secret';
$client = new SoapClient($wsdl_url, array("soap_version" => SOAP_1_1,"trace" => 1));
$user_param = array (
'WebProviderLoginId' => $username,