How to get last inserted id in Laravel

In this post, I would like to show the different ways to get last inserted ID from the database table when working with Laravel PHP Framework. In the core PHP, we will get last inserted ID with mysqli_insert_id() or PDO::lastInsertId() […]

Multiple Route files in Laravel 5

For small-scale applications single route file is sufficient but large-scale applications its cumbersome to maintain and organize the routes. The solution for this was creating multiple route files. For example, if you […]

Laravel 5 – SHA1 encryption instead of BCrypt

Recently I have migrated core PHP application to the Laravel5 framework. The old application used SHA1 encryption so I have implemented Hashing contracts of laravel5 to use SHA1 instead of BCrypt. Create Directories in […]

Laravel 5 – Prevent Browser back button after Logout

In this post, I would like to share a simple Laravel5 Middleware which prevents going back to the previous protected page after Logout by hitting the back button on your Browser. When you hit the browser back button after […]

How to add custom class in Laravel 5

In this tutorial, I will show you how to add a custom PHP class in Laravel 5.x application. For example, Lets call our class Common.php. Create a directory called Mylibs in app directory along with your class, Ex: Common.php. […]

Laravel 5 get current authenticated user?

Upon successful login you can get current user details by called Auth::user() method. It will return null if no user logged in or there is no current user. On successful login Auth::user() return value is based on your […]

How to redirect requests to HTTPS in Laravel 5

I know we can achieve same with other methods but I am going do it with the Laravel’s Middleware. So let’s create Middleware called ForceHttpProtocol. How it will work Our ForceHttpProtocol middleware will […]

How to install Laravel 5

In this post, I am going to share Laravel installation steps. We Can install Laravel by using composer and Laravel installer. Laravel Installer is a new feature which is introduced in Laravel 4.1, which can create a project […]

Laravel 5 Eloquent – Attribute casting

One of the Laravel 5 awesome feature is Attribute casting. Casting attribute means changing the attribute values to a particular type. for example Boolean, integer, strings. Eloquent models allows you to change datatype […]

Where NOT in Eloquent join Relation

Here is the simple laravel’s eloquent code snippet to get results in a table when there are no results for the relationship. I have two tables called users and accounts. each account belong to one user ,some users […]

DMCA.com Protection Status