Tag Archives: Laravel Tutorials
Laravel Join 3 Tables
Laravel Join 3 Tables: Joining more than two tables is very common in any framework, we often need to join 3 or more then three table in Laravel. Here in this tutorial we are going to explain how you can join three tables or more than three tables in Laravel.
Laravel Join 3 Tables Example | Join Multiple Tables
It is very simple to join 3 tables in Laravel. Let us create an example to join 3 table –
Laravel Join 3 Tables Example:
$orderList = DB::table('users') ->join('orders', 'users.id', '=', 'orders.user_id') ->join('order_items', 'orders.id', '=', 'order_items.orders_id') ->where('users.id', '=', 5) ->get(); |
The above example will join the three tables – users, orders and order_items on the basis of the foreign keys. You can join multiple tables on the same ways to get the data from different-different tables.
Laravel Check Duplicate Records
Laravel Check Duplicate Records: We often need to check duplicate records when working with database table records. It is very simple to check the duplicate records in Laravel. Here in this tutorial we are going to explain how you can Check duplicate Records in Laravel.
Laravel Check Duplicate Records Example | Laravel check if user exists
Here we have checked that the given email exists in the database table or not. You can simply check the duplicate records in Laravel simply as below-
Laravel Check Duplicate Records Query Example:
first(); if ($userExists === null) { // User Not Found Your Stuffs Goes Here.. } ?> |
The above example will check the given email exists in the database table or not it does not exists then it will return null, Using this response you do other stuffs.
Laravel get Session ID
Laravel get Session ID : Laravel session ID depends upon the version of the Laravel, Here in this tutorial we are going to explain how you can get Session ID in Laravel. We are going to explain how to get Session Id in Different versions of Laravel.
Laravel get Session ID Example
You can get the session Id in different versions of laravel as –
Laravel 3
You can get the Session ID in Laravel 3 simply as below –
Laravel get Session ID Example:
$sessionID = $_COOKIE['laravel_session']; |
Laravel 4.0
You can get the Session ID in Laravel 4.0 simply as below –
Laravel get Session ID Example:
$sessionID = session_id(); |
Laravel 4.1 & Onwards | Laravel 5
You can get the Session ID in Laravel 4.1 and onwards version simply as below –
Laravel get Session ID Example:
$sessionID = Session::getId(); |
Set Headers in Laravel
Set Headers in Laravel: There are many ways you can set headers in Laravel. You can set header directly in view or you can use before filter to bind headers in All views. Here in this tutorial we are going to explain how you can set headers in Laravel.
How to Set Headers in Laravel Example
You can add the headers in your view file directly, here in an example of setting headers in view file –
Set Headers in Laravel Example:
// Outputting a PDF header('Content-Type: application/pdf'); // It will be called my_download.pdf header('Content-Disposition: attachment; filename="my_download.pdf"'); // The PDF source is in original.pdf readfile('my_download.pdf'); |
You can set other headers on the same way in Laravel.
Install laravel 5 on windows Xampp or Wamp
Install laravel 5 on windows Xampp or Wamp It is very simple to install laravel On windows Xampp. Here in this tutorial we are going to explain how you can install Laravel 5 on windows.
Steps to Install laravel 5 on windows Xampp or Wamp
You can install laravel 5 on windows by following the steps given below –
1. First you need to Download laravel 5 from https://github.com/laravel/laravel
2. After completion of download Unzip it in folder[xampp\htdocs\laravel or wampp\www\laravel] named as : laravel Which Will Look Like
3.Now download Composer-Setup.exe from https://getcomposer.org/download/ And Install it.
4. After Successful installation of composer right click on laravel folder go to > Use Composer Here . When You click on it a terminal will be opened. Type the below command :
Command to Install Laravel 5.4
composer create-project --prefer-dist laravel/laravel test-laravel-5-project
Command to Install Laravel Lower Versio(< 5.4)
If you want to install lower version run the below command-
composer create-project laravel/laravel test-laravel-5-project –prefer-dist
5. Wait For a minute while your project is being installed……
6.After Successful installation you will see successful message at the end of terminal.
7. Now You can access your first project as :
http://localhost/laravel/test-laravel-5-project/public/
Which will look like with welcome page.