Why use Redis?

Redis is a key-value data store. It’s a “NoSQL” key-value data store. More precisely, it is a data structure server.

Not like MongoDB (which is a disk-based document store), though MongoDB could be used for similar key/value use cases.
The closest analog is probably to think of Redis as Memcached, but with built-in persistence (snapshotting or journaling to disk) and more datatypes.

Redis is a good if you want a highly scalable data store shared by multiple processes, multiple applications, or multiple servers. As just an inter-process communication mechanism it is tough to beat. Its speed also makes it great as a caching layer.

Below are some of the most common Redis use cases –
1. Session Cache
2. Full Page Cache (FPC)
3. Queues

Pros of Redis:
• It’s blazing fast
• it supports a wide variety of data types
• it’s open source and has an active community
• it’s simple to install and has no dependencies
• stores generic data types for any purpose
• easy to get started on a single cheap/free server

Cons of Redis:
• your dataset has to fit comfortably in memory
• no joins or query language
• you have to learn lua if you want something like stored procedures

The following link is superb to learn the basics of redis

How to Set Timezone in Laravel 5.1

Set Timezone in Laravel 5.1
We can set timezone in config file config/app.php at below section.
You have to set a timezone supported by PHP. An overview about available timezones can be find here: http://php.net/manual/en/timezones.php

| Application Timezone
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
//  Default value of timezone is ‘UTC’,
‘timezone’ => ‘UTC’,

// I have changed it to ‘Asia/Kolkata’ because i need indian timezone.

‘timezone’  => ‘Asia/Kolkata’,

how Use Laravel Auth middleware


If you want set any middleware in larave you need to change kernel.php file which is located in app/http folder
In Kernel.php – you can set middleware like this:

* The application’s route middleware.
* @var array
protected $routeMiddleware = [
‘auth’ => ‘App\Http\Middleware\Authenticate’,
‘auth.basic’ => ‘Illuminate\Auth\Middleware\AuthenticateWithBasicAuth’,
‘guest’ => ‘App\Http\Middleware\RedirectIfAuthenticated’,

‘admin’ => \App\Http\Middleware\Admin::class,
‘guestadmin’ => ‘App\Http\Middleware\RedirectIfAuthenticated’,

If you want to create Admin middleware you need to create Admin.php in middleware folder which in located in app folder.
Create admin and copy code below:-
return redirect()->route(‘admin.login’);

return $next($request);


Define ROutes in route file
| Application Routes for BackEnd
Route::group([‘namespace’ => ‘BackEnd’, ‘prefix’ => ‘admin’], function() {
#Access only guest users
Route::group([‘middleware’ => [‘adminguest’]], function(){
Route::get(‘/login’, [
‘as’ => ‘admin.login’,
‘uses’ => ‘AdminController@getSignin’
Route::post(‘/login’, [
‘as’ => ‘admin.login’,
‘uses’ => ‘AdminController@postSignin’
Route::post(‘/logout’, [
‘as’ => ‘admin.logout’,
‘uses’ => ‘AdminController@getLogout’

#Access only login users
Route::group([‘middleware’ => [‘admin’]], function(){
Route::get(‘/’, [
‘as’ => ‘admin.index’, function () {
$title = “Dashboard”;
return view(‘BackEnd.dashboard’, compact(‘title’));



Now you are able to acess http://example.com/admin

Write your login code in Admin Controller

Show queries in laravel


Laravel provides a database query builder. To see the query use toSql() in laravel.


$result = DB::table(‘users’)
->where(‘username’, ‘like’, ‘%admin%’)
->toSql() // to see the query which is executed
//  ->get()->toArray();  to get results

Laravel update record

Use Query Builder to update records, This is a sample:

Or Use another method to load DB