Laravel Accessors and Mutators

Laravel accessors and mutators are custom, user defined methods that allow you to format Eloquent attributes. Accessors are used to format attributes when you retrieve them from the database, while mutators format the attributes before saving them to the database.

Continue reading Laravel Accessors and Mutators

Using Repository Pattern In Laravel 5 – Eloquent Relations And Eager Loading

Preface

Before we go to the main topic of the article, I’ll give you a short heads up for some design problems you may face. Recently one of my clients complained that some pages open very slowly. When I say very, I mean incredibly slow. So I’ve decided to debug that page and what I saw shocked me. Query section was showing that on that page was executed an staggering 16500+ queries !!

Continue reading Using Repository Pattern In Laravel 5 – Eloquent Relations And Eager Loading

Using Repository Pattern in Laravel 5

These days there is a lot of buzz about software design patterns, and one of the most frequently asked questions is “How can I use some pattern with some technology“. In the case of Laravel and the Repository pattern, I see often questions like “How I can use repository pattern in Laravel 4” or nowadays “..in Laravel 5”. Important thing you must remember is that design patterns do not depend on specific technology, framework or programming language.

Continue reading Using Repository Pattern in Laravel 5

Laravel Validation: Comprehensive Guide, part 1

Introduction

In this tutorial I’ll cover different ways you can validate your data in Laravel 4. Almost every interactive web application requires some kind of data validation. For example, if your web application have registration form, you want email field to be unique or require from users to confirm their password. Laravel already has many standard rules to use within your validator, but if you don’t find one that meets your requirements at any time you can create your own rule.

There is a many ways how you can implement validation and I think the most common and the easiest way is to validate data directly in your controller. But, before we start validating our data let’s configure database and create migration for our  users table.

Continue reading Laravel Validation: Comprehensive Guide, part 1

A Brief Introduction to Laravel Envoy

Laravel Envoy provides you a simple and elegant way to run common tasks on your remote servers. If you have ever used Fabric, Capistrano or other tools for managing remote tasks, you already have an idea how Envoy tasks will look like.

Laravel Envoy Installation

To install Laravel Envoy simply run:

after that, make sure ~/.composer/vendor/bin/envoy  is flagged as executable:

Continue reading A Brief Introduction to Laravel Envoy