Skip to content

Commit 52bf586

Browse files
committed
First commit
0 parents  commit 52bf586

File tree

132 files changed

+230310
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+230310
-0
lines changed

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
10+
11+
DB_CONNECTION=mysql
12+
DB_HOST=127.0.0.1
13+
DB_PORT=3306
14+
DB_DATABASE=project
15+
DB_USERNAME=root
16+
DB_PASSWORD=
17+
18+
BROADCAST_DRIVER=log
19+
CACHE_DRIVER=file
20+
FILESYSTEM_DRIVER=local
21+
QUEUE_CONNECTION=sync
22+
SESSION_DRIVER=file
23+
SESSION_LIFETIME=120
24+
25+
MEMCACHED_HOST=127.0.0.1
26+
27+
REDIS_HOST=127.0.0.1
28+
REDIS_PASSWORD=null
29+
REDIS_PORT=6379
30+
31+
MAIL_MAILER=smtp
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
34+
MAIL_USERNAME=null
35+
MAIL_PASSWORD=null
36+
MAIL_ENCRYPTION=null
37+
MAIL_FROM_ADDRESS=null
38+
MAIL_FROM_NAME="${APP_NAME}"
39+
40+
AWS_ACCESS_KEY_ID=
41+
AWS_SECRET_ACCESS_KEY=
42+
AWS_DEFAULT_REGION=us-east-1
43+
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
45+
46+
PUSHER_APP_ID=
47+
PUSHER_APP_KEY=
48+
PUSHER_APP_SECRET=
49+
PUSHER_APP_CLUSTER=mt1
50+
51+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
52+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
9+
docker-compose.override.yml
10+
Homestead.json
11+
Homestead.yaml
12+
npm-debug.log
13+
yarn-error.log
14+
/.idea
15+
/.vscode

.styleci.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
php:
2+
preset: laravel
3+
version: 8
4+
disabled:
5+
- no_unused_imports
6+
finder:
7+
not-name:
8+
- index.php
9+
- server.php
10+
js:
11+
finder:
12+
not-name:
13+
- webpack.mix.js
14+
css: true

README.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## Test Your Laravel Blade Skills
2+
3+
This repository is a test for you: perform a set of tasks listed below, and fix the PHPUnit tests, which are currently intentionally failing.
4+
5+
To test if all the functions work correctly, there are PHPUnit tests in `tests/Feature/ViewsTest.php` file.
6+
7+
In the very beginning, if you run `php artisan test`, or `vendor/bin/phpunit`, all 8 tests fail.
8+
Your task is to make those tests pass.
9+
10+
11+
## How to Submit Your Solution
12+
13+
If you want to submit your solution, you should make a Pull Request to the `main` branch.
14+
It will automatically run the tests via Github Actions and will show you/me if the test pass.
15+
16+
If you don't know how to make a Pull Request, [here's my video with instructions](https://www.youtube.com/watch?v=vEcT6JIFji0).
17+
18+
This task is mostly self-served, so I'm not planning review or merge the Pull Requests. This test is for yourselves to assess your skills, the automated tests will be your answer if you passed the test :)
19+
20+
21+
## Questions / Problems?
22+
23+
If you're struggling with some of the tasks, or you have suggestions how to improve the task, create a Github Issue.
24+
25+
Good luck!
26+
27+
---
28+
29+
## Task 1. Passing Data to Views.
30+
31+
File `app/Http/Controllers/HomeController.php`, method `users()`, pass the `$usersCount` to the View.
32+
33+
Test method `test_users_list_get_with_values()`.
34+
35+
---
36+
37+
## Task 2. Prevent the XSS Attack.
38+
39+
The page `/alert` will show you a JavaScript alert. You need to change something in `resources/views/alert.blade.php` file, so that this alert would not be thrown, and instead just its HTML would be shown.
40+
41+
Test method `test_script_alert_does_not_fire_modal`.
42+
43+
---
44+
45+
## Task 3. Loop in the Table.
46+
47+
The file `resources/views/table.blade.php` should show the loop of all users, or "No content" row, if no users are in the database.
48+
49+
Test method `test_loop_shows_table_or_empty()`.
50+
51+
---
52+
53+
## Task 4. Styling Table Rows.
54+
55+
Three sub-tasks related to the table and loop, all in file `resources/views/rows.blade.php`:
56+
57+
- in the first column, add the row number: 1, 2, etc.
58+
- only every second row (2nd, 4th, etc) should have CSS class "bg-red-100"
59+
- only the FIRST row should have email column with "font-bold"
60+
61+
Test method `test_rows_styled_with_number()`.
62+
63+
---
64+
65+
## Task 5. Logged-in User.
66+
67+
In the file `resources/views/authenticated.blade.php`, show the appropriate text, if the user is/isn't logged in.
68+
69+
If the user is logged in, show their email.
70+
71+
Test method `test_authenticated()`.
72+
73+
---
74+
75+
## Task 6. Include File.
76+
77+
In the file `resources/views/include.blade.php`, include another Blade file `resources/views/includes/row.blade.php`, passing the parameter correctly.
78+
79+
Test method `test_include_row()`.
80+
81+
---
82+
83+
## Task 7. Global Variable.
84+
85+
In the file `resources/views/layouts/app.blade.php`, there's a "global" variable `$metaTitle`. Pass its value to this view, for all pages, without touching any Controllers.
86+
87+
Test method `test_meta_title()`.
88+
89+
---
90+
91+
## Task 8.
92+
93+
Change the file `resources/views/layout.blade` to extend the `layouts/main.blade.php` (without Blade components) instead of `layouts/app.blade.php` (with Blade components).
94+
95+
Test method `test_layout()`.

app/Console/Kernel.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')->hourly();
28+
}
29+
30+
/**
31+
* Register the commands for the application.
32+
*
33+
* @return void
34+
*/
35+
protected function commands()
36+
{
37+
$this->load(__DIR__.'/Commands');
38+
39+
require base_path('routes/console.php');
40+
}
41+
}

