Saturday, June 4, 2016

How to Download Instagram Photo? | How do I download Instagram Photo from PC?


Many of us want to download Instagram photo but don't know how to download photo from it. Some of you might have used downloader to download those photos. But it's very to download photo from Instagram from PC and you don't need to install any software also. Let's start..

1.  First login to your Instagram  Account. After login you will see your news feed like following screen.



2. Now press Ctrl+Shift+I (Inspect Element from browser right click)  in your logged in webpage. And it will open console like the following screen.





3. Now click on  Resource -> Frame (see the left corner) -> choose www.instagram.com  -> Images. ( For Instruction : See the following Image)



4. A list of images you will see in these images folder. Now select the image you want to download. Right click on it and select Open image in new tab. and the real image with full width and height will be loaded in next tab. 



5. Now in new tab you will see the image what you selected recently and right click on it and select Save image as and it will automatically download the image. 




That's it. See how easily you can download now Instagram images from your PC.

Stay connected. See you in next tutorial. Thank you!





Friday, June 3, 2016

How to Make a PDF from View in Laravel? | How to generate pdf using blade view with dompdf in laravel?


laravel pdf download


In this session we gonna a make a very cool thing. Sometimes we need to generate Pdf for creating report or to show data into document . So today we are gonna convert a static view page to pdf using Laravel.

Let's start!

1. In the first process we gonna install a package called /laravel-dompdf
It's very easy to install in your project. Just go through the doc and have installed it.
If you can't install in your project, Just ping me in comment.

2. Then create a route in Route.php

Route::get('/pdf', [
       'uses' => 'courseController@createPdf',
        'as' => 'pdf'
    ]);

3. Then create a Controller :

public function createPdf()
{
        $alldata=Course::all(); // it'll load all the data from course model.
        $pdf = \PDF::loadView(
'invoice', compact('alldata'))->setPaper('a4')->setOrientation('portrait');
return $pdf->download('invoice.pdf');       
}

And don't forget to use namespace above the the controller otherwise it will show Error.

namespace we have to use:

use Barryvdh\DomPDF\Facade as PDF;

4. In controller you save seen that in that loadView('invoice')  (It's actually a view page which will generate the PDF). So we have to create first this view page where we can show all the data what a user wanted to see.

5. That's it so when the user click on that pdf route, it will automatically generate/ convert the page into PDF.

That's it for today. Hope you liked it. If you want me to post more tutorial on laravel don't forget to comment or feedback.

Thank you.

Thursday, June 2, 2016

How to remove /public/ from URL in Laravel Project?






remove public from url


In this instructional exercise we will figure out how to remove public from laravel url.You can utilize this technique for laravel5.X+ and lower versions.By default, the URL which accompanies Laravel App will be this http://example.com/pubic/.So to get perfect URLs which are useful for SEO reason you should remove public from url in laravel application.

It's very easy for laravel 5+  .Just do the following process:

1. Rename the server.php in the your Laravel root folder to index.php


2. Copy the .htaccess file from /public directory to your Laravel root folder.

That's it. Just Reload the Project. You will see the project url without /public in it. 
Let's see with a demo video Tutorial.

 

Wednesday, June 1, 2016

PHP Laravel : How to logout a user from all devices using Redis?

laravel redis



Here is a common scenario like after password reset I/Admin want to logout the user from all device except the device which he logged in while password reset or suppose a user have logged in any many device and the admin want to logout from all of the devices for security purpose for certain reason.

In laravel we can finish the task very easy way using Redis. Lets solve the issue with the following steps.

1. First install the Predis package by composer:

In composer.json file add the following line and run update composer in your cmd.

"require": {
            ...... 
            "predis/predis": "~1.0" ,
            ...... },


2. Create a Session table in database using the following commands:

php artisan session:table
composer dump-autoload 
php artisan migrate

3. Then Download Redis in your PC from the below link and install it in your C:// drive in program files folder.


4. After Redis installed run redis-server.exe file means your server is ready. Now if you run your application.

5. Don't forget to change your .env setting for following driver :

CACHE_DRIVER=redis
SESSION_DRIVER=redis


5. Here is a sample controller code I have shared for logged in using Redis as well as logged out.


public function postSignIn(Request $request)
 { 
     if (Auth::attempt(['email' => $request['email'], 'password' =>$request['password'] ]) ) { 
    //for save session ID I use (when user login )
     $redis = \Redis::connection(); 
     $userId = Auth::user()->id;
     $redis->sadd('users:sessions:' . $userId,Session::getId()); 
     return redirect()->route('main');
   }
  return redirect()->back();
 }

 public function getLogout()
 {
   $redis = \Redis::connection();
   $userId=Auth::user()->id;
   //get all session IDs for user
   $userSessions = $redis->smembers('users:sessions:' . $userId);
   $currentSession = Session::getId();
   //for logout from all devices use loop
     foreach ($userSessions as $sessionId) {
       if ($currentSession == $sessionId) {
       continue; 
     }
   //for remove sessions ID from array of user sessions (if user logout or manually logout )
   $redis->srem('users:sessions:' . $userId, $sessionId);
   //remove Laravel session (logout user from other device)
   $redis->del('laravel:' . $sessionId);
 
   }
  Auth::logout();
  return redirect()->route('main');
 }
6. That's it! When a user logged out from a particular device it will automatically kill all the sessions and logged out from other device also.

How to Add a CkEditor in Laravel Project?

laravel ckeditor



Many of you have asked how can I add a CKEditor in my Laravel Project. So Here is the Very simple solution for that. Let's start.
About CKeditor:

CKEditor (in the past FCKeditor) is an open source WYSIWYG word processor intended to convey basic word processor includes specifically to website pages, disentangling their substance creation. Its center code is composed in JavaScript.

1. First in your view page such as index.blade.php write the textarea where you want to show the CKEditor or form for taking input. Make sure you keep an Id in it so that we can catch it with JavaScript Code:

<textarea id="article-ckeditor" class="form-control" name="description" rows="3"></textarea>

2. Now use the below JavaScript code for catching that Id "article-ckeditor" before the closing tag.

<script src="//cdn.ckeditor.com/4.5.7/standard/ckeditor.js"></script>

 <script>
      CKEDITOR.replace( 'article-ckeditor' ); 
 </script> 

 3. That's it. So if you load the page you will see the CKEditor will appear Instantly in your web page.

That's it for today. Hope you Like the article. Make Sure you Share it.