Skip to content

Instantly share code, notes, and snippets.

View ContactController.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;
paulund / css-purge-webpack-config.js
Last active Apr 26, 2021
Using CSS Purge With Laravel Mix. Tutorial on how to use the following can be found reduced a production ready CSS file from 179kb to 7.9kb.
View css-purge-webpack-config.js
plugins: [
new purgeCss({
paths: glob.sync([
path.join(__dirname, 'resources/views/**/*.blade.php'),
path.join(__dirname, 'resources/assets/js/**/*.vue')
extractors: [
extractor: class {
paulund / HomeController.php
Last active Nov 15, 2017
Tutorial on how to use can be used A gist to demo how to implement view objects in Laravel. Return this object from your controllers and you can remove duplicate return view code from your multiple controllers.
View HomeController.php
namespace App\Http\Controllers;
use App\Http\Resources\PostIndexResource;
use Dappa\Blog\Repositories\PostRepository;
* Homepage controller
class HomeController extends Controller
View php7-array-iteration.php
function loopThroughArrayErrors($array)
foreach($array['values'] as $key => $value)
echo $value;
function loopThroughArray($array)
paulund / phpcs.xml
Created Aug 20, 2017
PHP PSR-2 CodeSniffer Config for Laravel
View phpcs.xml
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
paulund / laravel-db-debug.php
Created Jul 18, 2017
Laravel Output DB Debug
View laravel-db-debug.php
* Add the following to routes to output DB data
\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) {
echo $query->sql;
paulund / youtube-responsive.css
Created Jul 16, 2017
Responsive Youtube Embedded Video
View youtube-responsive.css
.video-wrapper {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
padding-top: 25px;
height: 0;
.video-wrapper iframe {
position: absolute;
top: 0;
paulund / javascript-slugify.js
Created Jul 4, 2017
JavaScript function to slugify a string
View javascript-slugify.js
slugify (text)
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/&/g, '') // Replace & with empty
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, '') // Trim - from end of text
.replace(/-$/, ''); // Remove last -
View vue-pagination.vue
<ul class="pagination">
<li v-if="pagination.current_page > 1">
<a href="javascript:void(0)" aria-label="Previous" v-on:click.prevent="changePage(pagination.current_page - 1)">
<span aria-hidden="true">«</span>
<li v-for="page in pagesNumber" :class="{'active': page == pagination.current_page}">
<a href="javascript:void(0)" v-on:click.prevent="changePage(page)">{{ page }}</a>
paulund / example-wp-list-table.php
Last active Nov 20, 2021
An example code of using the WP_List_Table class. With Pagination.
View example-wp-list-table.php
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI:
* Author: Paul Underwood
* Author URI:
* Version: 1.0
* License: GPL2