|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Response\enso\core; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Contracts\Support\Responsable; |
|
6
|
|
|
use Illuminate\Support\Collection; |
|
7
|
|
|
use Illuminate\Support\Facades\App; |
|
8
|
|
|
use Illuminate\Support\Facades\Route; |
|
9
|
|
|
|
|
10
|
|
|
class GuestState implements Responsable |
|
11
|
|
|
{ |
|
12
|
|
|
public function toResponse($request): array |
|
13
|
|
|
{ |
|
14
|
|
|
if ($request->has('locale')) { |
|
15
|
|
|
App::setLocale($request->get('locale')); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
return [ |
|
19
|
|
|
'meta' => $this->meta(), |
|
20
|
|
|
'i18n' => $this->i18n(), |
|
21
|
|
|
'routes' => $this->routes(), |
|
22
|
|
|
]; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
protected function meta(): array |
|
26
|
|
|
{ |
|
27
|
|
|
return [ |
|
28
|
|
|
'appName' => config('app.name'), |
|
29
|
|
|
'appUrl' => url('/').'/', |
|
30
|
|
|
'extendedDocumentTitle' => config('enso.config.extendedDocumentTitle'), |
|
31
|
|
|
'showQuote' => config('enso.config.showQuote'), |
|
32
|
|
|
]; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
protected function i18n(): array |
|
36
|
|
|
{ |
|
37
|
|
|
return [ |
|
38
|
|
|
App::getLocale() => [ |
|
39
|
|
|
'Email' => __('Email'), |
|
40
|
|
|
'Password' => __('Password'), |
|
41
|
|
|
'Remember me' => __('Remember me'), |
|
42
|
|
|
'Forgot password' => __('Forgot password'), |
|
43
|
|
|
'Login' => __('Login'), |
|
44
|
|
|
'Send a reset password link' => __('Send a reset password link'), |
|
45
|
|
|
'Repeat Password' => __('Repeat Password'), |
|
46
|
|
|
'Success' => __('Success'), |
|
47
|
|
|
'Error' => __('Error'), |
|
48
|
|
|
], |
|
49
|
|
|
]; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
protected function routes(): Collection |
|
53
|
|
|
{ |
|
54
|
|
|
$authRoutes = new Collection(['login', 'password.email', 'password.reset']); |
|
55
|
|
|
|
|
56
|
|
|
return (new Collection(Route::getRoutes()->getRoutesByName())) |
|
57
|
|
|
->filter(fn ($route, $name) => $authRoutes->contains($name)) |
|
58
|
|
|
->map(fn ($route) => (new Collection($route)) |
|
59
|
|
|
->only(['uri', 'methods']) |
|
60
|
|
|
->put('domain', $route->domain())); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|