SlideShare a Scribd company logo
Object-Oriented
Programming
(with Laravel)
By: Shahrzad Peyman
Session 3
April-2017
shahrzad.peymaan@gmail.com
1
2
Today’s Presentation
• Final Methods
• Interface
• Abstract
• Template Engine
• Blade
• Template Inheritance
• Blade Syntax
Final Methods
Most of the time, allowing your classes to be extended
using inheritance is a good thing. It's part of what
makes object-oriented programming so powerful.
Occasionally, though, overriding certain methods of a
class can cause things to break easily, create security
issues, or make the resulting code overly complex.
When you wish to prevent a subclass from overriding
a superclass method, you can use the final keyword.
3
4
Final Methods
5
Interface
An interface is an outline of what a particular
object can do. You will often hear that an
interface is a contract. This is true in as much
as an interface defines the public methods that
a class must implement.
Object interfaces allow you to create code
which specifies which methods a class must
implement, without having to define how these
methods are handled.
Interface
6
Abstract
7
An abstract class is a special type of class that can't
be instantiated — in other words, you can't create
objects from it. Instead, you create child classes
from the abstract class, and create objects from
those child classes instead.
An abstract class is designed to be used as a
template for creating classes.
An abstract class will have abstract methods which
are defined by the abstract keyword, these methods
are like the methods defined in the interface classes.
8
Abstract
Interface vs Abstract
Interface Abstract
The Code
• abstract methods
• constants
• abstract methods
• constants
• concrete methods
• concrete variables
Access Modifiers • public
• public
• private
• protected
Number of Parents
Class can impelement
more than one interface
Class can inherit only
from one abstract class
9
What is template engine?
Template Engine, combines web templates to form
finished web pages, possibly using some data
source to customize the pages or present a large
amount of content on similar-looking pages.
As you know, the controller is responsible for
handling each request that comes into a Laravel
application. When a controller needs to generate
HTML, CSS or any other content, it hands the work
off to the templating engine.
10
Template Engine
11
Template
12
A template is simply a text file that can generate any
text-based format (HTML, XML, CSV, LaTeX ...). The
most familiar type of template is a PHP template - a text
file parsed by PHP that contains a mix of text and PHP
code.
Blade
Blade is the simple, yet powerful templating engine
provided with Laravel.
Unlike other popular PHP templating engines, Blade
does not restrict you from using plain PHP code in your
views. In fact, all Blade views are compiled into plain
PHP code and cached until they are modified, meaning
Blade adds essentially zero overhead to your
application.
Blade
Blade view files use the .blade.php file extension and
are typically stored in the resources/views directory.
Every template name also has two extensions that
specify the format and engine for that template.
Views contain the HTML served by your application
and separate your controller / application logic from
your presentation logic.
Template Inheritance
Defining a Layout:
Two of the primary benefits
of using Blade are template
inheritance and sections.
Template Inheritance
16
Extending a Layout:
When defining a child view,
use the Blade @extends
directive to specify which
layout the child view should
"inherit".
Routes & Blade Views
Blade views may be returned from routes using
the global view helper:
17
Components & Slots
18
Components and slots provide similar benefits to
sections and layouts; however, some may find the
mental model of components and slots easier to
understand.
Components & Slots
19
Displaying Data
You may display data passed to your Blade views by
wrapping the variable in curly braces.
20
Displaying Data
When passing information in this manner, $data should be an
array with key/value pairs. Inside your view, you can then access
each value using its corresponding key.
You can do:
21
22
Displaying Data
Of course, you are not limited to displaying the contents of
the variables passed to the view. You may also echo the
results of any PHP function. In fact, you can put any PHP
code you wish inside of a Blade echo statement:
If you do not want your data to be escaped, you may use the
following syntax:
23
Sharing Data with All Views
Occasionally, you may
need to share a piece of
data with all views that
are rendered by your
application.
24
Blade & JavaScript
Framework
Since many JavaScript frameworks also use "curly"
braces to indicate a given expression should be
displayed in the browser, you may use the @ symbol to
inform the Blade rendering engine an expression
should remain untouched. For example:
25
Blade & JavaScript
Framework
If you are displaying JavaScript variables in a large
portion of your template, you may wrap the HTML in the
@verbatim directive so that you do not have to prefix
each Blade echo statement with an @ symbol:
If Statements
26
Loops
27
28
Loops
29
Loops
30
Comments
Blade also allows you to define comments in your
views. However, unlike HTML comments, Blade
comments are not included in the HTML returned by
your application:
31
Including Sub-Views
Blade’s @include directive allows you to
include a Blade view from within another view.
All variables that are available to the parent
view will be made available to the included
view:
32
Rendering Views For Collections

More Related Content

What's hot (20)

PDF
C# ASP.NET WEB API APPLICATION DEVELOPMENT
Dr. Awase Khirni Syed
 
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
PDF
Intro to vue.js
TechMagic
 
PPTX
Laravel overview
Obinna Akunne
 
PDF
Laravel presentation
Toufiq Mahmud
 
PDF
An introduction to Vue.js
Javier Lafora Rey
 
