Tag Archives: laravel online course
Laravel delete all records from table
DB::table(‘table_name’)->delete(); is used to delete All records from table in laravel.
Syntax : Laravel delete all records from table example
Below is the simple example for Laravel delete all records from table
DB::table('users')->delete();
Will delete all records from table.
Laravel delete query example
DB::table(‘table_name’)->where(‘column_name’, ‘=’, value)->delete(); is used to delete records from table in laravel.
Laravel delete query example with Syntax
Below is the simple Laravel Delete query Example
DB::table('users')->where('id', '=', 66)->delete();
Will delete the record where id is 66.
Laravel join query example
DB::table(‘table_name’)->join(‘condition’)->select(‘column_names’)->get(); is used for join in laravel.
Laravel join query example
DB::table('users') ->join('city','city.user_id','=','users.id') ->select('users.name','city.city_name') ->get();
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.
Install Laravel on Windows using laravel installer
You can simply use laragon to install laravel on windows.
Simple and easy Steps to Install Laravel on Windows using laravel installer
- Download laragon from http://laragon.org/
- Install on windows [run the setup laragon-0.6-setup.exe]
- After Sucessfull installation – Start all services and you will see dialog box like this
- Now right click on dialog box
- Now go to > laravel > create project > Laravel 5 >.
Now click on Laravel 5 it will show prompt asking to enter project name enter “laravel” ->
- Afer entering project name you will see cmd which will take few minutes to install the laravel .After finishing installation you will see like this-
- Now you can access your project by accessing the url http://laravel.dev or you can access normally http://localhost/laravel/public
- Now you will see you first project
- For managing application go to : Lamp_path \lamp\www\laravel for example i have installed lamb in G: drive for me application directory is G:\lamp\www\laravel
Laravel inserting multiple records in table
You can insert multiple records into table at a time in laravel.
Syntax for laravel inserting multiple records in table
DB::table('table_name')->insert(array('data_array1','data_array2'....));
Laravel inserting multiple records in table Example
DB::table('users')->insert(array( array("id"=>'1',"name"=>"john","email"=>"john@testgmail.com"), array("id"=>'2',"name"=>"Jimmi","email"=>"jimmn@testgmail.com"), array("id"=>'3',"name"=>"Kelly","email"=>"kelly@testgmail.com"), array("id"=>'4',"name"=>"Mike","email"=>"mike@testgmail.com"), array("id"=>'5',"name"=>"Steve","email"=>"steve@testgmail.com"), );
or You can also use this :
$data1 = array("id"=>'1',"name"=>"john","email"=>"john@testgmail.com"); $data2 = array("id"=>'2',"name"=>"Jimmi","email"=>"jimmn@testgmail.com"); $data3 = array("id"=>'3',"name"=>"Kelly","email"=>"kelly@testgmail.com"); $data4 = array("id"=>'4',"name"=>"Mike","email"=>"mike@testgmail.com"); $data5 = array("id"=>'5',"name"=>"Steve","email"=>"steve@testgmail.com"); DB::table('users')->insert(array($data1,$data2,$data3,$data4,$data5,));
Laravel insert query
Laravel insert query : Laravel Insert Records Into A Table
Syntax for laravel insert Query
DB::table('table_name')->insert('data_array');
Laravel insert Query Example
DB::table('users')->insert(array("id"=>$uid,"name"=>$name,"email"=>$email));
or You can also use this :
$data = array("id"=>$uid,"name"=>$name,"email"=>$email); DB::table('users')->insert($data);