aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r--app/Http/Controllers/Auth/ForgotPasswordController.php32
-rw-r--r--app/Http/Controllers/Auth/LoginController.php39
-rw-r--r--app/Http/Controllers/Auth/RegisterController.php76
-rw-r--r--app/Http/Controllers/Auth/ResetPasswordController.php34
-rw-r--r--app/Http/Controllers/Controller.php7
-rw-r--r--app/Http/Controllers/RandomVerbController.php3
-rw-r--r--app/Http/Controllers/RootController.php3
-rw-r--r--app/Http/Controllers/UserController.php67
-rw-r--r--app/Http/Controllers/VerbController.php5
9 files changed, 190 insertions, 76 deletions
diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php
new file mode 100644
index 0000000..a36a6f4
--- /dev/null
+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
+
+class ForgotPasswordController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reset Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller is responsible for handling password reset emails and
+ | includes a trait which assists in sending these notifications from
+ | your application to your users. Feel free to explore this trait.
+ |
+ */
+
+ use SendsPasswordResetEmails;
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
+}
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
new file mode 100644
index 0000000..4c81bea
--- /dev/null
+++ b/app/Http/Controllers/Auth/LoginController.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\AuthenticatesUsers;
+
+class LoginController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Login Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller handles authenticating users for the application and
+ | redirecting them to your home screen. The controller uses a trait
+ | to conveniently provide its functionality to your applications.
+ |
+ */
+
+ use AuthenticatesUsers;
+
+ /**
+ * Where to redirect users after login.
+ *
+ * @var string
+ */
+ protected $redirectTo = '/contribute';
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest', ['except' => 'logout']);
+ }
+}
diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php
new file mode 100644
index 0000000..ed46cab
--- /dev/null
+++ b/app/Http/Controllers/Auth/RegisterController.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use HebrewParseTrainer\User;
+use Validator;
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\RegistersUsers;
+
+class RegisterController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Register Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller handles the registration of new users as well as their
+ | validation and creation. By default this controller uses a trait to
+ | provide this functionality without requiring any additional code.
+ |
+ */
+
+ use RegistersUsers;
+
+ /**
+ * Where to redirect users after login / registration.
+ *
+ * @var string
+ */
+ protected $redirectTo = '/';
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
+
+ /**
+ * Get a validator for an incoming registration request.
+ *
+ * @param array $data
+ * @return \Illuminate\Contracts\Validation\Validator
+ */
+ protected function validator(array $data)
+ {
+ return Validator::make($data, [
+ 'name' => 'required|max:255',
+ 'email' => 'required|email|max:255|unique:users',
+ 'password' => 'required|min:6|confirmed',
+ ]);
+ }
+
+ /**
+ * Create a new user instance after a valid registration.
+ *
+ * @param array $data
+ * @return User
+ */
+ protected function create(array $data)
+ {
+ $user = new User([
+ 'name' => $data['name'],
+ 'email' => $data['email'],
+ ]);
+
+ $user->password = $data['password'];
+
+ $user->save();
+
+ return $user;
+ }
+}
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php
new file mode 100644
index 0000000..98d1131
--- /dev/null
+++ b/app/Http/Controllers/Auth/ResetPasswordController.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Http\Controllers\Auth;
+
+use App\Http\Controllers\Controller;
+use Illuminate\Foundation\Auth\ResetsPasswords;
+
+class ResetPasswordController extends Controller
+{
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reset Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller is responsible for handling password reset requests
+ | and uses a simple trait to include this behavior. You're free to
+ | explore this trait and override any methods you wish to tweak.
+ |
+ */
+
+ use ResetsPasswords;
+
+ protected $redirectTo = '/';
+
+ /**
+ * Create a new controller instance.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
+}
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 0ccb918..03e02a2 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -2,9 +2,12 @@
namespace App\Http\Controllers;
-use Laravel\Lumen\Routing\Controller as BaseController;
+use Illuminate\Foundation\Bus\DispatchesJobs;
+use Illuminate\Routing\Controller as BaseController;
+use Illuminate\Foundation\Validation\ValidatesRequests;
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
- //
+ use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
diff --git a/app/Http/Controllers/RandomVerbController.php b/app/Http/Controllers/RandomVerbController.php
index 501440a..ceb5ff9 100644
--- a/app/Http/Controllers/RandomVerbController.php
+++ b/app/Http/Controllers/RandomVerbController.php
@@ -22,9 +22,8 @@ use HebrewParseTrainer\Verb;
use HebrewParseTrainer\RandomLog;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
-use Laravel\Lumen\Routing\Controller as BaseController;
-class RandomVerbController extends BaseController {
+class RandomVerbController extends Controller {
public function show()
{
diff --git a/app/Http/Controllers/RootController.php b/app/Http/Controllers/RootController.php
index 3899754..5546a1d 100644
--- a/app/Http/Controllers/RootController.php
+++ b/app/Http/Controllers/RootController.php
@@ -21,12 +21,11 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
-use Laravel\Lumen\Routing\Controller as BaseController;
use HebrewParseTrainer\Root;
use HebrewParseTrainer\RootKind;
-class RootController extends BaseController {
+class RootController extends Controller {
public function create(Request $request) {
$_kinds = RootKind::all();
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
deleted file mode 100644
index 7036439..0000000
--- a/app/Http/Controllers/UserController.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * HebrewParseTrainer - practice Hebrew verbs
- * Copyright (C) 2015 Camil Staps <info@camilstaps.nl>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-namespace App\Http\Controllers;
-
-use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Validator;
-use Illuminate\Validation\ValidationException;
-use Laravel\Lumen\Routing\Controller as BaseController;
-
-use HebrewParseTrainer\User;
-
-class UserController extends BaseController {
-
- public function createForm(Request $request) {
- $messages = [];
-
- if ($request->isMethod('post')) {
- $validator = Validator::make($request->input(), [
- 'email' => 'required|unique:users|email',
- 'name' => 'required|unique:users',
- 'password' => 'required|confirmed|min:8',
- ]);
-
- if ($validator->fails()) {
- foreach ($validator->errors()->all() as $error) {
- $messages[] = ['danger', $error];
- }
- } else {
- $user = new User;
- $user->name = $request->input('name');
- $user->email = $request->input('email');
- $user->password = $request->input('password');
- if ($user->save()) {
- $messages[] = ['success', 'Your account has been created.'];
- } else {
- $messages[] = ['danger', 'Your account could not be created.'];
- }
- }
- }
-
- return view('user.create',
- [
- 'messages' => $messages,
- 'form' => [
- 'email' => $request->input('email'),
- 'name' => $request->input('name')
- ]
- ]);
- }
-
-}
diff --git a/app/Http/Controllers/VerbController.php b/app/Http/Controllers/VerbController.php
index 18cdd2f..59289c1 100644
--- a/app/Http/Controllers/VerbController.php
+++ b/app/Http/Controllers/VerbController.php
@@ -29,9 +29,8 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Validator;
-use Laravel\Lumen\Routing\Controller as BaseController;
-class VerbController extends BaseController {
+class VerbController extends Controller {
public function random() {
$verbs = Verb::where('active', 1)->get();
@@ -129,7 +128,7 @@ class VerbController extends BaseController {
return true;
}
- public function vote($choice, $verb_id) {
+ public function vote($verb_id, $choice) {
$verb = Verb::findOrFail($verb_id);
$user = Auth::user();