Amitav Roy

Blog on web and travel

Events in Laravel 5 and customising Model save

Posted on 15 Mar 2015 by Amitav Roy

Laravel has always been a treat to work with and the new version not only brings a lot of added features but also gives a much structured folder structure which will help organize the code even much better. One of the great features of Laravel 4 for me is events which I have shown in my tutorial Laravel 4 how to use Events. But in Laravel 5 the code is structured even better. In this tutorial, I will show you how we can use Events in Laravel 5 and how we can customize the default mode’s save function to fire an event on every save.

Uploading images on AWS S3 from a Laravel 4 application

Posted on 26 Feb 2015 by Amitav Roy

Any web application which deals with a lot of images or a lot of file downloads will for sure want to offload their space requirements for images and files from the mail server to buckets like what Amazon provides us. Some may even choose Amazon cloudfront (CDN) for storing images if their traffic is from different geo locations. So, in this tutorial I will show how we can use the Amazon SDK and the Laravel wrapper to store images on Amazon S3 inside a bucket.

Laravel 4 how to use events

Posted on 11 Oct 2014 by Amitav Roy

One of the most powerful aspects of Drupal is the concept of hooks. We can modify core features of Drupal entities without hacking the core. It’s a great way to separate the concerns of code which in long-term helps us write maintainable code. Laravel's event is one such thing which I can compare with hooks. In this tutorial, I will show you how to use a Laravel event like user login and perform some activity using a complete different class.

Creating CSV output from database query result in Laravel 4

Posted on 4 Sept 2014 by Amitav Roy

Generating a CSV file from some records in the database is a very common requirement which a web developer will come across. It will be nice and handy to have a generic function which will take some basic parameters and generate this for us. In this tutorial I will show how we can write a function inside a common utility class which will take a necessary parameters and generate a CSV file output.

Working with workbench and building packages in Laravel 4

Posted on 2 Aug 2014 by Amitav Roy

I come from the world of Drupal where every code that we write is part of a module. This is very useful because over time I am able to develop modules which I can re-use in all of my projects. Codeigniter has this feature using HMVC which I showed in the tutorialHMVS architecture with Codeigniter. The same approach can be followed in Laravel 4 using workbench to create packages. This way we can make an independent piece of code (or some dependent on other modules) and once we plug it in, the module is ready to do what it is supposed to do. In this tutorial I will start with a blog module which will be independent; it will have its own migrations, controllers, models, views and its own routes.

Laravel 4 Swift Mailer with dynamic config to send mail through Gmail

Posted on 17 Jun 2014 by Amitav Roy

Laravel 4 comes with the Swift Mailer library which works great in sending emails from your application. Just set the mail.php configuration file with the required variables and you are good to send emails. Inline images, attachment are like one line code. But the problem with a config file is that the parameters are fixed. I had a requirement where user would send email using their Gmail username and password. So, in this tutorial I will show you how to create a Swift Mailer instance and send a mail with a dynamic username, password and other parameters.

Laravel 4 forms, retain data, default and custom validations

Posted on 14 Jun 2014 by Amitav Roy

Working with forms in Laravel 4 is really fun and there is hardly any PHP application which doesn’t have a form. So, in this tutorial, I will demonstrate how to create a simple registration form using the Laravel’s form library. Then we will validate the data when the form is submitted. We will use the validation library which comes with Laravel 4 out of the box and also our custom validation rule.

Laravel 4 Multiple segment route and Blog post page

Posted on 15 Feb 2014 by Amitav Roy

In this tutorial, I will show how we would define a route with multiple segments in Laravel 4 so that we can use the URL alias of a Drupal node and then take the user to the individual node’s page. Also, we will see how we can override a view section’s content to set the page title to the blog’s title inside the head tag.

Laravel 4 Debug bar and Caching

Posted on 30 Jan 2014 by Amitav Roy

Caching of data is very important for any application and if we can save SQL queries, then it is always a bonus. In my last tutorial, I created the node object which was fetching its data from multiple tables and in different queries. In this tutorial I will cache the node object and save the SQL queries.

Working with XML in Angular JS

Posted on 4 Aug 2013 by Amitav Roy

In this tutorial I will show you how to use the X2JS javascript library to parse XML and turn that into an AngularJS object. This is one of my RND project where I am using XML files along with HTML to create an e-learning shell.