Skip to content

Instantly share code, notes, and snippets.

@0xMatt
0xMatt / Breadcrumb.php
Created June 12, 2014 14:59
My breadcrumb classs
<?php namespace 0xMatt\Breadcrumb;
use View;
class Breadcrumb
{
// ---------------------------------------------
// Class Properties
// ---------------------------------------------
@0xMatt
0xMatt / gist:3996cd73992957fec6e4
Created June 16, 2014 18:41
Iterate over indexed array and group evey two values into associative array
<?php
$array = ['string1', 'string2', 'string3'];
$obj = new ArrayObject( $array );
$it = $obj->getIterator();
$new = [];
while($it->valid())
@0xMatt
0xMatt / gist:85da048d46dd04212699
Created June 17, 2014 18:19
Effective column splitting
<?php
echo '<table border="1"><tr>';
foreach(range(1,20) as $key => $row)
{ echo '<td>'. $row . '</td>';
if(++$key % 5 == 0 ) echo '</tr><tr>';
}
echo '</td></table>';
<?php
use LaravelCms\Mvc\Resolver;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
<?php
namespace LaravelCms\Theme;
class Theme
{
/**
* Theme constructor
*
* @return void
* @access public
@0xMatt
0xMatt / Repository.php
Last active August 29, 2015 14:10
Laravel 5 Repositories
<?php
namespace Lithe\Database;
use Illuminate\Database\Eloquent\Model;
use Lithe\Contracts\Database\RepositoryInterface;
use Illuminate\Contracts\Container\Container;
abstract class Repository implements RepositoryInterface
{
@0xMatt
0xMatt / Controller.php
Last active August 29, 2015 14:11
Get paginated relationship results for Eloquent 4&5
<?php
class Controller {
public function action()
{
$model = MyModal::with('relationship')->first();
return $model->relationshipPaginated();
}
@0xMatt
0xMatt / AuthController.php
Last active August 29, 2015 14:12
User Authentication
<?php
namespace Modules\System\Http\Controllers\Frontend;
use Modules\System\Http\Requests\Frontend\LoginRequest;
use Modules\System\Http\Requests\Frontend\RegisterRequest;
use Modules\System\Http\Requests\Frontend\ResetRequest;
use Modules\System\Domain\User\UserManager;
use Modules\System\Domain\User\UserRepositoryInterface;
use Modules\System\Domain\User\LoginManager;
use Modules\System\Domain\Validating\ValidatingManager;
@0xMatt
0xMatt / install_projects_module.php
Created December 29, 2014 18:57
Project Module's migration
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class InstallProjectsModule extends Migration
{
/**
* Run the migrations.
*
@0xMatt
0xMatt / gist:f906cf1d3a1042add9cd
Last active August 29, 2015 14:12
$_GET keys whitelist
<?php
if(!validate_request()) {
die('you requested data from a $_GET key that is not whitelisted.');
}
echo 'Your request is valid';
function validate_request($additional_keys = array()) {