Skip to content

Instantly share code, notes, and snippets.

View paulund's full-sized avatar

Paulund paulund

View GitHub Profile
@paulund
paulund / google-webfont-async.php
Last active January 25, 2023 11:51
Javascript tag to load google web font async
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Roboto' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
@paulund
paulund / AppServiceProvider.php
Last active March 16, 2023 18:10
Laravel Cache Auth::user(). Learn how to cache the logged in user at https://paulund.co.uk/laravel-cache-authuser
<?php
namespace App\Providers;
use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@paulund
paulund / AuthTestsServiceProvider.php
Last active November 20, 2021 09:07
Laravel Make Auth Tests
<?php
namespace Dappa\AuthTests;
use Illuminate\Support\ServiceProvider;
/**
* Auth test service provider
*/
class AuthTestsServiceProvider extends ServiceProvider
@paulund
paulund / toggle.vue
Created April 15, 2018 14:25
How to create a VueJS toggle component
<template>
<div class="my-2">
<div class="toggle">
<input type="checkbox" :id="id" :name="id" value="1" v-on:change="updateValue($event.target.value)" :checked="isChecked" />
<label :for="id"></label>
</div>
<p class="inline-block">{{ label }}</p>
</div>
</template>
@paulund
paulund / AdminNewUser.php
Last active March 23, 2019 17:27
How to send an email to admin when new users sign up.
<?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
paulund / www-redirect.conf
Created April 8, 2018 09:25
Nginx redirect www to non-www
server {
listen 80;
listen 443 ssl;
server_name www.example.com;
return 301 https://example.com$request_uri;
}
@paulund
paulund / laravel-recaptcha-validation.php
Created April 3, 2018 19:14
A Laravel validation rule to verify recaptcha.
<?php
namespace App\Rules;
use GuzzleHttp\Client;
use Illuminate\Contracts\Validation\Rule;
class GoogleRecaptcha implements Rule
{
/**
@paulund
paulund / Results--html.vue
Created December 26, 2017 14:53
Creating a Laravel, VueJS, Algolia real time search results box.
<template>
<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>
</div>
</section>
</template>
@paulund
paulund / SmokeGuestTest.php
Last active April 12, 2024 15:56
Example of smoke testing guest URLs in a Laravel application
<?php
namespace Tests\Feature\SmokeTests;
use App\Models\Post;
use App\Models\Tutorial;
use Illuminate\Routing\Router;
use Tests\TestCase;
class SmokeGuestTest extends TestCase
<?php
namespace Paulund\ContactForm\Http\Controllers;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Mail;
use Paulund\ContactForm\Http\Requests\ContactFormRequest;
use Paulund\ContactForm\Mail\ContactEmail;
use Paulund\LaravelCommon\Http\Controllers\Controller;