PDF
Spring Framework - AOP
Dzmitry Naskou
 
PDF
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Edureka!
 
PPTX
Laravel Tutorial PPT
Piyush Aggarwal
 
PPTX
Introduction à Laravel
Abdoulaye Dieng
 
PDF
Web Development with Laravel 5
Soheil Khodayari
 
PPTX
Laravel ppt
Mayank Panchal
 
ODP
Introduction to Apache solr
Knoldus Inc.
 
PDF
Expressjs
Yauheni Nikanovich
 
PPTX
Terraform 101
Pradeep Loganathan
 
PPTX
Express js
Manav Prasad
 
PDF
Introdução APIs RESTful
Douglas V. Pasqua
 
PDF
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Edureka!
 
PDF
Introduction to ASP.NET Core
Avanade Nederland
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
Dr. Awase Khirni Syed
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Intro to vue.js
TechMagic
 
Laravel overview
Obinna Akunne
 
Laravel presentation
Toufiq Mahmud
 
An introduction to Vue.js
Javier Lafora Rey
 
Spring Framework - AOP
Dzmitry Naskou
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Edureka!
 
Laravel Tutorial PPT
Piyush Aggarwal
 
Introduction à Laravel
Abdoulaye Dieng
 
Web Development with Laravel 5
Soheil Khodayari
 
Laravel ppt
Mayank Panchal
 
Introduction to Apache solr
Knoldus Inc.
 
Terraform 101
Pradeep Loganathan
 
Express js
Manav Prasad
 
Introdução APIs RESTful
Douglas V. Pasqua
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Edureka!
 
Introduction to ASP.NET Core
Avanade Nederland
 

Similar to Object Oriented Programming with Laravel - Session 3 (20)

PDF
Web Programming - 7 Blading Template
AndiNurkholis1
 
PDF
Lecture15_LaravelGetStarted_SPring2023.pdf
ShaimaaMohamedGalal
 
PDF
Laravel
SitaPrajapati
 
PPTX
Laravel Meetup
Whisnu Sucitanuary
 
PPTX
Laravel 5
Sudip Simkhada
 
PPTX
Laravel Framework for web development.pptx
Eric Walter
 
PDF
Laravel 101
Commit University
 
PPTX
Introduction_to_Laravel_Background DOCUMENTATION.pptx
michaelcagampang4
 
PPTX
Introduction_to_Laravel_Simple DUCUMENTATION.pptx
michaelcagampang4
 
PPTX
Laravel
Dyuti Islam
 
PPTX
Introduction to Laravel Framework (5.2)
Viral Solani
 
PDF
Why Laravel?
Jonathan Goode
 
DOCX
Laravel framework - An overview and usability for web development
ifour_bhavesh
 
PPTX
What-is-Laravel and introduciton to Laravel
PraveenHegde20
 
PPTX
Lecture 4_Laravel Controller and Data Pass-Route.pptx
SaziaRahman
 
PPTX
Laravel 5
Brian Feaver
 
PPTX
Laravel session 1
Ashish Kumar
 
PDF
Key Features of Laravel for Developers - Eminence
Eminence Technology
 
PPTX
Laravel Webcon 2015
Tim Bracken
 
PDF
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
Cetpa Infotech
 
Web Programming - 7 Blading Template
AndiNurkholis1
 
Lecture15_LaravelGetStarted_SPring2023.pdf
ShaimaaMohamedGalal
 
Laravel
SitaPrajapati
 
Laravel Meetup
Whisnu Sucitanuary
 
Laravel 5
Sudip Simkhada
 
Laravel Framework for web development.pptx
Eric Walter
 
Laravel 101
Commit University
 
Introduction_to_Laravel_Background DOCUMENTATION.pptx
michaelcagampang4
 
Introduction_to_Laravel_Simple DUCUMENTATION.pptx
michaelcagampang4
 
Laravel
Dyuti Islam
 
Introduction to Laravel Framework (5.2)
Viral Solani
 
Why Laravel?
Jonathan Goode
 
Laravel framework - An overview and usability for web development
ifour_bhavesh
 
What-is-Laravel and introduciton to Laravel
PraveenHegde20
 
Lecture 4_Laravel Controller and Data Pass-Route.pptx
SaziaRahman
 
Laravel 5
Brian Feaver
 
Laravel session 1
Ashish Kumar
 
Key Features of Laravel for Developers - Eminence
Eminence Technology
 
Laravel Webcon 2015
Tim Bracken
 
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
Cetpa Infotech
 
Ad

More from Shahrzad Peyman (11)

PDF
Web Design & Development - Session 9
Shahrzad Peyman
 
PDF
Web Design & Development - Session 8
Shahrzad Peyman
 
PDF
Web Design & Development - Session 7
Shahrzad Peyman
 
PDF
Web Design & Development - Session 6
Shahrzad Peyman
 
PDF
Web Design & Development - Session 4
Shahrzad Peyman
 
PDF
Web Design & Development - Session 3
Shahrzad Peyman
 
PDF
Web Design & Development - Session 2
Shahrzad Peyman
 
PDF
Web Design & Development - Session 1
Shahrzad Peyman
 
