Latest Blogs

Learn about my progress!

Collations in MySQL and Laravel Database Settings

A collation is a set of rules that defines how to compare and sort character strings. Each collation in MySQL belongs to a single character set. Every character set has at least one collation, and most have two or more collations. A collation orders characters based on weights. Each character in a character set maps to a weight. Characters with equal weights compare as equal, and characters wit...

Eager Loading in Laravel

When accessing Eloquent relationships as properties, the relationship data is "lazy loaded". This means the relationship data is not actually loaded until you first access the property. However, Eloquent can "eager load" relationships at the time you query the parent model. Eager loading alleviates the N + 1 query problem. To illustrate the N + 1 query problem, consider a Book ...

Components in Angular2

Components are a logical piece of code for Angular JS application. A Component consists of the following − Template − This is used to render the view for the application. This contains the HTML that needs to be rendered in the application. This part also includes the binding and directives. Class − This is like a class defined in any language such as C....

Many To Many Relationships Laravel

Attaching / Detaching Eloquent also provides a few additional helper methods to make working with related models more convenient. For example, let's imagine a user can have many roles and a role can have many users. To attach a role to a user by inserting a record in the intermediate table that joins the models, use the attach() method: $user = App\User::find(1); $user->roles()-&...

ACID Properties

ACID properties are an important concept for databases. The acronym stands for Atomicity, Consistency, Isolation, and Durability. The ACID properties of a DBMS allow safe sharing of data. Without these ACID properties, everyday occurrences such using computer systems to buy products would be difficult and the potential for inaccuracy would be huge. Imagine more than one person trying to buy the...

Making Validation Trait in Laravel

In PHP we use Traits for code reusibility. If we have to make same functions in different classes we can simply make a trait and use it in different classes. In Laravel Validation is an important part which we have to make in models and we have to do validations in objects. So we can make a ValidationTrait.php file in app\Traits folder and write the following codes. <?php namespace...

Stripe Integration in Laravel

Stripe is a US technology company, operating in over 25 countries, that allows both private individuals and businesses to accept payments over the Internet. For integrating Stripe in Laravel, first add the Cashier package for Stripe to your composer.json file and run the composer update command: "laravel/cashier": "~7.0" Next, register the&nb...

CSRF Protection in Laravel

Laravel makes it easy to protect your application from cross-site request forgery (CSRF) attacks. Cross-site request forgeries are a type of malicious exploit whereby unauthorized commands are performed on behalf of an authenticated user. Laravel automatically generates a CSRF "token" for each active user session managed by the application. This token is used to verify that ...

Resourceful Controllers in Laravel

Resource Controllers Laravel resource routing assigns the typical "CRUD" routes to a controller with a single line of code. For example, you may wish to create a controller that handles all HTTP requests for "photos" stored by your application. Using the make:controller Artisan command, we can quickly create such a controller: php artisan make:controller PhotoController...

Multiple Inheritance in PHP

Multiple Inheritance is a feature of Object Oriented Programming which inherits features from more than one object or class. We use Interfaces to implement them in more than one class.  interface I1 { public function fun1(); public function fun2(); } interface I2 { public function fun3(); public function fun4(); } class A { public function fun1(){ //do s...