SlideShare a Scribd company logo
1 Author : Vikas Chauhan
Presented By:
Vikas Chauhan
Software Engineer,
BrainCoerce
Technologies, Bangalore
Date – 08/18/2013
2 Author : Vikas Chauhan
 Exercise 1 :- Migration & Artisan
 Exercise 2 :- Database Setup
 Exercise 3 :- Create Table Using Migration & Artisan
 Exercise 4 :- Add Data Into Table Using Migration &
Artisan
3 Author : Vikas Chauhan
Exercise 1
Migration & Artisan
4 Author : Vikas Chauhan
Artisan :- Artisan is the name of the command-line interface included with
Laravel. It provides a number of helpful commands.
 To view all available Artisan commends type “<project_dir>/ php artisan list “
on your command line.
Migration :- Migrations are a type of version control for your database.
 It allows me to create my tables easily, without writing a single line of
database language for example :- mysql etc.
 Before install migration in your project you need to be configure your
database file.
5 Author : Vikas Chauhan
Exercise 2
Database Setup
6 Author : Vikas Chauhan
 <project_dir>/app/ config / database.php :-
7 Author : Vikas Chauhan
Exercise 3
Create Table Using Migration & Artisan
8 Author : Vikas Chauhan
 On command line :- “php artisan migrate: install” (migration table should be
add in you database)
 On command line :- “php artisan migrate: make create_authors_table” (create a
authors table into database)
 <project_dir>/ app/ database/ migration
/2013_08_07_101708_create_authors_table.php :-
That php file contain two
function up() & down(). up() function is used for create table and down() function
is used for destroy table and its data. For example :-
9 Author : Vikas Chauhan
class CreateAuthorsTable extends Migration
{
public function up()
{
Schema::create('authors', function($table){
$table->increments('id');
$table->string('name');
$table-> text('bio');
$table->timestamps();
});
}
public function down()
{
Schema::drop('authors');
}
}
10 Author : Vikas Chauhan
 On command line :- “php artisan migrate” (for perform action on up function)
 On command line :- “php artisan migrate: rollback” (for perform action on down
function)
 If you will see fatal error while you rollback the migration :-
on command line :- “var/local/bin/composer.phar dump-autolode” for ubuntu
in your case “<composer_dir>/composer.phar dump-auto lode
 On command line :- php artisan migrate:reset (for reset all migration)
11 Author : Vikas Chauhan
Exercise4
Add Data Into Table Using
Migration & Artisan
12 Author : Vikas Chauhan
 On command line :- php artisan migrate: make add_authors (create a file in
migration for add data in authors table)
 <project_dir>/ app/ database/ migration/
2013_08_07_102350_add_authors.php :-
That php file contain two function up()
& down(). up() function is used for add data into table and down() function is
used for delete data from table. For example :-
13 Author : Vikas Chauhan
class AddAuthors extends Migration
{
public function up() {
DB::table('authors')->insert(array(
'name'=>'vikas chauhan',
'bio'=>'vikas chauhan is a good developer',
'created_at'=>date('y-m-d H:m:s'),
'updated_at'=>date('y-m-d H:m:s')
));
}
public function down() {
DB::table('authors')->where('name','=','vikas chauhan')->delete();
}
}
14 Author : Vikas Chauhan
 On command line :- “php artisan migrate” (for perform action on up function)
 On command line :- “php artisan migrate: rollback” (for perform action on down
function)
 If you will see fatal error while you rollback the migration :-
on command line :- “var/local/bin/composer.phar dump-autolode” for ubuntu
in your case “<composer_dir>/composer.phar dump-auto lode
 On command line :- php artisan migrate:reset (for reset all migration)
15 Author : Vikas Chauhan
Thanks & Regards,
Contact to – Vikas Chauhan
Email ID – vikas.chauhan@braincoerce.com
Phone – (080) 41155974
Ad

Recommended

Laravel 101
Laravel 101
Commit University
 
Laravel for Web Artisans
Laravel for Web Artisans
Raf Kewl
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentials
Pramod Kadam
 
Laravel 5 In Depth
Laravel 5 In Depth
Kirk Bushell
 
Workshop Laravel 5.2
Workshop Laravel 5.2
Wahyu Rismawan
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.
SWAAM Tech
 
Intro to Laravel 4
Intro to Laravel 4
Singapore PHP User Group
 
Getting to know Laravel 5
Getting to know Laravel 5
Bukhori Aqid
 