PDF
Object Oriented Programming with Laravel - Session 6
Shahrzad Peyman
 
PDF
Object Oriented Programming with Laravel - Session 5
Shahrzad Peyman
 
PDF
Object Oriented Programming with Laravel - Session 4
Shahrzad Peyman
 
Web Design & Development - Session 9
Shahrzad Peyman
 
Web Design & Development - Session 8
Shahrzad Peyman
 
Web Design & Development - Session 7
Shahrzad Peyman
 
Web Design & Development - Session 6
Shahrzad Peyman
 
Web Design & Development - Session 4
Shahrzad Peyman
 
Web Design & Development - Session 3
Shahrzad Peyman
 
Web Design & Development - Session 2
Shahrzad Peyman
 
Web Design & Development - Session 1
Shahrzad Peyman
 
Object Oriented Programming with Laravel - Session 6
Shahrzad Peyman
 
Object Oriented Programming with Laravel - Session 5
Shahrzad Peyman
 
Object Oriented Programming with Laravel - Session 4
Shahrzad Peyman
 
Ad

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Tally software_Introduction_Presentation
AditiBansal54083
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 

Object Oriented Programming with Laravel - Session 3

  • 2. 2 Today’s Presentation • Final Methods • Interface • Abstract • Template Engine • Blade • Template Inheritance • Blade Syntax
  • 3. Final Methods Most of the time, allowing your classes to be extended using inheritance is a good thing. It's part of what makes object-oriented programming so powerful. Occasionally, though, overriding certain methods of a class can cause things to break easily, create security issues, or make the resulting code overly complex. When you wish to prevent a subclass from overriding a superclass method, you can use the final keyword. 3
  • 5. 5 Interface An interface is an outline of what a particular object can do. You will often hear that an interface is a contract. This is true in as much as an interface defines the public methods that a class must implement. Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are handled.
  • 7. Abstract 7 An abstract class is a special type of class that can't be instantiated — in other words, you can't create objects from it. Instead, you create child classes from the abstract class, and create objects from those child classes instead. An abstract class is designed to be used as a template for creating classes. An abstract class will have abstract methods which are defined by the abstract keyword, these methods are like the methods defined in the interface classes.
  • 9. Interface vs Abstract Interface Abstract The Code • abstract methods • constants • abstract methods • constants • concrete methods • concrete variables Access Modifiers • public • public • private • protected Number of Parents Class can impelement more than one interface Class can inherit only from one abstract class 9
  • 10. What is template engine? Template Engine, combines web templates to form finished web pages, possibly using some data source to customize the pages or present a large amount of content on similar-looking pages. As you know, the controller is responsible for handling each request that comes into a Laravel application. When a controller needs to generate HTML, CSS or any other content, it hands the work off to the templating engine. 10
  • 12. Template 12 A template is simply a text file that can generate any text-based format (HTML, XML, CSV, LaTeX ...). The most familiar type of template is a PHP template - a text file parsed by PHP that contains a mix of text and PHP code.
  • 13. Blade Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application.
  • 14. Blade Blade view files use the .blade.php file extension and are typically stored in the resources/views directory. Every template name also has two extensions that specify the format and engine for that template. Views contain the HTML served by your application and separate your controller / application logic from your presentation logic.
  • 15. Template Inheritance Defining a Layout: Two of the primary benefits of using Blade are template inheritance and sections.
  • 16. Template Inheritance 16 Extending a Layout: When defining a child view, use the Blade @extends directive to specify which layout the child view should "inherit".
  • 17. Routes & Blade Views Blade views may be returned from routes using the global view helper: 17
  • 18. Components & Slots 18 Components and slots provide similar benefits to sections and layouts; however, some may find the mental model of components and slots easier to understand.
  • 20. Displaying Data You may display data passed to your Blade views by wrapping the variable in curly braces. 20
  • 21. Displaying Data When passing information in this manner, $data should be an array with key/value pairs. Inside your view, you can then access each value using its corresponding key. You can do: 21
  • 22. 22 Displaying Data Of course, you are not limited to displaying the contents of the variables passed to the view. You may also echo the results of any PHP function. In fact, you can put any PHP code you wish inside of a Blade echo statement: If you do not want your data to be escaped, you may use the following syntax:
  • 23. 23 Sharing Data with All Views Occasionally, you may need to share a piece of data with all views that are rendered by your application.
  • 24. 24 Blade & JavaScript Framework Since many JavaScript frameworks also use "curly" braces to indicate a given expression should be displayed in the browser, you may use the @ symbol to inform the Blade rendering engine an expression should remain untouched. For example:
  • 25. 25 Blade & JavaScript Framework If you are displaying JavaScript variables in a large portion of your template, you may wrap the HTML in the @verbatim directive so that you do not have to prefix each Blade echo statement with an @ symbol:
  • 30. 30 Comments Blade also allows you to define comments in your views. However, unlike HTML comments, Blade comments are not included in the HTML returned by your application:
  • 31. 31 Including Sub-Views Blade’s @include directive allows you to include a Blade view from within another view. All variables that are available to the parent view will be made available to the included view:
  • 32. 32 Rendering Views For Collections