Skip to content

Instantly share code, notes, and snippets.

Martin Bean martinbean

Block or report user

Report or block martinbean

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@martinbean
martinbean / CartPage.php
Created Mar 15, 2019
Laravel Dusk example test
View CartPage.php
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class CartPage extends Page
{
/**
* {@inheritDoc}
@martinbean
martinbean / LogNameHandler.php
Last active Mar 15, 2019
Mapping jobs to handler classes in Lumen
View LogNameHandler.php
<?php
namespace App\Handlers\Jobs;
use App\Jobs\LogNameJob;
use Illuminate\Support\Facades\Log;
class LogNameHandler
{
public function __construct()
View styles.css
p:last-of-type::after {
content: "\0020 \220E"
}
@martinbean
martinbean / component.js
Created Nov 10, 2018
Promise-based Vue.js confirmation dialog mixin
View component.js
import confirm from './confirm';
export default {
mixins: [
confirm
],
methods: {
onDelete() {
this.confirm('Are you sure you wish to delete this item?').then(() => {
// Delete item
@martinbean
martinbean / webpack.mix.js
Created May 17, 2018
Vendor library extraction in Laravel Mix
View webpack.mix.js
let mix = require('laravel-mix');
mix.sass('resources/assets/sass/app.scss', 'public/css')
.js('resources/assets/js/app.js', 'public/js')
.js('resources/assets/js/channel-admin.js', 'public/js')
.js('resources/assets/js/video.js', 'public/js')
.extract(['jquery', 'bootstrap'])
.options({ processCssUrls: false })
.sourceMaps();
View gist:d2889eef2bc4affddcd6a2386b44dd2a
vendor/bin/phpunit --printer="PHPUnit\TextUI\ResultPrinter"
@martinbean
martinbean / ArticleController.php
Created Mar 26, 2018
Using Laravel’s Responsable interface to create view models
View ArticleController.php
<?php
namespace App\Http\Controllers;
use App\Article;
use App\Http\Views\ArticleIndex;
class ArticleController extends Controller
{
public function index()
@martinbean
martinbean / AppServiceProvider.php
Last active Mar 1, 2018
Disable Bugsnag in certain environments
View AppServiceProvider.php
<?php
namespace App\Providers;
use Bugsnag\BugsnagLaravel\Facades\Bugsnag;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@martinbean
martinbean / test.php
Created Feb 6, 2018
Throw a validation exception with a plain array of errors
View test.php
<?php
use Illuminate\Validation\ValidationException;
if ($coupon->cannotBeRedeemed()) {
throw ValidationException::withMessages([
'coupon' => [
'The coupon code is invalid.',
],
]);
@martinbean
martinbean / confirm.js
Created Nov 27, 2017
Vue.js confirm mixin
View confirm.js
module.exports = {
methods: {
confirm(message, callback) {
if (window.confirm(message)) {
callback();
}
}
}
};
You can’t perform that action at this time.