Articles tagged with #laravel




Array list of all timezones

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 …



BaseRepositoryInterface Base Eloquent Repository

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 …



How to get laravel database prefix

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.



How to get the base directory of a laravel 4 installation.

In order to get the base directory of a laravel 4 install you'll just need to do one command. It's fairly simple. app()->make('path.base')



How to set Laravel 4 environments

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 …



Add a command file to Laravel artisan

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]



How to set local environment as default in command line (CLI) for Larvel 4 artisan

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 …



How to add a library folder to Laravel 4

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 …



Laravel 4 Documentation

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/



Setting up Composer globally for Laravel 4

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 …