Skip to content

Instantly share code, notes, and snippets.

@mattdfloyd
mattdfloyd / 0.php
Created September 28, 2017 19:37
Dusk Blade directive
<?php
Blade::directive('dusk', function ($expression) {
if (app()->environment('production')) {
return;
}
return "<?php echo sprintf('dusk=\"%s\"', $expression); ?>";
});
@mattdfloyd
mattdfloyd / HiddenInput.vue
Created May 4, 2018 11:36 — forked from calebporzio/HiddenInput.vue
Little Vue component for turning JSON into native HTML for inputs
<script>
import { flatMapDeep } from 'lodash'
export default {
props: [ 'name', 'value' ],
methods: {
flatInputsFromDeepJson(item, key, h) {
if (typeof item === 'object') {
return flatMapDeep(item, (value, newKey) => {
@mattdfloyd
mattdfloyd / CreateProductJob.php
Created June 21, 2018 02:26
Laravel's firstOrCreate race conditions
<?php
namespace App\Jobs;
use App\Product;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Redis;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
@mattdfloyd
mattdfloyd / csrfToken.vue
Created July 30, 2018 15:55
CSRF Token Component
<template>
<input type="hidden" name="_token" :value="token">
</template>
<script>
export default {
data() {
return {
token: null,
}
},
@mattdfloyd
mattdfloyd / gist.php
Created August 21, 2019 14:46
Searchable cascade via dot notation
<?php
use Illuminate\Support\Collection;
use Laravel\Scout\Searchable;
abstract class Cascade
{
protected $models = [
// Organization::class => ['users']
];