app/Exceptions/Handler.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Auth\LoginRequest;
7+
use App\Providers\RouteServiceProvider;
8+
use Illuminate\Http\Request;
9+
use Illuminate\Support\Facades\Auth;
10+
11+
class AuthenticatedSessionController extends Controller
12+
{
13+
/**
14+
* Display the login view.
15+
*
16+
* @return \Illuminate\View\View
17+
*/
18+
public function create()
19+
{
20+
return view('auth.login');
21+
}
22+
23+
/**
24+
* Handle an incoming authentication request.
25+
*
26+
* @param \App\Http\Requests\Auth\LoginRequest $request
27+
* @return \Illuminate\Http\RedirectResponse
28+
*/
29+
public function store(LoginRequest $request)
30+
{
31+
$request->authenticate();
32+
33+
$request->session()->regenerate();
34+
35+
return redirect()->intended(RouteServiceProvider::HOME);
36+
}
37+
38+
/**
39+
* Destroy an authenticated session.
40+
*
41+
* @param \Illuminate\Http\Request $request
42+
* @return \Illuminate\Http\RedirectResponse
43+
*/
44+
public function destroy(Request $request)
45+
{
46+
Auth::guard('web')->logout();
47+
48+
$request->session()->invalidate();
49+
50+
$request->session()->regenerateToken();
51+
52+
return redirect('/');
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Providers\RouteServiceProvider;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Support\Facades\Auth;
9+
use Illuminate\Validation\ValidationException;
10+
11+
class ConfirmablePasswordController extends Controller
12+
{
13+
/**
14+
* Show the confirm password view.
15+
*
16+
* @return \Illuminate\View\View
17+
*/
18+
public function show()
19+
{
20+
return view('auth.confirm-password');
21+
}
22+
23+
/**
24+
* Confirm the user's password.
25+
*
26+
* @param \Illuminate\Http\Request $request
27+
* @return mixed
28+
*/
29+
public function store(Request $request)
30+
{
31+
if (! Auth::guard('web')->validate([
32+
'email' => $request->user()->email,
33+
'password' => $request->password,
34+
])) {
35+
throw ValidationException::withMessages([
36+
'password' => __('auth.password'),
37+
]);
38+
}
39+
40+
$request->session()->put('auth.password_confirmed_at', time());
41+
42+
return redirect()->intended(RouteServiceProvider::HOME);
43+
}
44+
}

0 commit comments

Comments
 (0)