Lab 4

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

lab4.

md 2/26/2023

Lab 4: Creating View for Contacts-Create Route


Submission instruction: after practicing Lab 4 successfully, please
Print each page into pdf
Upload to MS Team (into your folder in Lab)
Copy link from each pdf file and submit
routes\web.php
<?php

use Illuminate\Support\Facades\Route;

Route::get('/',function(){
return view ('welcome');
});

Route::get('/contacts', function () {
return view('contacts.index');
})->name('contacts.index');

Route::get('/contacts/create', function () {
return view('contacts.create');
})->name('contacts.create');

Route::get('/contacts/{id}', function ($id) {


return "Contact " . $id;
})->name('contacts.show');

?>

resources\views\welcome.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Royal University of Phnom Penh</h1>
1/2
lab4.md 2/26/2023

<h1>Class: M1</h1>
<h1>Name: Dara</h1>
<h1>Contact App</h1>
<div>
<a href='{{ route('contacts.index') }}'>All contacts</a>
</div>
</body>
</html>

resources/views/contacts/index.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>All contacts</h1>
<div>
<a href='{{ route('contacts.create') }}'>Add contact</a>
<a href='{{ route('contacts.show', 1) }}'>Show contact</a>
</div>
</body>
</html>

resources/views/contacts/create.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>Add new contact</h1>
<div>
<a href='{{ route('contacts.index') }}'>Back to all contacts</a>
</div>
</body>
</html>

2/2

You might also like