|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Xetaravel\Http\Controllers; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Contracts\View\Factory; |
|
8
|
|
|
use Illuminate\Foundation\Application; |
|
9
|
|
|
use Illuminate\Http\RedirectResponse; |
|
10
|
|
|
use Illuminate\Http\Request ; |
|
11
|
|
|
use Illuminate\Support\Facades\App; |
|
12
|
|
|
use Illuminate\Support\Facades\Auth; |
|
13
|
|
|
use Illuminate\Support\Facades\Mail; |
|
14
|
|
|
use Illuminate\Support\Facades\Validator; |
|
15
|
|
|
use Illuminate\View\View; |
|
16
|
|
|
use Xetaravel\Models\BlogArticle; |
|
17
|
|
|
use Xetaravel\Mail\Contact; |
|
18
|
|
|
|
|
19
|
|
|
class PageController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Show the home page. |
|
23
|
|
|
* |
|
24
|
|
|
* @return Factory|\Illuminate\Contracts\View\View|Application|object|View |
|
25
|
|
|
*/ |
|
26
|
|
|
public function index() |
|
27
|
|
|
{ |
|
28
|
|
|
$article = BlogArticle::with('category', 'user') |
|
29
|
|
|
->latest() |
|
30
|
|
|
->first(); |
|
31
|
|
|
|
|
32
|
|
|
return view('page.index', ['article' => $article]); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Display the terms page. |
|
37
|
|
|
* |
|
38
|
|
|
* @return Application|Factory|\Illuminate\Contracts\View\View|object|View |
|
39
|
|
|
*/ |
|
40
|
|
|
public function terms() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->breadcrumbs->addCrumb( |
|
43
|
|
|
'<svg class="w-4 h-4 mr-2" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M0 64C0 28.7 28.7 0 64 0L224 0l0 128c0 17.7 14.3 32 32 32l128 0 0 47-92.8 37.1c-21.3 8.5-35.2 29.1-35.2 52c0 56.6 18.9 148 94.2 208.3c-9 4.8-19.3 7.6-30.2 7.6L64 512c-35.3 0-64-28.7-64-64L0 64zm384 64l-128 0L256 0 384 128zm39.1 97.7c5.7-2.3 12.1-2.3 17.8 0l120 48C570 277.4 576 286.2 576 296c0 63.3-25.9 168.8-134.8 214.2c-5.9 2.5-12.6 2.5-18.5 0C313.9 464.8 288 359.3 288 296c0-9.8 6-18.6 15.1-22.3l120-48zM527.4 312L432 273.8l0 187.8c68.2-33 91.5-99 95.4-149.7z"></path></svg> Terms', |
|
44
|
|
|
route('page.terms') |
|
45
|
|
|
); |
|
46
|
|
|
|
|
47
|
|
|
return view('page.terms', ['breadcrumbs' => $this->breadcrumbs]); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Display the contact page. |
|
52
|
|
|
* |
|
53
|
|
|
* @return View |
|
54
|
|
|
*/ |
|
55
|
|
|
public function showContact(): View |
|
56
|
|
|
{ |
|
57
|
|
|
$this->breadcrumbs->addCrumb('<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path></svg> |
|
58
|
|
|
Contact', route('page.contact')); |
|
59
|
|
|
|
|
60
|
|
|
return view('page.contact', ['breadcrumbs' => $this->breadcrumbs]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Send an E-mail to . |
|
65
|
|
|
* |
|
66
|
|
|
* @param Request $request The current request. |
|
67
|
|
|
* |
|
68
|
|
|
* @return RedirectResponse |
|
69
|
|
|
*/ |
|
70
|
|
|
public function contact(Request $request): RedirectResponse |
|
71
|
|
|
{ |
|
72
|
|
|
$rules = [ |
|
73
|
|
|
'name' => 'required|min:4|max:30', |
|
74
|
|
|
'email' => 'required|email|max:50', |
|
75
|
|
|
'message' => 'required|min:10', |
|
76
|
|
|
]; |
|
77
|
|
|
|
|
78
|
|
|
// Bypass the captcha for the unit testing. |
|
79
|
|
|
if (App::environment() !== 'testing') { |
|
80
|
|
|
$rules = array_merge($rules, ['g-recaptcha-response' => 'required|captcha']); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
Validator::make($request->all(), $rules)->validate(); |
|
84
|
|
|
|
|
85
|
|
|
$details = [ |
|
86
|
|
|
'name' => $request->get('name'), |
|
87
|
|
|
'email' => $request->get('email'), |
|
88
|
|
|
'subject' => $request->get('subject'), |
|
89
|
|
|
'message' => $request->get('message'), |
|
90
|
|
|
'ip' => $request->ip() |
|
91
|
|
|
]; |
|
92
|
|
|
|
|
93
|
|
|
Mail::to(config('xetaravel.site.contact_email'))->send(new Contact($details)); |
|
94
|
|
|
|
|
95
|
|
|
return redirect() |
|
96
|
|
|
->route('page.contact') |
|
|
|
|
|
|
97
|
|
|
->success('Thanks for contacting me ! I will answer you as fast as I can !'); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Display the banished page. |
|
102
|
|
|
* |
|
103
|
|
|
* @return Application|Factory|\Illuminate\Contracts\View\View|object|View |
|
104
|
|
|
*/ |
|
105
|
|
|
public function banished() |
|
106
|
|
|
{ |
|
107
|
|
|
if (!Auth::user()->hasRole('Banished')) { |
|
|
|
|
|
|
108
|
|
|
return redirect() |
|
109
|
|
|
->route('page.index'); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
return view('page.banished'); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Display my custom page. |
|
117
|
|
|
* |
|
118
|
|
|
* @return Application|Factory|\Illuminate\Contracts\View\View|object|View |
|
119
|
|
|
*/ |
|
120
|
|
|
public function aboutme() |
|
121
|
|
|
{ |
|
122
|
|
|
return view('page.aboutme'); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.