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

PDF
Object Oriented Programming with Laravel - Session 2
PDF
Laravel Blade Template
PPTX
Lecture 2_ Intro to laravel.pptx
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
PDF
Object Oriented Programming with Laravel - Session 1
PPTX
Laravel Tutorial PPT
PDF
Laravel presentation
PPTX
Introduction to laravel framework
Object Oriented Programming with Laravel - Session 2
Laravel Blade Template
Lecture 2_ Intro to laravel.pptx
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Object Oriented Programming with Laravel - Session 1
Laravel Tutorial PPT
Laravel presentation
Introduction to laravel framework

What's hot (20)

PPTX
Learning solid principles using c#
PDF
Web Development with Laravel 5
PDF
Introduction to React Native
PPTX
Express JS
DOCX
Create rest webservice for oracle public api using java class via jdeveloper
PPTX
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
PDF
REST API and CRUD
PPTX
Php.ppt
PPTX
PDF
Laravel Introduction
PDF
CSS Grid vs. Flexbox
PPTX
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
PDF
Gradle Introduction
PPTX
Node js introduction
PPTX
Introduction to Node.js
PPTX
Express js
PPTX
ASP.NET Core MVC + Web API with Overview
PPTX
[Final] ReactJS presentation
PPTX
Solid principles
KEY
Rest and the hypermedia constraint
Learning solid principles using c#
Web Development with Laravel 5
Introduction to React Native
Express JS
Create rest webservice for oracle public api using java class via jdeveloper
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
REST API and CRUD
Php.ppt
Laravel Introduction
CSS Grid vs. Flexbox
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
Gradle Introduction
Node js introduction
Introduction to Node.js
Express js
ASP.NET Core MVC + Web API with Overview
[Final] ReactJS presentation
Solid principles
Rest and the hypermedia constraint
Ad

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

PDF
Frontend Interview Questions PDF By ScholarHat
PPT
Ruby On Rails Siddhesh
PPTX
cakephp UDUYKTHA (1)
PPTX
Website development-osgl
PDF
Ez platform meetup, madrid 21 marzo 2018 english
PDF
The Ultimate Guide to Ad0 e103 adobe experience manager sites developer
PDF
Web Programming - 7 Blading Template
PDF
MVC Interview Questions PDF By ScholarHat
PDF
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
PPTX
Parallel minds silverlight
PDF
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
PDF
Mastering Important Design Patterns in Laravel.pdf
PDF
Making Of PHP Based Web Application
PDF
Html5 deciphered - designing concepts part 1
PDF
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
PPTX
Laravel overview
PDF
sveltekit-en.pdf
PDF
Intro to mobile web application development
PDF
IRJET- Lightweight MVC Framework in PHP
PDF
Crash Course HTML/Rails Slides
Frontend Interview Questions PDF By ScholarHat
Ruby On Rails Siddhesh
cakephp UDUYKTHA (1)
Website development-osgl
Ez platform meetup, madrid 21 marzo 2018 english
The Ultimate Guide to Ad0 e103 adobe experience manager sites developer
Web Programming - 7 Blading Template
MVC Interview Questions PDF By ScholarHat
Salesforce Auckland Developer Meetup - May 2018 - Lightning Web Components
Parallel minds silverlight
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
Mastering Important Design Patterns in Laravel.pdf
Making Of PHP Based Web Application
Html5 deciphered - designing concepts part 1
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
Laravel overview
sveltekit-en.pdf
Intro to mobile web application development
IRJET- Lightweight MVC Framework in PHP
Crash Course HTML/Rails Slides
Ad

More from Shahrzad Peyman (11)

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

Recently uploaded (20)

PDF
Perfecting Gamer’s Experiences with Performance Testing for Gaming Applicatio...
PPTX
How a Careem Clone App Allows You to Compete with Large Mobility Brands
PPTX
AIRLINE PRICE API | FLIGHT API COST |
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPT
JAVA ppt tutorial basics to learn java programming
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Forouzan Book Information Security Chaper - 1
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
PPTX
Mastering-Cybersecurity-The-Crucial-Role-of-Antivirus-Support-Services.pptx
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
System and Network Administration Chapter 2
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
Save Business Costs with CRM Software for Insurance Agents
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Perfecting Gamer’s Experiences with Performance Testing for Gaming Applicatio...
How a Careem Clone App Allows You to Compete with Large Mobility Brands
AIRLINE PRICE API | FLIGHT API COST |
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PTS Company Brochure 2025 (1).pdf.......
2025 Textile ERP Trends: SAP, Odoo & Oracle
Upgrade and Innovation Strategies for SAP ERP Customers
JAVA ppt tutorial basics to learn java programming
How Creative Agencies Leverage Project Management Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Forouzan Book Information Security Chaper - 1
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Mastering-Cybersecurity-The-Crucial-Role-of-Antivirus-Support-Services.pptx
The Five Best AI Cover Tools in 2025.docx
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
Materi-Enum-and-Record-Data-Type (1).pptx
System and Network Administration Chapter 2
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Save Business Costs with CRM Software for Insurance Agents
Which alternative to Crystal Reports is best for small or large businesses.pdf

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