Presentation laravel 5 4
Presentation laravel 5 4
Christen Gjølbye Christensen
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Javascript laravel's friend
Javascript laravel's friend
Bart Van Den Brande
 
Laravel Design Patterns
Laravel Design Patterns
Bobby Bouwmann
 
Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
Katy Slemon
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expert
Katy Slemon
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJS
Blake Newman
 
Web services with laravel
Web services with laravel
Confiz
 
Web service with Laravel
Web service with Laravel
Abuzer Firdousi
 
Laravel 5
Laravel 5
Sudip Simkhada
 
API Development with Laravel
API Development with Laravel
Michael Peacock
 
Flask
Flask
Mamta Kumari
 
Laravel 5
Laravel 5
Brian Feaver
 
Learn flask in 90mins
Learn flask in 90mins
Larry Cai
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
 
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
Brilo Team
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
Larry Cai
 
Hello World on Slim Framework 3.x
Hello World on Slim Framework 3.x
Ryan Szrama
 
Object Oriented Programming with Laravel - Session 6
Object Oriented Programming with Laravel - Session 6
Shahrzad Peyman
 
Phinx talk
Phinx talk
Michael Peacock
 

More Related Content

What's hot (20)

Presentation laravel 5 4
Presentation laravel 5 4
Christen Gjølbye Christensen
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Javascript laravel's friend
Javascript laravel's friend
Bart Van Den Brande
 
Laravel Design Patterns
Laravel Design Patterns
Bobby Bouwmann
 
Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
Katy Slemon
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expert
Katy Slemon
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJS
Blake Newman
 
Web services with laravel
Web services with laravel
Confiz
 
Web service with Laravel
Web service with Laravel
Abuzer Firdousi
 
Laravel 5
Laravel 5
Sudip Simkhada
 
API Development with Laravel
API Development with Laravel
Michael Peacock
 
Flask
Flask
Mamta Kumari
 
Laravel 5
Laravel 5
Brian Feaver
 
Learn flask in 90mins
Learn flask in 90mins
Larry Cai
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
 
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
Brilo Team
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
Larry Cai
 
Hello World on Slim Framework 3.x
Hello World on Slim Framework 3.x
Ryan Szrama
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
Elena Kolevska
 
Laravel Design Patterns
Laravel Design Patterns
Bobby Bouwmann
 
Task scheduling in laravel 8 tutorial
Task scheduling in laravel 8 tutorial
Katy Slemon
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expert
Katy Slemon
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
REST APIs in Laravel 101
REST APIs in Laravel 101
Samantha Geitz
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJS
Blake Newman
 
Web services with laravel
Web services with laravel
Confiz
 
Web service with Laravel
Web service with Laravel
Abuzer Firdousi
 
API Development with Laravel
API Development with Laravel
Michael Peacock
 
Learn flask in 90mins
Learn flask in 90mins
Larry Cai
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall
 
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
WP Weekend #2 - Corcel, aneb WordPress přes Laravel
Brilo Team
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
Larry Cai
 
Hello World on Slim Framework 3.x
Hello World on Slim Framework 3.x
Ryan Szrama
 

Similar to Laravel Beginners Tutorial 2 (11)

Object Oriented Programming with Laravel - Session 6
Object Oriented Programming with Laravel - Session 6
Shahrzad Peyman
 
Phinx talk
Phinx talk
Michael Peacock
 
Laravel
Laravel
biplob04
 
Laravel tips-2019-04
Laravel tips-2019-04
Fernando Andrés Pérez Alarcón
 
symfony Live 2010 - Using Doctrine Migrations
symfony Live 2010 - Using Doctrine Migrations
D
 
CRUD presentation of laravel application.pptx
CRUD presentation of laravel application.pptx
ShoukatRiaz
 
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
LimoenGroen
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Alan Pinstein
 
Migrating data into Drupal using the migrate module
Migrating data into Drupal using the migrate module
Johan Gant
 
Introduction to laravel framework
Introduction to laravel framework
Ahmad Fatoni
 
Laravel and artisan cli
Laravel and artisan cli
Sayed Ahmed
 
Object Oriented Programming with Laravel - Session 6
Object Oriented Programming with Laravel - Session 6
Shahrzad Peyman
 
symfony Live 2010 - Using Doctrine Migrations
symfony Live 2010 - Using Doctrine Migrations
D
 
CRUD presentation of laravel application.pptx
CRUD presentation of laravel application.pptx
ShoukatRiaz
 
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
The Myths, Musts and Migraines of Migrations - DrupalJam 2018
LimoenGroen
 
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Patterns and Tools for Database Versioning, Migration, Data Loading and Test ...
Alan Pinstein
 
