Skip to content

Instantly share code, notes, and snippets.

View Penderis's full-sized avatar

Keith Penderis

View GitHub Profile
@Penderis
Penderis / assocCSV.php
Last active August 29, 2015 14:05
Create CSV from Associative Array - PHP
$header=null;
//header nulled first line will make not nulled thus creating csv with header values
$pathToGenerate = "path to new file location including filename";
//create directory if does not exist beforehand, file will be created or override in fopen with w+ flag
$createFile = fopen($pathToGenerate,"w+");
foreach ($assocArray as $row) {
if(!$header){
//this matches the first line to create header values
@ifkas
ifkas / laravel-go-back-link.php
Created August 7, 2014 20:12
Laravel - Go to previous page link
@Penderis
Penderis / Batch Recursive File Copier.bat
Last active July 23, 2023 11:29
Windows Batch Script to recursively copy files from folders into new folder using a text document with filenames
@echo off
CLS
setlocal EnableDelayedExpansion
REM Changes root path to relative of current bat folder
pushd "%~dp0"
REM finds files in provided .txt file and copies them to destination directory
REM CHECK FOR ADMIN RIGHTS
COPY /b/y NUL %WINDIR%\06CF2EB6-94E6-4a60-91D8-AB945AE8CF38 >NUL 2>&1
@leabdalla
leabdalla / Laravel Sentry 2 with multiple user types.md
Last active February 10, 2024 10:57
Laravel Sentry 2 with multiple user types, finally.

Sentry is an amazing auth system. But I really need a feature: multiple user types in the same app. And I cannot separate those in groups, because they have different table columns. After 2 days burning my head, I think I found a good solution. The magic is duplicate SentryServiceProvider with new different settings.

This was tested on Laravel 4.0 and Sentry 2. If you're using other version of Sentry, my suggestion is to follow same steps from this gist but use your local files instead copying files from here.

Lets suppose we have a fresh Sentry install with default User ambient. Now we want another ambient called Admin, with new model and different settings. How to do:

1. One model, one ambient

@Kindari
Kindari / gist:3879716
Created October 12, 2012 15:19
Laravel Filter Route based on Role
<?php
Route::get('protected', array('before' => 'auth|role:admin', function() {
return "Only admins can see this";
}));
Route::filter('role', function ($role) {
if ( ! Auth::user()->has_role( $role ) )
{
return Response::error("401"); // not authorized