AuthController.php 979 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Support\Facades\Hash;
  4. class ApplicationController extends Controller
  5. {
  6. public function register()
  7. {
  8. $validated = $request->validate(['login' => ['required', 'string', 'max:255'], 'full_name' => ['required', 'text', 'max:255'], 'password' => ['required', 'string'], 'phone' => ['required', 'string'], 'email' => ['required', 'string', 'max:255']]);
  9. User::create($validated);
  10. }
  11. public function login()
  12. {
  13. $query = User::with();
  14. if ($request->login()) {
  15. $query->where('login')->whereIn('login', $request->login)->first();
  16. if ($query->password === $request->password) {
  17. return view(route('application.index'));
  18. }
  19. return back()->withErrors('Error', "ошибка при попытке входа");
  20. }
  21. return back()->withErrors('Error', "ошибка при попытке входа");
  22. }
  23. }