Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

answers #464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// https://aka.ms/devcontainer.json
{
"name": "Existing Docker Compose (Extend)",
"dockerComposeFile": [
"../docker-compose.yml"
],
"service": "laravel.test",
"workspaceFolder": "/var/www/html",
"customizations": {
"vscode": {
"extensions": [
// "mikestead.dotenv",
// "amiralizadeh9480.laravel-extra-intellisense",
// "ryannaddy.laravel-artisan",
// "onecentlin.laravel5-snippets",
// "onecentlin.laravel-blade"
],
"settings": {}
}
},
"remoteUser": "sail",
"postCreateCommand": "chown -R 1000:1000 /var/www/html"
// "forwardPorts": [],
// "runServices": [],
// "shutdownAction": "none",
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function users()
{
$usersCount = User::count();

return view('users');
return view('users',['usersCount' => $usersCount]);
}

// Task 2. Change the View code so alert would not show on the screen
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function register()
*/
public function boot()
{
//
view()->share('metaTitle', 'Blade Test');
}
}
55 changes: 55 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.2
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.2/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/alert.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
{!! $text !!}
{{ $text }}
Your task is to change the code of alert.blade.php, to avoid that JavaScript alert.
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions resources/views/authenticated.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
{{-- Task: add a condition to show correct text --}}
{{-- If user is logged in, show their email --}}
Yes, I am logged in as [insert_user_email_here].
No, I am not logged in.
@if (Auth::check())
Yes, I am logged in as {{ Auth::user()->email }}.
@else
No, I am not logged in.
@endif
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/views/include.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<tr class="bg-red-100">
{{-- Task: include file resources/views/includes/row.blade.php --}}
{{-- passing the $user variable to it --}}
@include('includes.row')
</tr>
@endforeach
</tbody>
Expand Down
5 changes: 2 additions & 3 deletions resources/views/layout.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<x-app-layout>
@extends('layouts.main')
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
Expand All @@ -9,5 +9,4 @@
</div>
</div>
</div>
</div>
</x-app-layout>
</div>
12 changes: 8 additions & 4 deletions resources/views/rows.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
</tr>
</thead>
<tbody>
@foreach ($users as $user)
@foreach ($users as $user)
{{-- Task: only every second row should have "bg-red-100" --}}
<tr class="bg-red-100">
<td>{{-- Task: add row number here: 1, 2, etc. --}}</td>
<tr @class([
'bg-red-100' => $user->id % 2
])>
<td>{{ $user->id }}</td>
<td>{{ $user->name }}</td>
{{-- Task: only the FIRST row should have email with "font-bold" --}}
<td class="font-bold">{{ $user->email }}</td>
<td @class([
'font-bold' => $user->id == 1
])>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
@endforeach
Expand Down
19 changes: 11 additions & 8 deletions resources/views/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
</thead>
{{-- Task: add the loop here to show users, or the row "No content" --}}
<tbody>
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
<tr>
<td colspan="3">No content.</td>
</tr>
@forelse ($users as $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->created_at }}</td>
</tr>
@empty
<tr>
<td colspan="3">No content.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
Expand Down
Loading