Skip to content

Instantly share code, notes, and snippets.

View bmadigan's full-sized avatar

Brad Madigan bmadigan

View GitHub Profile
@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,
@bmadigan
bmadigan / sample.js
Created June 15, 2016 17:22
Sample Inline Save VueJS
<tr v-for="shipment in gridData" id="tr-field-{{ shipment.id }}">
<td style="display:none;">
<input type="hidden" v-model="shipForm[$index].id" value="{{ shipment.id }}">
</td>
<td>
<input
@keyup.enter="saveField(shipForm[$index])"
@keyup.tab="saveField(shipForm[$index])"
type="text"
v-model="shipForm[$index].shipment_number"
// Build out the query based on the form filter request
$contractQuery = Contract::where('id', '>', '1'); // get all contracts
if($request->get('company') != '') {
$contractQuery->where('mpb_company', $request->get('company'));
}
if($request->get('status') != '') {
$contractQuery->where('status', $request->get('status'));
}