Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

Commit

Permalink
added languages and setup base application
Browse files Browse the repository at this point in the history
  • Loading branch information
idoqo committed Dec 9, 2019
1 parent e686eec commit e0724bf
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
38 changes: 38 additions & 0 deletions app/Http/Controllers/WelcomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;

class WelcomeController extends Controller
{
function showGreetings(Request $request){
// retrieve the language from the GET parameter or default to English
$language = $request->get('language', 'english');

$greetings = $this->greetings($language);
$data = ['greetings' => $greetings];

// return the view template at `resources/views/welcome.blade.php` with the $greetings array.
return view('welcome', $data);
}
function greetings($language) {
switch ($language) {
case "english":
default:
return [
"Hello", "Good Morning", "Good Afternoon", "Good Evening", "Thank you"
];
case "german":
return ["Hallo", "Guten Morgen", "Guten Nachmittag", "Guten Abend", "Danke"];
case "idoma":
return ["Abole", "Uma ònnê", "Uma òchi", "Uma enò", "Ainya",];
case "yoruba":
return ["E Pẹlẹ", "E kaaro", "E Kaasan", "E Kaale", "O ṣeun"];
case "french":
return [
"Bonjour", "Bonjour", "Bonne après-midi",
"Bonsoir",
"Merci"];
}
}
}
32 changes: 23 additions & 9 deletions resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel</title>
<title>Twilio Greeter!</title>

<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
Expand Down Expand Up @@ -39,6 +39,15 @@
right: 10px;
top: 18px;
}
.top-right > a {
color: #636b6f;
padding: 0 24px;
font-size: 13px;
font-weight: 600;
letter-spacing: .05rem;
text-decoration: none;
text-transform: uppercase;
}
.content {
text-align: center;
Expand All @@ -48,14 +57,13 @@
font-size: 84px;
}
.links > a {
.links > p {
color: #636b6f;
padding: 12px 24px;
font-size: 13px;
font-weight: 600;
letter-spacing: .1rem;
text-decoration: none;
text-transform: uppercase;
display: block;
}
Expand All @@ -66,20 +74,26 @@
</head>
<body>
<div class="flex-center position-ref full-height">
<div class="top-right links">
<a href="{{ url('/?language=english') }}">English</a>
<a href="{{ url('/?language=german') }}">German</a>
<a href="{{ url('/?language=idoma') }}">Idoma</a>
<a href="{{ url('/?language=yoruba') }}">Yoruba</a>
<a href="{{ url('/?language=french') }}">French</a>
</div>

<div class="content">
<div class="title m-b-md">
Twilio Greeter
</div>

<div class="links">
<a href="#">Docs</a>
<a href="#">Laracasts</a>
<a href="#">News</a>
<a href="#">Blog</a>
<a href="#">Nova</a>
<a href="#">Forge</a>
@foreach ($greetings as $greeting)
<p>{{$greeting}}</p>
@endforeach
</div>
</div>
</div>

</body>
</html>
4 changes: 1 addition & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@
|
*/

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

0 comments on commit e0724bf

Please sign in to comment.