Laravel Filters: Route access depending on the user group

Filters are one of the Larevel’s features that I like the most. It’s pretty straightforward – you need to run some chunk of code before or after some action. Recently I had to implement restrictions on route resources depending on user group. I use Sentry for user authentication and role management and this Laravel filter should check if user belongs to specified group and allow him access to route resource if he does.

One solution is to simply create a new filter for every group. But, I don’t like repetition. I wanted simple and elegant solution that meets my requirements, without unnecessary repetition of code. Here is solution I came up with:

Continue reading Laravel Filters: Route access depending on the user group

Deploy your Laravel 4 application on Heroku

Heroku is a popular PaaS that allows you to deploy your application’s in no time. But, learning how to do that can be confusing, especially for PHP developers. In this tutorial I’ll cover basic steps which will help you to deploy your Laravel 4 application on Heroku. First let’s download Laravel:

After that, enter in laravel directory:

and initialize new git repository:

Now, create .gitignore file and put everything you want to ignore from git tracking. You can use Laravel’s default .gitignore file, just remove composer.lock from it:

Continue reading Deploy your Laravel 4 application on Heroku

Install Elasticsearch on Laravel Homestead

Recently I started working on a Laravel project that requires integration with Elasticsearch search engine. I didn’t want to change super cool development environment that Taylor (creator of Laravel) so kindly provided to us, so I installed Elasticsearch on Homestead instead of creating a new Vagrant box specially for this project. Here is a little snippet that will help you if you want to use Elasticsearch in you Laravel application.

 

Continue reading Install Elasticsearch on Laravel Homestead