Academic Session 2025-26
ODD Semester Jul-Dec 2025
UNIVERSITY INSTITUTE OF COMPUTING
Bachelor of Computer Application(BC201)
Semester-VI
Advance Web Development using PHP
(23CAH-302)
Unit No.2 Chapter No. 1 Lecture No.1.1.1
Topic : __View
Gurpreet Kaur E12934 Assistant professor
Syllabus and CO’s Unit-2
CO3 Make use of necessary skills for designing and developing web applications
Compare different web development frameworks, libraries, and tools based on their strengths and weaknesses
CO4
CO5 Develop web application using MVA to solve real world problem
View Lecture Hours:30
Creating Blade file in laravel, creating form in blade file, sending file or image
through form
what are flash-messages, explain different type of flash messages, Introduction to packages, Inbuilt packages, how to install packages, Looping statementsin laravel: while loop, do
while, for loop, foreach loop, Conditional statements in laravel: if statement, if-else,Validation in Laravel, redirection in laravel, Miration and seeding
in laravel, artisan commands in laravel
Experiment-3 Write the code for creating controller.
3 .1 How to get requested data
Experiment-4 Write the code for uploading file or image with validation.
2
Introduction MVC
• MVC stands for Model-View-Controller, which is a software design pattern commonly used for developing
user interfaces. It divides an application into three interconnected components:
• Model:
• Represents the data and the business logic of the application.
• It directly manages the data, logic, and rules of the application. It responds to requests for information
(usually from the controller) and updates the view when the data changes.
• View:
• Represents the user interface (UI) of the application.
• It displays the data from the model in a format that is easy for users to understand and interact with.
The view listens for changes in the model and updates itself accordingly.
• Controller:
• Acts as an intermediary between the model and the view.
• It takes user input from the view, processes it (often altering the model), and then updates the view to
reflect changes in the data.
21/09/2025 3
View
• The View is data that is going to be displayed to the user on their browser and the user can interact with it. It
is simply an interface provided to the user for interaction.
Creating Blade file in Laravel
• Laravel used a powerful templating engine called Blade. The extension for this file used here
is [Link]. Even though there are some directives and layout format used with a blade for taking
advantage of this templating engine, still it allows us to write plain PHP in the view file. The main advantage
of using Blade Templating Engine is that it provides template inheritance. With this, we can create a master
layout page, which will become the base for other pages. So, the master page becomes the parent for all the
child pages that we extend it to.
21/09/2025 4
• Blade is the simple, yet powerful templating engine that is included with
Laravel. Unlike some PHP templating engines, Blade does not restrict you
from using plain PHP code in your templates. In fact, all Blade templates
are compiled into plain PHP code and cached until they are modified,
meaning Blade adds essentially zero overhead to your application. Blade
template files use the .[Link] file extension and are typically stored in
the resources/views directory.
• You may create a view by placing a file with the .[Link] extension in
your application's resources/views directory or by using the make:view
Artisan command:
• php artisan make:view greeting
21/09/2025 5
Creating form in blade file
• Creating a form in a Blade file (used in Laravel) typically involves using Laravel's Form facade or plain HTML.
Laravel's Blade templating engine makes it easy to generate form elements with security features like CSRF
protection.
• Example 1: Using Plain HTML in a Blade File
<form action="{{ route('[Link]') }}" method="POST">
@csrf <!-- Protects against CSRF attacks -->
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Submit</button>
</form>
21/09/2025 6
Sending file or Image through
form
• 1. HTML Form in Blade (View)Make sure you include the following:
• Use POST method.
• Add enctype="multipart/form-data" to allow file uploads.
• Use csrf_field() or @csrf for CSRF [Link]
<form action="{{ route('upload') }}" method="POST" enctype="multipart/form-data">
@csrf
<label for="image">Choose Image:</label>
<input type="file" name="image" id="image">
<button type="submit">Upload</button>
</form>
21/09/2025 7
• 2. Route ([Link])php
Route::post('/upload', [UploadController::class, 'store'])->name('upload');
3. ControllerMethod ([Link])
public function store(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048', // validation rules
]);
$image = $request->file('image');
$imageName = time().'.'.$image->getClientOriginalExtension();
$image->move(public_path('uploads'), $imageName);
return back()->with('success', 'Image uploaded successfully!');
}
21/09/2025 8
Quiz/ FAQ’s
• Load a view file?
• Pass data to a view?
• Include or extend templates?
• Use a view in a specific framework
Quiz/ FAQ’s (like Laravel's return
view(...))?
21/09/2025 9
Class wise Feedback
Class-Wise Feedback
21/09/2025 10
Relevant learning resources
• [Link]
• [Link]
• [Link]
relevant learning resources
21/09/2025 11
Links and Books
Text books
• Laravel Design Patterns and Best Practices - Book by Arda Kilicdagi and HIbrahim Yilmaz
• Laravel: Up and Running: A Framework for Building Modern PHP Apps - Book by Matt Stauffer
References books
• Professional WordPress: Design and Development by Brad Williams
• Step-By-Step WordPress for Beginners: How to Build a Beautiful Website on Your Own Domain from
Scratch by Mike Taylor
Links
1.[Link]
2. [Link]
3. [Link]
4. [Link]
21/09/2025 12
THANK YOU
13