Migrating data into Drupal using the migrate module
Migrating data into Drupal using the migrate module
Johan Gant
 
Introduction to laravel framework
Introduction to laravel framework
Ahmad Fatoni
 
Laravel and artisan cli
Laravel and artisan cli
Sayed Ahmed
 
Ad

Recently uploaded (20)

OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
" How to survive with 1 billion vectors and not sell a kidney: our low-cost c...
Fwdays
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
“MPU+: A Transformative Solution for Next-Gen AI at the Edge,” a Presentation...
Edge AI and Vision Alliance
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Ad

Laravel Beginners Tutorial 2

  • 1. 1 Author : Vikas Chauhan Presented By: Vikas Chauhan Software Engineer, BrainCoerce Technologies, Bangalore Date – 08/18/2013
  • 2. 2 Author : Vikas Chauhan  Exercise 1 :- Migration & Artisan  Exercise 2 :- Database Setup  Exercise 3 :- Create Table Using Migration & Artisan  Exercise 4 :- Add Data Into Table Using Migration & Artisan
  • 3. 3 Author : Vikas Chauhan Exercise 1 Migration & Artisan
  • 4. 4 Author : Vikas Chauhan Artisan :- Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands.  To view all available Artisan commends type “<project_dir>/ php artisan list “ on your command line. Migration :- Migrations are a type of version control for your database.  It allows me to create my tables easily, without writing a single line of database language for example :- mysql etc.  Before install migration in your project you need to be configure your database file.
  • 5. 5 Author : Vikas Chauhan Exercise 2 Database Setup
  • 6. 6 Author : Vikas Chauhan  <project_dir>/app/ config / database.php :-
  • 7. 7 Author : Vikas Chauhan Exercise 3 Create Table Using Migration & Artisan
  • 8. 8 Author : Vikas Chauhan  On command line :- “php artisan migrate: install” (migration table should be add in you database)  On command line :- “php artisan migrate: make create_authors_table” (create a authors table into database)  <project_dir>/ app/ database/ migration /2013_08_07_101708_create_authors_table.php :- That php file contain two function up() & down(). up() function is used for create table and down() function is used for destroy table and its data. For example :-
  • 9. 9 Author : Vikas Chauhan class CreateAuthorsTable extends Migration { public function up() { Schema::create('authors', function($table){ $table->increments('id'); $table->string('name'); $table-> text('bio'); $table->timestamps(); }); } public function down() { Schema::drop('authors'); } }
  • 10. 10 Author : Vikas Chauhan  On command line :- “php artisan migrate” (for perform action on up function)  On command line :- “php artisan migrate: rollback” (for perform action on down function)  If you will see fatal error while you rollback the migration :- on command line :- “var/local/bin/composer.phar dump-autolode” for ubuntu in your case “<composer_dir>/composer.phar dump-auto lode  On command line :- php artisan migrate:reset (for reset all migration)
  • 11. 11 Author : Vikas Chauhan Exercise4 Add Data Into Table Using Migration & Artisan
  • 12. 12 Author : Vikas Chauhan  On command line :- php artisan migrate: make add_authors (create a file in migration for add data in authors table)  <project_dir>/ app/ database/ migration/ 2013_08_07_102350_add_authors.php :- That php file contain two function up() & down(). up() function is used for add data into table and down() function is used for delete data from table. For example :-
  • 13. 13 Author : Vikas Chauhan class AddAuthors extends Migration { public function up() { DB::table('authors')->insert(array( 'name'=>'vikas chauhan', 'bio'=>'vikas chauhan is a good developer', 'created_at'=>date('y-m-d H:m:s'), 'updated_at'=>date('y-m-d H:m:s') )); } public function down() { DB::table('authors')->where('name','=','vikas chauhan')->delete(); } }
  • 14. 14 Author : Vikas Chauhan  On command line :- “php artisan migrate” (for perform action on up function)  On command line :- “php artisan migrate: rollback” (for perform action on down function)  If you will see fatal error while you rollback the migration :- on command line :- “var/local/bin/composer.phar dump-autolode” for ubuntu in your case “<composer_dir>/composer.phar dump-auto lode  On command line :- php artisan migrate:reset (for reset all migration)
  • 15. 15 Author : Vikas Chauhan Thanks & Regards, Contact to – Vikas Chauhan Email ID – [email protected] Phone – (080) 41155974