Skip to content

Instantly share code, notes, and snippets.

View albofish's full-sized avatar

Alex Hollyman albofish

  • Prescript Communications Ltd
  • Bedfordshire, United Kingdom
View GitHub Profile
@albofish
albofish / EntrustFixFacade.php
Created September 2, 2016 10:48
Entrust Laravel 5.3 Blade syntax fix
<?php namespace App\Extensions\EntrustFix;
use Zizaco\Entrust\EntrustFacade;
class EntrustFixFacade extends EntrustFacade
{
//
}
@albofish
albofish / laravel-resources.md
Last active August 30, 2016 08:26
Laravel Resources

Scaffolding

Laravel 5.2 Scaffold Generator

https://github.com/laralib/l5scaffold

Generates model, REST controller, migration, table seeder, REST UI (Twitter Bootstrap)

  1. composer require 'laralib/l5scaffold' --dev
  2. app/config.php - "Laralib\L5scaffold\GeneratorsServiceProvider"
  3. php artisan make:scaffold Post --schema="title:string:, body:text"
@albofish
albofish / entrust-user-permission.md
Last active March 20, 2017 11:47 — forked from uzegonemad/entrust-user-permission.md
Entrust Laravel 5 User Permissions

What is this?

Entrust is a fantastic role-based permission library for Laravel. However, by design, it only supports attaching permissions to roles, not to users.

This gist adds support for user-specific permissions on top of existing roles.

There's a chance that this hasn't been thought out fully, so use it at your own risk... I'm offering zero support for this. It either works, or it doesn't.

This has only been tested on Entrust's Laravel 5 branch.

How to use it

@albofish
albofish / wp-clean.php
Created May 11, 2016 13:23
Quick Wordpress Optimisations
<?php
define('WP_POST_REVISIONS', 0); // Remove post revision support
add_theme_support( 'post-thumbnails' ); // Add post thumbnail support
add_theme_support('html5', array('comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'widgets')); // Add html5 support
/**
* Clean up Wordpress HTML output
*/
function wp_clean_setup () {
remove_action('wp_head', 'wp_generator');
@albofish
albofish / gist:93afafbc557ad118ba37
Created August 13, 2015 08:26
Class ASP adovbs.inc
<%
'--------------------------------------------------------------------
' Microsoft ADO
'
' (c) 1996 Microsoft Corporation. All Rights Reserved.
'
'
'
' ADO constants include file for VBScript
'
@albofish
albofish / outputCSV.php
Last active May 4, 2022 03:02
Laravel Chunk Results to CSV
<?php
/*
* Chunk through result set and output as CSV file in browser.
*/
function outputCSV($columns, $query, $chunkSize = 200) {
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename='export-" . date("YmdHis") . ".csv");
header("Pragma: no-cache");
header("Expires: 0");
@albofish
albofish / CSVSeeder.php
Last active March 19, 2023 05:41
Laravel CSV to Array
<?php
// ini_set("auto_detect_line_endings", true); // If having issues on iOS
trait CSVSeeder {
public function csv_to_array($filename = '', $delimiter = ',') {
if (!file_exists($filename) || !is_readable($filename))
return FALSE;
$header = NULL;
$data = array();