I needed an array of all the timezones so I could insert it in to a database seeder. So I created one off a list from wikipedia. \$timezones = array( array('abbr'=>'BIT', 'name'=>'Baker Island Time', 'utc'=>'UTC-12'), array('abbr'=>'NUT', 'name'=>'Niue Time', 'utc …
Here's a base Eloquent Repository. interface BaseRepositoryInterface { /\*\* \* Execute the query and get the first result. \* \* @param array \$columns \* @return :::IlluminateDatabase:::EloquentModel|null|static \* @static \*/ public function first(\$columns); /\*\* \* Execute the query and get the first result or throw an exception. \* \* @param array \$columns \* @return :::IlluminateDatabase:::EloquentModel \* @static \*/ public function firstOrFail …
I needed to get the db prefix for a raw insert query I was running. It's an easy function call to get the current database prefix. DB::getTablePrefix(); Will output the prefix for the current database. This will work in laravel 4.
The environment is based on url matches. You'll find that configuration in /bootstrap/start.php [ps] \$env = \$app->detectEnvironment(array( 'local' => array('your-machine-name'), )); [/ps] Now say you are developing locally and use the prefix/postfix local. E.g: my-new-site.local or local.my-new-site [ps] \$env = \$app->detectEnvironment(array( 'local' => array …
In order to run a custom command from the command line utility called artisan you need to do two things: Create a new CustomCommand file Register that command with artisan Here's a sample Command file called FooCommand.php which should be placed in *app/commands/ * [php]
Typically when Laravel 4 artisan is run from the command line (cli) it uses the production configuration files. This can be changed by using a flag when running the command. [ps]php artisan migrate --env=local[/ps] However, adding --env-=local each time while running a script can slow down …
I typically use a library folder in my projects to group of files that you want to use in different projects but don't want to use Satis to manage the contained files. This folder could also be a helper folder for functions that are static and are mainly generic helpers …
Yesterday I was in search of Laravel 4 documentation. I couldn't figure our where to find Laravel 4 documentation. I found the committed files on GitHub but I couldn't find the actual site that hosted it. Turns out it was in a now obvious place. http://four.laravel.com/
An easy way to set up composer globally is to follow the instructions on getcomposer.org site: [ps] \$ curl -s http://getcomposer.org/installer | php \$ sudo mv composer.phar /usr/local/bin/composer [/ps] Now I can use composer by invoking just the composer command. Optional way to do it …