152
Php

Laravel – Using Repository Pattern

Laravel is one of the most popular PHP MVC frameworks and taking the Php community rapidly than any other frameworks probably couldn’t do and it’s because of a great combination of power, extensibility and easiness. The framework provides so many ways to a developer to develop an application using one or another, depending on the […]

9
Php

Laravel – Useful RenderSections Method In View

In Laravel PHP MVC Framework, to send content back to the browser one must use a return keyword from a controller with the rendered content, like: return View::make(‘home.index’); This is a very simple example and very common in any Laravel application and any developer knows what is this code for, obviously any developer means a […]

4
Php

Laravel – Route Matched Event

In Laravel there is a nice way to listen for many events, built-in and custom events, simply using code like this: Event::listen(‘event_name’, function($object) { }); We can register event listeners. In Laravel documentation on their website, mentioned about Application Events and also about Custom Events (defined by user). There are also some special events available […]

29
Php

Laravel – Model Relationship to Itself

Laravel provides a nice and easy way to build model relationship using some methods like hasOne(), hasMany(), belongsTo() and belongsToMany() and each one of these methods are used for different kinds of relationships, for example, hasOne() used for one to one relationship and hasMany() for one to many and so on. These methods let use […]

2
Php

Laravel – Manually Invalidate A Validation

Laravel provides a nice extensible and easy validation class to validate user inputs but Sometimes we may need to forcefully invalidate a passed validation. For example, a few days ago I realized that in one of my projects. I had a table with fields group_name and name along with other fields and when inserting data […]

16
Php

Extend Laravel Eloquent Collection Object

According to Laravel, all multi-result sets returned by Eloquent, either via the get method or a relationship, will return a collection object. This object implements the IteratorAggregate PHP interface so it can be iterated over like an array. However, this object also has a variety of other helpful methods for working with result sets. For […]

4
Php

Extend Input Class in Laravel – 4

There is no Input class in Laravel, instead it uses Request class for any Input::method() calls. Basically, we extend a class in OOP language to add some extra functionalities to a base (already created) class and in PHP, for example, if you have following class class BaseClass { public function hello() { echo “Say Hello!”; […]

7
Php

Advanced Date Queries in WordPress – 3.7

On October 24, 2013, WordPress Version 3.7, named for Count Basie, was released. It has some cool new features and one of those is that, developers can now query for posts within a date range, or that are older than or newer than a specific point in time using date_query . For example, to get […]