Skip to content

Instantly share code, notes, and snippets.

@edueo
Last active August 29, 2015 14:08
Show Gist options
  • Save edueo/3ada27817508c4397845 to your computer and use it in GitHub Desktop.
Save edueo/3ada27817508c4397845 to your computer and use it in GitHub Desktop.
Laravel tips
<?php
// routes.php
Route::get('tasks/{id}', 'TaskController@show')->where('id', '\d+');
// Na model de user, para evitar Hash::make('senha')
public function setPasswordAtrribute($value)
{
$this->attributes['password'] = Hash::make($value);
}
// app/start/global.php - Interceptando erros
App::error(function(Illuminate\Database\Eloquent\ModelNotFoundException $exception)
{
//return Redirect::home();
return View::make('home.index');
});
// Ouvindo as querys
Event::listen('illuminate.query', function($query)
{
var_dump($query);
});
// Eager Loading
$user->tasks()->findOrFail($id);
`
// Passar a ser ..
$user::with('tasks')->[...]

// Helper

// app/helpers.php

composer.json

"autoload" : {

   [...],
   "files" : [
     "app/helpers.php"
   ]

}
composer dump-autoload -o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment