Tasks we solve with the help of Laravel

Tasks we solve with the help of Laravel

Using an example from the GetPolis car insurance selection service

In brief

  • 01
    Kind of tool

    Laravel PHP framework

  • 02
    Where it’s used

    Car insurance selection service GetPolis

  • 03
    Reason to use Laravel

    Reduces routine operations: speeds up code writing and implementation of new functionality

    Due to its queuing mechanism it doesn’t lose speed

    It’s easy to search and correct errors in code thanks to its channel logging system

    Ensures security: protects passwords with mechanisms for authentication

  • 04
    Results

    16,000 personal accounts in the system

    Over 100,000 policies sold per year

    1,600 policies sold per day

The GetPolis service selects a CASCO for free, reminds the user regarding the policy purchase, and allows for the creation of an agent network

GetPolis is a service for selecting auto insurance policies: it compares prices for MTPL and comprehensive car insurance and offers the customer the best price option. The policy selection is free. The service earns money from commissions from the insurance companies involved.

The service has two types of users: ordinary buyers from the Internet and agents. Agents are intermediaries who choose policies from the service and sell it to their clients.

Service functions:

  • Policy selection: comparison of prices from different insurance companies, analysis of input data from the buyer, accounting for discounts and promotions.
  • Automatic mailing of reminder letters regarding policy purchase.
  • Ability to send inquiries to traffic police.
  • Ability to create an agent network: add employees, assign commission payments to them.

A full set of functions for the service is available from any device due to the adaptive layout of the site. There is no mobile application for the service as of yet.

Service shows the current cost of policies from insurance companies. It is connected to their platforms by API.

Tasks we solve with the help of Laravel

The client gave us the project after another contractor failed in carrying out the development. In order to launch the service faster, we decided not to reinvent the code base from scratch, but to refine it.

The Laravel framework was used in the development. Following are the tasks we solved with its help.

Fast creation of new entities: user personal accounts, order pages. The framework optimizes the writing of new routes: mapping program code and URLs.

This is what the example code for creating a route to get data looks like. When you access the specified site address, controller functions will be called that will perform operations and return either data or a web page with markup in response:

High speed of the service. The service is able to perform two tasks simultaneously and doesn’t slow down a user’s work with the site. For example, it can update car directories and send notifications while the user is arranging insurance.

This is possible thanks to a queuing mechanism: the framework allows you to split tasks into several parts, isolate them from each other, and run them in parallel.

Real-time data update. Users will see the policy in their personal account as soon as they pay the insurance company. If we don’t receive a policy from an insurance company right away, we use the «task scheduler» function to poll insurance companies for the availability of a ready-made policy. As a rule, the document appears in your personal account within half an hour.

To check the availability of a policy, we can write such a task in the Kernel. php file:

The cron format specifies the interval at which the specified command is to be invoked. There is no need to write tasks at the operating system level: the framework organizes everything itself.

It’s convenient to find and fix bugs. Laravel is able to separate bugs by type, so it’s easier to find and fix them. The framework uses a channel-based logging system: you can use different channels to store logs from different parts of the system. For logging you can use different types of output, for example, you can output the logs to individual files on disk or output them to Slack, or to some other service.

Logging channels are configured in the config/logging.php file as follows:

Here we have described two channels whose messages will be stored for 30 days in the logs folder, broken down by day.

The entries in the orders channel will look like this:

Storing data in the cloud. When we ran out of server space, we moved the data to the cloud — we use cloud object storage with Amazon S3 support. To do this we took an off-the-shelf library from Amazon, the AWS SDK for PHP.

It’s not specific to Laravel, but it’s very easy to integrate into our code.

All you need to do is initialize the client in the repository class and then use the API methods.

Initialization:

This is how to get an object from the repository:

And this is how to send an object to the repository:

The $localPath parameter here is for convenience and shows in what form we’re sending the data to the repository.

Email newsletter through Mailchimp. The service reminds users by email that it’s time to buy insurance. As the number of active agents grew, we ran into problems with email sending limits, as Yandex doesn’t allow for mass mailings of more than 500 messages per day, or more than 50 recipients at a time.

We decided to use a mailing service. We chose Mailchimp, because it’s a handy and thoroughly-tested tool, which also allows for the viewing of statistics: how many people read the letter, who clicked on the links from it, etc.

We used the spatie/laravel-newsletter library to connect the newsletters. When you install it, you create a config/newsletter.php file in the project. It contains the details for connecting to the Mailchimp service.

Then in the code we get a client to call the service:

In order to create a new mailing campaign, you have to do the following:

In response, the campaign creation function returns the ID that we use when we run the campaign:

You can add users to the mailing list through the API, or via Mailchimp’s personal account interface.

Data is protected from theft and copying. Laravel has automatic application security measures in place:

  • Stored passwords: they are encoded so that even the site developer can’t see the user’s password in plaintext.
  • Authentication mechanisms are built in: for example, you can plug in an off-the-shelf function to remember the user.
  • The Eloquent ORM utility protects against hacking through forms on the site.

There’s protection against cross-site request forgery, connected with a couple lines of code:

Work results using Laravel: We launched the service in just 10 months

OrbitSoft started working on the project in 2019 and launched it in just 10 months. Now the service works, we continue to support it, and we working on the creation of a mobile application.

The service immediately worked with both agents and regular users. There are two personal accounts with different sets of functions: the service offers businesses several models for making money.

It works on any device. The service has no mobile application, but thanks to the adaptive layout the site is easy to use not only on a computer but also on a tablet or cell phone.

Easy integration with any insurance company platforms. The customer can negotiate cooperation with new partners, and easily connect to them via API and earn more.

Ability to create an agent network and settle accounts with employees. The personal account allows agents to build a business, organize their work, and earn more.

10,000 personal accounts of ordinary users10,000 policies bought by regular customers1,600 policies sold per day
6,000 personal accounts of insurance agents90,000 policies sold by agents

Technical unit

  • PHP 7.3
  • Laravel 5.7.29
  • Vue.js 2.6

Programming languages:

  • PHP
  • JS

Libraries

PHP:

JS:

  • Vuetify
  • JQuery
  • Bootstrap
  • Axios
  • Bootstrap
  • Lodash

Whatever your needs, we can help!

Tell us what problems you’re facing with your business. We look forward to hearing from you.

Получите ответ по смс

Ваше сообщение успешно отправлено!
Представьтесь пожалуйста
Укажите номер, на который придет ответ
Нажимая на кнопку, вы даете согласие
на обработку персональных данных.