Skip to content

Instantly share code, notes, and snippets.

View aranw's full-sized avatar

Aran Wilkinson aranw

View GitHub Profile
@aranw
aranw / PageController.php
Created November 24, 2012 12:24
Caching issue
<?php
class PageController extends Controller {
/**
* Blog Posts
*
* @var array
**/
protected $posts;
@aranw
aranw / PostController.php
Created November 15, 2012 10:04
Laravel 4 Tests
<?php
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class NoPostsException extends Exception {}
class PostController extends Controller
{
/**
public function showPost($post = null)
{
$view = View::make('blog.post');
$view->with('title', "Aran Wilkinson - "); // We need to get the post title
$view->with('post', $this->posts->getPostBySlug($post));
//
// Get the requested blog post
// If it doesn't exist give 404 error
//
@aranw
aranw / PostController.php
Created November 13, 2012 13:16
Bug with phpunit Laravel 4
public function showPost($post = null)
{
$view = View::make('blog.post');
$view->with('title', "Aran Wilkinson - "); // We need to get the post title
$view->with('post', $this->posts->getPostBySlug($post));
//
// Get the requested blog post
// If it doesn't exist give 404 error
//
@aranw
aranw / gist:4062641
Created November 12, 2012 23:01
L4 Encrypter Bug
PHP Fatal error: Call to undefined function Illuminate\mcrypt_create_iv() in /Users/aran/Sites/blog/vendor/illuminate/encryption/src/Illuminate/Encrypter.php on line 54
Fatal error: Call to undefined function Illuminate\mcrypt_create_iv() in /Users/aran/Sites/blog/vendor/illuminate/encryption/src/Illuminate/Encrypter.php on line 54
@aranw
aranw / album.php
Created November 9, 2012 11:42
Models
class Album extends \Eloquent
{
public static $timestamps = true;
public function artist()
{
return $this->belongs_to('Askonasholt\Artist');
}
public function image()
@aranw
aranw / gist:4030437
Created November 7, 2012 09:44
overlay
<div id="overlay" class="lb">
<div class="media">
<img src="assets/images/content/lightbox-image.jpg" alt="" />
<div class="titlebar">
<a class="close">Close</a>
<p><span class="current">1</span> of <span class="total">25</span></p>
</div> <!-- titlebar -->
<div class="heading">
@aranw
aranw / gist:3981121
Created October 30, 2012 15:55
Artists Model
<?php
namespace Askonasholt;
class Artist extends \Eloquent
{
public static $timestamps = true;
public function category()
{
return $this->has_many_and_belongs_to('Askonasholt\Category');
@aranw
aranw / gist:3916930
Created October 19, 2012 08:23
Resizer Laravel Bundle
if ( ! file_exists($image->saved_to.$filename_stripped.'-480.'.$filename_ext))
{
$file = File::get(path('public').$image->saved_to.$image->filename);
$size_480 = Resizer::open($file)
->resize(480, 340, "crop")
->save($image->saved_to.$filename_stripped."-480.".$filename_ext);
var_dump($size_480);
}
@aranw
aranw / gist:3908030
Created October 17, 2012 20:41
Blog Boxfile
web1:
name: blog
document_root: public
php_version: 5.3.8
after_build:
- "php composer.phar update"
shared_writeable_dirs:
- app/storage
php_extensions:
- mysql