SlideShare a Scribd company logo
1 of 63
Workshop Laravel 5.2
27 February 2016
STT NF, Jakarta Selatan
Hello!
Wahyu Rismawan
Informatics Eng, Telkom University (2011)
Software Artisan at Badr Interactive
~3 years exp in Web Development
Stalk:
Linkedin: bit.ly/wrismawan
FB: fb.com/wahyu.rismawan
Ready?
Preparation
• PHP >= 5.5.9 on XAMPP
• Already installed Composer (PHP Dependency
Manager)
• Terminal / Command Prompt
• Text Editor
Composer?
Is he musician? Hmmm...
Composer is a tool for
dependency manager in PHP
Your
Awesome
PHP
Project
(1) Read composer.json
(2) Find Library form Packagist
(3) Download Library(4) Library downloaded
on your project
How Composer Works?
Installation for OSX - Windows - Linux
https://getcomposer.org/doc/00-intro.md
How to use Composer?
Let’s install Laravel using Composer!
composer create-project --prefer-dist laravel/laravel PROJECT_NAME
1) cd PROJECT_NAME
2) php artisan serve
Run your Project
http://localhost:8000
Congratulation! It should be…
Small Intro into MVC (Model-View-Controller)
Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/
Small Intro into MVC (Model-View-Controller)
Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/
“Model” Example
Directory for “Controller codes”
Directory for “View codes”
Feeling dizzy or confused?
Don’t talk to much. Let’s practice!
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- Create, Update and Delete Quote
- Quote Timeline (Display quote from all users)
- Like Quote
Create Database
Inspire: Design Database
Review: Create Table using migrations
1) Create migration file
php artisan make:migration create_{name}_table
2) Code your table schema
3) To generata table, run: php artisan migrate
DB Config: Preparing database
• Create DB via phpmyadmin, e.g: “workshop”
• Config .env file
DB_HOST=localhost:8889
DB_DATABASE=workshop
DB_USERNAME=root
DB_PASSWORD=root
DB Config: Create migration for Quotes
php artisan make:migration create_quotes_table
Schema::create('quotes', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('content');
$table->string('author');
$table->timestamps();
});
DB Config: Create migration for Likes
php artisan make:migration create_likes_table
Schema::create('likes', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('quote_id');
$table->timestamps();
});
DB Config: Create Table Users
We don’t need to do anything,
Because Laravel have made users migration files (?)
2014_10_12_000000_create_users_table.php
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
Ready to create table
php artisan migrate
Will generate table to database based on our
migration files just made
Review: Create Table using migrations
1) Create migration file
php artisan make:migration create_{name}_table
2) Code your table schema
3) To generata table, run: php artisan migrate
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- Create, Update and Delete Quote
- Quote Timeline (Display quote from all users)
- Like Quote
Feature: Authentication
(Register, Login, Logout)
Create Login, Logout and Register
using “Laravel Magic”
php artisan make:auth
Will generate: view, controller and route for register,
login and logout
How can it work?
Is there ‘/home’ in
routes.php?
HTTP Request -> localhost:8000/home
Route::get(‘/home’, ‘HomeController@index’)
App/Http/Controllers/HomeController.php
Resources/views/home.blade.php
Render view
Load controller
HTTP Response
Find route
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- CRUD (Create, Retrieve, Update and Delete)
Quote
- Quote Timeline (Display quote from all users)
- Like Quote
CRUD for Quote
General Steps
2) Create controller
php artisan make:controller YourNewController
1) Define new feature route in routes.php
4) If needed, create model
php artisan make:model NewModelName
3) Create view using blade in resources/views
Define new feature routing
Route::get('/quote/timeline', 'QuoteController@timeline');
Route::post('/quote/save', 'QuoteController@store');
Route::get('/quote/edit/{id}', 'QuoteController@edit');
Route::post('/quote/update/{id}', 'QuoteController@update');
Open routes.php in App/Http/routes.php
Add this following code into routes.php
Create Quote Controller
php artisan make:controller QuoteController
View for Quote Timeline
Create timeline.blade.php at directory resources/views
Controller for Quote Timeline
Open QuoteController at directory App/Http/Controllers
It will refer to timeline.blade.php
Model for Quote
Create Quote Model: php artisan make:model Quote
Controller for storing new Quote
Open QuoteController at directory App/Http/Controllers
Display Quotes from all users
Open QuoteController at directory App/Http/Controllers
Display Quotes from all users
Open timeline.blade.php at directory resources/views
View for Edit & Remove Quote
View for Edit & Remove Quote
Open timeline.blade.php at directory resources/views
View for Edit Quote
View for Edit Quote
create edit_quote.blade.php at directory resources/views
Controller for Edit Quote
Open QuoteController at directory App/Http/Controllers
Controller for Update Quote
Open QuoteController at directory App/Http/Controllers
Controller for Delete Quote
Open QuoteController at directory App/Http/Controllers
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- CRUD (Create, Retrieve, Update and Delete)
Quote
- Quote Timeline (Display quote from all users)
- Like Quote
General Steps
3) Create controller for handling Like request
php artisan make:controller LikeController
1) Define new route in routes.php
2) Create Like Model
php artisan make:model Like
4) We’d already made view for Like at prev step.
Define new feature routing
Route::get('/like/{quote_id}', ’LikeController@like');
Route::get('/unlike/{quote_id}', ’LikeController@unlike');
Open routes.php from App/Http/routes.php
Add this following code into routes.php
Create Quote Model
php artisan make:model Like
Add Like relation in Quote Model
Open Quote.php from App/, add function likes()
Add Like relation in Quote Model
Open Quote.php from App/ then add function likes()
Create Like Controller
php artisan make:controller LikeController
Handling View for Like/Unlike Request
Open timeline.blade.php from resources/views
Controller for like request
Open LikeController from App/Http/Controllers
Don’t forget to add use App/Quote at the top
Add static function to check “user like”
Open Quote.php from App/
Don’t forget to add use Auth; at the top
Controller for unlike request
Open LikeController from App/Http/Controllers
Let’s see.
Any questions?

More Related Content

What's hot

Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Lorvent56
 

What's hot (20)

Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
 
Laravel 5.4
Laravel 5.4 Laravel 5.4
Laravel 5.4
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should know
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routing
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Laravel Introduction
Laravel IntroductionLaravel Introduction
Laravel Introduction
 
Knowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP frameworkKnowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP framework
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel framework
 

Similar to Workshop Laravel 5.2

Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
Joshua Warren
 

Similar to Workshop Laravel 5.2 (20)

Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
My Saminar On Php
My Saminar On PhpMy Saminar On Php
My Saminar On Php
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Laravel 5 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New Features
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Day02 a pi.
Day02   a pi.Day02   a pi.
Day02 a pi.
 
Elefrant [ng-Poznan]
Elefrant [ng-Poznan]Elefrant [ng-Poznan]
Elefrant [ng-Poznan]
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
Make your application expressive
Make your application expressiveMake your application expressive
Make your application expressive
 
Introduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in RIntroduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in R
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce Lightning
 
Dev streams2
Dev streams2Dev streams2
Dev streams2
 
CONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEMCONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEM
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 

Recently uploaded

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Recently uploaded (20)

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 

Workshop Laravel 5.2

  • 1. Workshop Laravel 5.2 27 February 2016 STT NF, Jakarta Selatan
  • 2. Hello! Wahyu Rismawan Informatics Eng, Telkom University (2011) Software Artisan at Badr Interactive ~3 years exp in Web Development Stalk: Linkedin: bit.ly/wrismawan FB: fb.com/wahyu.rismawan
  • 4. Preparation • PHP >= 5.5.9 on XAMPP • Already installed Composer (PHP Dependency Manager) • Terminal / Command Prompt • Text Editor
  • 6. Composer is a tool for dependency manager in PHP
  • 7. Your Awesome PHP Project (1) Read composer.json (2) Find Library form Packagist (3) Download Library(4) Library downloaded on your project How Composer Works?
  • 8. Installation for OSX - Windows - Linux https://getcomposer.org/doc/00-intro.md
  • 9. How to use Composer?
  • 10. Let’s install Laravel using Composer!
  • 11. composer create-project --prefer-dist laravel/laravel PROJECT_NAME
  • 12. 1) cd PROJECT_NAME 2) php artisan serve Run your Project http://localhost:8000
  • 14. Small Intro into MVC (Model-View-Controller) Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/
  • 15. Small Intro into MVC (Model-View-Controller) Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/ “Model” Example Directory for “Controller codes” Directory for “View codes”
  • 16. Feeling dizzy or confused?
  • 17. Don’t talk to much. Let’s practice!
  • 18. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - Create, Update and Delete Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 21. Review: Create Table using migrations 1) Create migration file php artisan make:migration create_{name}_table 2) Code your table schema 3) To generata table, run: php artisan migrate
  • 22. DB Config: Preparing database • Create DB via phpmyadmin, e.g: “workshop” • Config .env file DB_HOST=localhost:8889 DB_DATABASE=workshop DB_USERNAME=root DB_PASSWORD=root
  • 23. DB Config: Create migration for Quotes php artisan make:migration create_quotes_table Schema::create('quotes', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->string('content'); $table->string('author'); $table->timestamps(); });
  • 24. DB Config: Create migration for Likes php artisan make:migration create_likes_table Schema::create('likes', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->integer('quote_id'); $table->timestamps(); });
  • 25. DB Config: Create Table Users We don’t need to do anything, Because Laravel have made users migration files (?) 2014_10_12_000000_create_users_table.php Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); $table->timestamps(); });
  • 26. Ready to create table php artisan migrate Will generate table to database based on our migration files just made
  • 27. Review: Create Table using migrations 1) Create migration file php artisan make:migration create_{name}_table 2) Code your table schema 3) To generata table, run: php artisan migrate
  • 28. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - Create, Update and Delete Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 30. Create Login, Logout and Register using “Laravel Magic” php artisan make:auth Will generate: view, controller and route for register, login and logout
  • 31. How can it work?
  • 32. Is there ‘/home’ in routes.php? HTTP Request -> localhost:8000/home Route::get(‘/home’, ‘HomeController@index’) App/Http/Controllers/HomeController.php Resources/views/home.blade.php Render view Load controller HTTP Response Find route
  • 33. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - CRUD (Create, Retrieve, Update and Delete) Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 35. General Steps 2) Create controller php artisan make:controller YourNewController 1) Define new feature route in routes.php 4) If needed, create model php artisan make:model NewModelName 3) Create view using blade in resources/views
  • 36. Define new feature routing Route::get('/quote/timeline', 'QuoteController@timeline'); Route::post('/quote/save', 'QuoteController@store'); Route::get('/quote/edit/{id}', 'QuoteController@edit'); Route::post('/quote/update/{id}', 'QuoteController@update'); Open routes.php in App/Http/routes.php Add this following code into routes.php
  • 37. Create Quote Controller php artisan make:controller QuoteController
  • 38. View for Quote Timeline Create timeline.blade.php at directory resources/views
  • 39.
  • 40. Controller for Quote Timeline Open QuoteController at directory App/Http/Controllers It will refer to timeline.blade.php
  • 41. Model for Quote Create Quote Model: php artisan make:model Quote
  • 42. Controller for storing new Quote Open QuoteController at directory App/Http/Controllers
  • 43. Display Quotes from all users Open QuoteController at directory App/Http/Controllers
  • 44. Display Quotes from all users Open timeline.blade.php at directory resources/views
  • 45. View for Edit & Remove Quote
  • 46. View for Edit & Remove Quote Open timeline.blade.php at directory resources/views
  • 47. View for Edit Quote
  • 48. View for Edit Quote create edit_quote.blade.php at directory resources/views
  • 49. Controller for Edit Quote Open QuoteController at directory App/Http/Controllers
  • 50. Controller for Update Quote Open QuoteController at directory App/Http/Controllers
  • 51. Controller for Delete Quote Open QuoteController at directory App/Http/Controllers
  • 52. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - CRUD (Create, Retrieve, Update and Delete) Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 53. General Steps 3) Create controller for handling Like request php artisan make:controller LikeController 1) Define new route in routes.php 2) Create Like Model php artisan make:model Like 4) We’d already made view for Like at prev step.
  • 54. Define new feature routing Route::get('/like/{quote_id}', ’LikeController@like'); Route::get('/unlike/{quote_id}', ’LikeController@unlike'); Open routes.php from App/Http/routes.php Add this following code into routes.php
  • 55. Create Quote Model php artisan make:model Like
  • 56. Add Like relation in Quote Model Open Quote.php from App/, add function likes()
  • 57. Add Like relation in Quote Model Open Quote.php from App/ then add function likes()
  • 58. Create Like Controller php artisan make:controller LikeController
  • 59. Handling View for Like/Unlike Request Open timeline.blade.php from resources/views
  • 60. Controller for like request Open LikeController from App/Http/Controllers Don’t forget to add use App/Quote at the top
  • 61. Add static function to check “user like” Open Quote.php from App/ Don’t forget to add use Auth; at the top
  • 62. Controller for unlike request Open LikeController from App/Http/Controllers