Skip to content

Commit 8c2612d

Browse files
committedJun 28, 2023
route-fix-basic-code-format
1 parent 289e837 commit 8c2612d

32 files changed

+226
-280
lines changed
 

‎Http/Forms/LoginForm.php

+19-24
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,27 @@
66

77
class LoginForm
88
{
9-
protected $errors = [];
10-
public function validate($email, $password)
11-
12-
{
13-
14-
15-
if (!Validator::email($email)) {
16-
$this->errors['email'] = 'Please provide a valid email address.';
9+
protected $errors = [];
10+
public function validate($email, $password)
11+
{
12+
if (!Validator::email($email)) {
13+
$this->errors['email'] = 'Please provide a valid email address.';
14+
}
15+
16+
if (!Validator::string($password, 7, 255)) {
17+
$this->errors['password'] = 'Please provide a valid password.';
18+
}
19+
20+
return empty($this->errors);
1721
}
1822

19-
if (!Validator::string($password, 7, 255)) {
20-
$this->errors['password'] = 'Please provide a valid password.';
23+
public function errors()
24+
{
25+
return $this->errors;
2126
}
2227

23-
24-
return empty($this->errors);
25-
}
26-
27-
public function errors()
28-
{
29-
30-
return $this->errors;
31-
}
32-
33-
public function error($filed, $message)
34-
{
35-
$this->errors[$filed] = $message;
36-
}
28+
public function error($filed, $message)
29+
{
30+
$this->errors[$filed] = $message;
31+
}
3732
}

‎Http/controllers/about.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

3-
4-
view(
5-
6-
'about.view.php',
7-
[
8-
'heading' => 'About'
9-
]
10-
);
3+
view('about.view.php', [
4+
'heading' => 'About',
5+
]);

‎Http/controllers/contact.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<?php
22

3-
view(
4-
5-
'contact.view.php',
6-
7-
[
8-
9-
'heading' => 'Contact'
10-
11-
]
12-
13-
);
3+
view('contact.view.php', [
4+
'heading' => 'Contact',
5+
]);

‎Http/controllers/index.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?php
22

3-
4-
view(
5-
6-
'index.view.php',
7-
[
8-
'heading' => 'HOME'
9-
]
10-
);
3+
view('index.view.php', [
4+
'heading' => 'HOME',
5+
]);

‎Http/controllers/notes/create.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

3-
view("notes/create.view.php", [
4-
3+
view('notes/create.view.php', [
54
'heading' => 'Create Note',
6-
'errors' => []
5+
'errors' => [],
76
]);

‎Http/controllers/notes/destroy.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
$currentUserId = 1;
99

10-
$note = $db->query('select * from notes where id = :id', [
11-
'id' => $_POST['id'],
12-
])->findOrFail();
10+
$note = $db
11+
->query('select * from notes where id = :id', [
12+
'id' => $_POST['id'],
13+
])
14+
->findOrFail();
1315

1416
authorize($note['user_id'] === $currentUserId);
1517

1618
$db->query('delete from notes where id = :id', [
17-
'id' => $_POST['id'],
19+
'id' => $_POST['id'],
1820
]);
1921

2022
header('location: /notes');

‎Http/controllers/notes/edit.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
$currentUserId = 1;
99

10-
$note = $db->query('select * from notes where id = :id', [
11-
'id' => $_GET['id']
12-
])->findOrFail();
10+
$note = $db
11+
->query('select * from notes where id = :id', [
12+
'id' => $_GET['id'],
13+
])
14+
->findOrFail();
1315

1416
authorize($note['user_id'] === $currentUserId);
1517

16-
view("notes/edit.view.php", [
18+
view('notes/edit.view.php', [
1719
'heading' => 'Edit Note',
1820
'errors' => [],
19-
'note' => $note
21+
'note' => $note,
2022
]);

‎Http/controllers/notes/index.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55

66
$db = App::resolve(Database::class);
77

8-
9-
108
$notes = $db->query('select * from notes where user_id = 1')->get();
119

12-
13-
view(
14-
15-
"notes/index.view.php",
16-
[
10+
view('notes/index.view.php', [
1711
'heading' => 'My Note',
18-
'notes' => $notes
19-
]
20-
);
12+
'notes' => $notes,
13+
]);

‎Http/controllers/notes/show.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,19 @@
1010
$note = $db
1111

1212
->query('select * from notes where id = :id', [
13-
1413
'id' => $_GET['id'],
1514
])
1615

1716
->findOrFail();
1817

1918
authorize($note['user_id'] === $currentUserId);
2019

21-
2220
if ($note['user_id'] !== $currentUserId) {
23-
24-
2521
abort(Response::FORBIDDEN);
2622
}
2723

28-
view("notes/show.view.php", [
29-
30-
'heading' => "Note",
24+
view('notes/show.view.php', [
25+
'heading' => 'Note',
3126

32-
'note' => $note
27+
'note' => $note,
3328
]);

‎Http/controllers/notes/store.php

+7-16
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,22 @@
88

99
$errors = [];
1010

11-
1211
if (!Validator::string($_POST['body'], 1, 1000)) {
13-
14-
$errors['body'] = 'Body is required and must be less than 1000 characters';
12+
$errors['body'] = 'Body is required and must be less than 1000 characters';
1513
}
1614

1715
if (!empty($errors)) {
16+
return view('notes/create.view.php', [
17+
'heading' => 'Create Note',
1818

19-
return view("notes/create.view.php", [
20-
21-
'heading' => 'Create Note',
22-
23-
'errors' => $errors ?? [],
24-
25-
]);
19+
'errors' => $errors ?? [],
20+
]);
2621
}
2722

28-
29-
3023
$db->query('INSERT INTO notes(body, user_id) VALUES(:body, :user_id)', [
24+
'body' => $_POST['body'],
3125

32-
'body' => $_POST['body'],
33-
34-
'user_id' => 1,
35-
26+
'user_id' => 1,
3627
]);
3728

3829
header('location: /notes');

‎Http/controllers/notes/update.php

+13-11
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
$currentUserId = 1;
1010

1111
// find the corresponding note
12-
$note = $db->query('select * from notes where id = :id', [
13-
'id' => $_POST['id']
14-
])->findOrFail();
12+
$note = $db
13+
->query('select * from notes where id = :id', [
14+
'id' => $_POST['id'],
15+
])
16+
->findOrFail();
1517

1618
// authorize that the current user can edit the note
1719
authorize($note['user_id'] === $currentUserId);
@@ -20,21 +22,21 @@
2022
$errors = [];
2123

2224
if (!Validator::string($_POST['body'], 1, 1000)) {
23-
$errors['body'] = 'A body of no more than 1,000 characters is required.';
25+
$errors['body'] = 'A body of no more than 1,000 characters is required.';
2426
}
2527

2628
// if no validation errors, update the record in the notes database table.
2729
if (count($errors)) {
28-
return view('notes/edit.view.php', [
29-
'heading' => 'Edit Note',
30-
'errors' => $errors,
31-
'note' => $note
32-
]);
30+
return view('notes/edit.view.php', [
31+
'heading' => 'Edit Note',
32+
'errors' => $errors,
33+
'note' => $note,
34+
]);
3335
}
3436

3537
$db->query('update notes set body = :body where id = :id', [
36-
'id' => $_POST['id'],
37-
'body' => $_POST['body']
38+
'id' => $_POST['id'],
39+
'body' => $_POST['body'],
3840
]);
3941

4042
// redirect the user
-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<?php
22

3-
43
view('registration/create.view.php');

‎Http/controllers/registration/store.php

+21-22
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,46 @@
44
use Core\Database;
55
use Core\Validator;
66

7-
8-
97
$email = $_POST['email'];
108
$password = $_POST['password'];
119

1210
$errors = [];
1311
if (!Validator::email($email)) {
14-
$errors['email'] = 'Please provide a valid email address.';
12+
$errors['email'] = 'Please provide a valid email address.';
1513
}
1614

1715
if (!Validator::string($password, 7, 255)) {
18-
$errors['password'] = 'Please provide a password of at least seven characters.';
16+
$errors['password'] = 'Please provide a password of at least seven characters.';
1917
}
2018

2119
if (!empty($errors)) {
22-
return view('registration/create.view.php', [
23-
'errors' => $errors
24-
]);
20+
return view('registration/create.view.php', [
21+
'errors' => $errors,
22+
]);
2523
}
2624

2725
$db = App::resolve(Database::class);
2826

29-
$user = $db->query('SELECT * FROM users WHERE email = :email', [
30-
'email' => $email
31-
])->find();
27+
$user = $db
28+
->query('SELECT * FROM users WHERE email = :email', [
29+
'email' => $email,
30+
])
31+
->find();
3232

3333
if ($user) {
34-
$errors['email'] = 'This email is already in use.';
34+
$errors['email'] = 'This email is already in use.';
3535

36-
return view('registration/create.view.php', [
37-
'errors' => $errors
38-
]);
36+
return view('registration/create.view.php', [
37+
'errors' => $errors,
38+
]);
3939
} else {
40-
$db->query('INSERT INTO users(email, password) VALUES(:email, :password)', [
41-
'email' => $email,
42-
'password' => password_hash($password, PASSWORD_BCRYPT)
43-
]);
44-
45-
login($user);
40+
$db->query('INSERT INTO users(email, password) VALUES(:email, :password)', [
41+
'email' => $email,
42+
'password' => password_hash($password, PASSWORD_BCRYPT),
43+
]);
4644

45+
login($user);
4746

48-
header('location: /');
49-
exit();
47+
header('location: /');
48+
exit();
5049
}

‎Http/controllers/session/create.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use Core\Session;
44

5-
65
view('session/create.view.php', [
7-
'errors' => Session::get('errors')
6+
'errors' => Session::get('errors'),
87
]);

‎Http/controllers/session/store.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,23 @@
44
use Core\Session;
55
use Http\Forms\LoginForm;
66

7-
8-
97
$email = $_POST['email'];
108

119
$password = $_POST['password'];
1210

13-
1411
$form = new LoginForm();
1512

1613
if ($form->validate($email, $password)) {
17-
if ((new Authenticator)->attempt($email, $password)) {
18-
redirect('/');
19-
}
14+
if ((new Authenticator())->attempt($email, $password)) {
15+
redirect('/');
16+
}
2017

21-
$form->error('email', 'No matching account found for that email address and password.');
18+
$form->error('email', 'No matching account found for that email address and password.');
2219
}
2320

2421
Session::flash('errors', $form->errors());
2522
Session::flash('old', [
26-
'email' => $_POST['email']
23+
'email' => $_POST['email'],
2724
]);
2825

29-
3026
return redirect('/login');

‎bootstrap.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<?php
32

43
use Core\App;
@@ -8,9 +7,9 @@
87
$container = new Container();
98

109
$container->bind('Core\Database', function () {
11-
$config = require base_path('config.php');
10+
$config = require base_path('config.php');
1211

13-
return new Database($config['database']);
12+
return new Database($config['database']);
1413
});
1514

1615
App::setContainer($container);

‎config.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<?php
22

33
return [
4-
54
'database' => [
65
'host' => 'localhost',
76
'port' => '3306',
87
'dbname' => 'myapp',
98
'charset' => 'utf8mb4',
10-
11-
]
12-
9+
],
1310
];

‎public/index.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
session_start();
66

7-
87
const BASE_PATH = __DIR__ . '/../';
98

109
require BASE_PATH . 'Core/functions.php';
1110

1211
require base_path('Core/response.php');
1312

1413
spl_autoload_register(function ($class) {
15-
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
14+
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
1615

17-
require base_path("{$class}.php");
16+
require base_path("{$class}.php");
1817
});
1918

2019
require base_path('bootstrap.php');

‎routes.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
$router->get('/', 'index.php');
54

65
$router->get('/about', 'about.php');
@@ -9,13 +8,13 @@
98

109
$router->get('/notes', 'notes/index.php')->only('auth');
1110

12-
$router->get('/notes', 'notes/show.php');
11+
$router->get('/note', 'notes/show.php');
1312

1413
$router->delete('/note', 'notes/destroy.php');
1514

1615
$router->get('/note/edit', 'notes/edit.php');
1716

18-
$router->patch('/notes', 'notes/update.php');
17+
$router->patch('/note', 'notes/update.php');
1918

2019
$router->get('/notes/create', 'notes/create.php');
2120

‎views/403.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?php require base_path("views/partials/head.php") ?>
2-
<?php require base_path("views/partials/nav.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
2+
<?php require base_path('views/partials/nav.php'); ?>
33

44
<main>
55
<div class="mx-auto mx-w-7xl py-6 sm:px-6 lg:px8">
@@ -10,4 +10,4 @@
1010
</p>
1111
</div>
1212
</main>
13-
<?php require base_path("views/partials/footer.php") ?>
13+
<?php require base_path('views/partials/footer.php'); ?>

‎views/404.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?php require base_path("views/partials/head.php") ?>
2-
<?php require base_path("views/partials/nav.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
2+
<?php require base_path('views/partials/nav.php'); ?>
33

44
<main>
55
<div class="mx-auto max-w-7-xl py-6 sm:px-6 lg:px-8">
@@ -10,4 +10,4 @@
1010
</div>
1111
</main>
1212

13-
<?php require base_path("views/partials/footer.php") ?>
13+
<?php require base_path('views/partials/footer.php'); ?>

‎views/about.view.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?php require base_path("views/partials/head.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
22

3-
<?php require base_path("views/partials/nav.php") ?>
3+
<?php require base_path('views/partials/nav.php'); ?>
44

55

6-
<?php require base_path("views/partials/banner.php") ?>
6+
<?php require base_path('views/partials/banner.php'); ?>
77

88
<main>
99

@@ -16,4 +16,4 @@
1616
</main>
1717

1818

19-
<?php base_path("views/partials/footer.php") ?>
19+
<?php base_path('views/partials/footer.php'); ?>

‎views/contact.view.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
<?php require base_path("views/partials/head.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
22

3-
<?php require base_path("views/partials/nav.php") ?>
4-
5-
<?php require base_path("views/partials/banner.php") ?>
3+
<?php require base_path('views/partials/nav.php'); ?>
64

5+
<?php require base_path('views/partials/banner.php'); ?>
76

87
<main>
98
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
@@ -14,5 +13,4 @@
1413

1514
</main>
1615

17-
18-
<?php require base_path("views/partials/footer.php") ?>
16+
<?php require base_path('views/partials/footer.php'); ?>

‎views/index.view.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<?php require base_path("views/partials/head.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
22

3-
<?php require base_path("views/partials/nav.php") ?>
3+
<?php require base_path('views/partials/nav.php'); ?>
44

5-
<?php require base_path("views/partials/banner.php") ?>
5+
<?php require base_path('views/partials/banner.php'); ?>
66

77
<main>
88

@@ -14,4 +14,4 @@
1414

1515
</main>
1616

17-
<?php require base_path("views/partials/footer.php") ?>
17+
<?php require base_path('views/partials/footer.php'); ?>

‎views/notes/create.view.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?php require base_path("views/partials/head.php") ?>
2-
<?php require base_path("views/partials/nav.php") ?>
3-
<?php require base_path("views/partials/banner.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
2+
<?php require base_path('views/partials/nav.php'); ?>
3+
<?php require base_path('views/partials/banner.php'); ?>
44

55
<main>
66

@@ -17,7 +17,7 @@
1717

1818
<?php if (isset($errors['body'])) : ?>
1919

20-
<p class="text-red-500 text-xs mt-2"><?= $errors['body'] ?></p>
20+
<p class="text-red-500 text-xs mt-2"><?= $errors['body'] ?></p>
2121

2222
<?php endif; ?>
2323

@@ -35,4 +35,4 @@
3535
</div>
3636
</main>
3737

38-
<?php require base_path('views/partials/footer.php') ?>
38+
<?php require base_path('views/partials/footer.php'); ?>

‎views/notes/edit.view.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?php require base_path('views/partials/head.php') ?>
2-
<?php require base_path('views/partials/nav.php') ?>
3-
<?php require base_path('views/partials/banner.php') ?>
1+
<?php require base_path('views/partials/head.php'); ?>
2+
<?php require base_path('views/partials/nav.php'); ?>
3+
<?php require base_path('views/partials/banner.php'); ?>
44

55
<main>
66
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
@@ -19,7 +19,7 @@
1919
<textarea id="body" name="body" rows="3" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="Here's an idea for a note..."><?= $note['body'] ?></textarea>
2020

2121
<?php if (isset($errors['body'])) : ?>
22-
<p class="text-red-500 text-xs mt-2"><?= $errors['body'] ?></p>
22+
<p class="text-red-500 text-xs mt-2"><?= $errors['body'] ?></p>
2323
<?php endif; ?>
2424
</div>
2525
</div>
@@ -48,4 +48,4 @@
4848
</div>
4949
</main>
5050

51-
<?php require base_path('views/partials/footer.php') ?>
51+
<?php require base_path('views/partials/footer.php'); ?>

‎views/notes/index.view.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
<?php require base_path("views/partials/head.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
22

3-
<?php require base_path("views/partials/nav.php") ?>
4-
<?php require base_path("views/partials/banner.php") ?>
3+
<?php require base_path('views/partials/nav.php'); ?>
4+
<?php require base_path('views/partials/banner.php'); ?>
55

66
<main>
77
<div class="mx-auto max-w-7xl py-6 sm:px-6 lg:px-8">
88
<ul>
99
<?php foreach ($notes as $note) : ?>
10-
<li>
11-
<a href="/note?id=<?= $note['id'] ?>" class="text-blue-500 hover:underline">
12-
<?= htmlspecialchars($note['body']) ?>
13-
</a>
14-
</li>
10+
<li>
11+
<a href="/note?id=<?= $note['id'] ?>" class="text-blue-500 hover:underline">
12+
<?= htmlspecialchars($note['body']) ?>
13+
</a>
14+
</li>
1515
<?php endforeach; ?>
1616
</ul>
1717
<p class="mt-6">
@@ -20,4 +20,4 @@
2020
</div>
2121
</main>
2222

23-
<?php require base_path("views/partials/footer.php") ?>
23+
<?php require base_path('views/partials/footer.php'); ?>

‎views/notes/show.view.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<?php require base_path("views/partials/head.php") ?>
1+
<?php require base_path('views/partials/head.php'); ?>
22

3-
<?php require base_path("views/partials/nav.php") ?>
4-
<?php require base_path("views/partials/banner.php") ?>
3+
<?php require base_path('views/partials/nav.php'); ?>
4+
<?php require base_path('views/partials/banner.php'); ?>
55

66
<main>
77

@@ -24,4 +24,4 @@
2424

2525
</main>
2626

27-
<?php require base_path("views/partials/footer.php") ?>
27+
<?php require base_path('views/partials/footer.php'); ?>

‎views/partials/banner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<header class="bg-white shadow">
22
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
3-
<h1 class="text-3xl font-bold tracking-tight text-gray-900">Hello <?= ($_SESSION['user']['email']) ?? 'Guest user'; ?></h1>
3+
<h1 class="text-3xl font-bold tracking-tight text-gray-900">Hello <?= $_SESSION['user']['email'] ?? 'Guest user' ?></h1>
44
</div>
55
</header>

‎views/partials/nav.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
<?php if ($_SESSION['user'] ?? false) : ?>
3535

36-
<img class="h-8 w-8 rounded-full" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
36+
<img class="h-8 w-8 rounded-full" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
3737
<?php else : ?>
38-
<a href="/register" class="<?= urlIs('/register') ? 'bg-gray-900 text-white' : 'text-gray-300' ?>bg-gray-900 text-white hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">Register</a>
38+
<a href="/register" class="<?= urlIs('/register') ? 'bg-gray-900 text-white' : 'text-gray-300' ?>bg-gray-900 text-white hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">Register</a>
3939

40-
<a href="/login" class="<?= urlIs('/login') ? 'bg-gray-900 text-white' : 'text-gray-300' ?>bg-gray-900 text-white hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">Log In</a>
40+
<a href="/login" class="<?= urlIs('/login') ? 'bg-gray-900 text-white' : 'text-gray-300' ?>bg-gray-900 text-white hover:bg-gray-700 hover:text-white rounded-md px-3 py-2 text-sm font-medium">Log In</a>
4141

4242
<?php endif; ?>
4343
</button>
@@ -48,14 +48,14 @@
4848

4949

5050
<?php if ($_SESSION['user'] ?? false) : ?>
51-
<div class="ml-3">
52-
<form method="post" action="/session">
51+
<div class="ml-3">
52+
<form method="post" action="/session">
5353

54-
<input type="hidden" name="_method" value="DELETE">
54+
<input type="hidden" name="_method" value="DELETE">
5555

56-
<button class="text-white">Log Out</button>
57-
</form>
58-
</div>
56+
<button class="text-white">Log Out</button>
57+
</form>
58+
</div>
5959
<?php endif; ?>
6060

6161
</div>

‎views/registration/create.view.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
<?php require base_path('views/partials/head.php') ?>
2-
<?php require base_path('views/partials/nav.php') ?>
1+
<?php require base_path('views/partials/head.php'); ?>
2+
<?php require base_path('views/partials/nav.php'); ?>
33

44
<main>
5-
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
6-
<div class="w-full max-w-md space-y-8">
7-
<div>
8-
<img class="mx-auto h-12 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company">
9-
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">Register for a new
10-
account</h2>
11-
</div>
5+
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
6+
<div class="w-full max-w-md space-y-8">
7+
<div>
8+
<img class="mx-auto h-12 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company">
9+
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">Register for a new
10+
account</h2>
11+
</div>
1212

13-
<form class="mt-8 space-y-6" action="/register" method="POST">
14-
<div class="-space-y-px rounded-md shadow-sm">
15-
<div>
16-
<label for="email" class="sr-only">Email address</label>
17-
<input id="email" name="email" type="email" autocomplete="email" required class="relative block w-full appearance-none rounded-none rounded-t-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Email address">
18-
</div>
13+
<form class="mt-8 space-y-6" action="/register" method="POST">
14+
<div class="-space-y-px rounded-md shadow-sm">
15+
<div>
16+
<label for="email" class="sr-only">Email address</label>
17+
<input id="email" name="email" type="email" autocomplete="email" required class="relative block w-full appearance-none rounded-none rounded-t-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Email address">
18+
</div>
1919

20-
<div>
21-
<label for="password" class="sr-only">Password</label>
22-
<input id="password" name="password" type="password" autocomplete="current-password" required class="relative block w-full appearance-none rounded-none rounded-b-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Password">
23-
</div>
24-
</div>
20+
<div>
21+
<label for="password" class="sr-only">Password</label>
22+
<input id="password" name="password" type="password" autocomplete="current-password" required class="relative block w-full appearance-none rounded-none rounded-b-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Password">
23+
</div>
24+
</div>
2525

26-
<div>
27-
<button type="submit" class="group relative flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
28-
Register
29-
</button>
30-
</div>
26+
<div>
27+
<button type="submit" class="group relative flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
28+
Register
29+
</button>
30+
</div>
3131

32-
<ul>
33-
<?php if (isset($errors['email'])) : ?>
34-
<li class="text-red-500 text-xs mt-2"><?= $errors['email'] ?></li>
35-
<?php endif; ?>
32+
<ul>
33+
<?php if (isset($errors['email'])) : ?>
34+
<li class="text-red-500 text-xs mt-2"><?= $errors['email'] ?></li>
35+
<?php endif; ?>
3636

37-
<?php if (isset($errors['password'])) : ?>
38-
<li class="text-red-500 text-xs mt-2"><?= $errors['password'] ?></li>
39-
<?php endif; ?>
40-
</ul>
41-
</form>
37+
<?php if (isset($errors['password'])) : ?>
38+
<li class="text-red-500 text-xs mt-2"><?= $errors['password'] ?></li>
39+
<?php endif; ?>
40+
</ul>
41+
</form>
42+
</div>
4243
</div>
43-
</div>
4444
</main>
4545

46-
<?php require base_path('views/partials/footer.php') ?>
46+
<?php require base_path('views/partials/footer.php'); ?>

‎views/session/create.view.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
<?php require base_path('views/partials/head.php') ?>
2-
<?php require base_path('views/partials/nav.php') ?>
1+
<?php require base_path('views/partials/head.php'); ?>
2+
<?php require base_path('views/partials/nav.php'); ?>
33

44
<main>
5-
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
6-
<div class="w-full max-w-md space-y-8">
7-
<div>
8-
<img class="mx-auto h-12 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company">
9-
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">Log In for
10-
account</h2>
11-
</div>
5+
<div class="flex min-h-full items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
6+
<div class="w-full max-w-md space-y-8">
7+
<div>
8+
<img class="mx-auto h-12 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company">
9+
<h2 class="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900">Log In for
10+
account</h2>
11+
</div>
1212

13-
<form class="mt-8 space-y-6" action="/session" method="POST">
14-
<div class="-space-y-px rounded-md shadow-sm">
15-
<div>
16-
<label for="email" class="sr-only">Email address</label>
17-
<input id="email" name="email" type="email" autocomplete="email" required class="relative block w-full appearance-none rounded-none rounded-t-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Email address" value="<?= old('email') ?>">
18-
</div>
13+
<form class="mt-8 space-y-6" action="/session" method="POST">
14+
<div class="-space-y-px rounded-md shadow-sm">
15+
<div>
16+
<label for="email" class="sr-only">Email address</label>
17+
<input id="email" name="email" type="email" autocomplete="email" required class="relative block w-full appearance-none rounded-none rounded-t-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Email address" value="<?= old('email') ?>">
18+
</div>
1919

20-
<div>
21-
<label for="password" class="sr-only">Password</label>
22-
<input id="password" name="password" type="password" autocomplete="current-password" required class="relative block w-full appearance-none rounded-none rounded-b-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Password">
23-
</div>
24-
</div>
20+
<div>
21+
<label for="password" class="sr-only">Password</label>
22+
<input id="password" name="password" type="password" autocomplete="current-password" required class="relative block w-full appearance-none rounded-none rounded-b-md border border-gray-300 px-3 py-2 text-gray-900 placeholder-gray-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" placeholder="Password">
23+
</div>
24+
</div>
2525

26-
<div>
27-
<button type="submit" class="group relative flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
28-
Log In
29-
</button>
30-
</div>
26+
<div>
27+
<button type="submit" class="group relative flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
28+
Log In
29+
</button>
30+
</div>
3131

32-
<ul>
33-
<?php if (isset($errors['email'])) : ?>
34-
<li class="text-red-500 text-xs mt-2"><?= $errors['email'] ?></li>
35-
<?php endif; ?>
32+
<ul>
33+
<?php if (isset($errors['email'])) : ?>
34+
<li class="text-red-500 text-xs mt-2"><?= $errors['email'] ?></li>
35+
<?php endif; ?>
3636

37-
<?php if (isset($errors['password'])) : ?>
38-
<li class="text-red-500 text-xs mt-2"><?= $errors['password'] ?></li>
39-
<?php endif; ?>
40-
</ul>
41-
</form>
37+
<?php if (isset($errors['password'])) : ?>
38+
<li class="text-red-500 text-xs mt-2"><?= $errors['password'] ?></li>
39+
<?php endif; ?>
40+
</ul>
41+
</form>
42+
</div>
4243
</div>
43-
</div>
4444
</main>
4545

46-
<?php require base_path('views/partials/footer.php') ?>
46+
<?php require base_path('views/partials/footer.php'); ?>

0 commit comments

Comments
 (0)
Please sign in to comment.