Skip to content

Instantly share code, notes, and snippets.

paulund / google-webfont-async.php
Created Jul 14, 2018
Javascript tag to load google web font async
View google-webfont-async.php
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Roboto' ] }
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
wf.type = 'text/javascript';
wf.async = 'true';
paulund / AppServiceProvider.php
Last active Aug 7, 2021
Laravel Cache Auth::user(). Learn how to cache the logged in user at
View AppServiceProvider.php
namespace App\Providers;
use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
View AuthTestsServiceProvider.php
namespace Dappa\AuthTests;
use Illuminate\Support\ServiceProvider;
* Auth test service provider
class AuthTestsServiceProvider extends ServiceProvider
paulund / toggle.vue
Created Apr 15, 2018
How to create a VueJS toggle component
View toggle.vue
<div class="my-2">
<div class="toggle">
<input type="checkbox" :id="id" :name="id" value="1" v-on:change="updateValue($" :checked="isChecked" />
<label :for="id"></label>
<p class="inline-block">{{ label }}</p>
paulund / AdminNewUser.php
Last active Mar 23, 2019
How to send an email to admin when new users sign up.
View AdminNewUser.php
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class AdminNewUser extends Mailable
paulund / www-redirect.conf
Created Apr 8, 2018
Nginx redirect www to non-www
View www-redirect.conf
server {
listen 80;
listen 443 ssl;
return 301$request_uri;
paulund / laravel-recaptcha-validation.php
Created Apr 3, 2018
A Laravel validation rule to verify recaptcha.
View laravel-recaptcha-validation.php
namespace App\Rules;
use GuzzleHttp\Client;
use Illuminate\Contracts\Validation\Rule;
class GoogleRecaptcha implements Rule
paulund / PostController.php
Created Feb 10, 2018
A resource post controller example with tests.
View PostController.php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Post;
use Illuminate\Http\Request;
* PostController
paulund / Results--html.vue
Created Dec 26, 2017
Creating a Laravel, VueJS, Algolia real time search results box.
View Results--html.vue
<section class="search-results" v-show="results.length > 0">
<div v-for="result in results" class="search-result">
<a :href="'/' + result.slug">{{ result.title }}</a>
paulund / SmokeGuestTest.php
Last active Dec 17, 2017
Example of smoke testing guest URLs in a Laravel application
View SmokeGuestTest.php
namespace Tests\Feature\SmokeTests;
use App\Models\Post;
use App\Models\Tutorial;
use Illuminate\Routing\Router;
use Tests\TestCase;
class SmokeGuestTest extends TestCase