I am new to laravel here i am trying to make a simple registration and login form,Registration form register the user in the database and login form login the user,But here i am getting this error been trying to solve this issue for many hours looked into many resources but can't figure it out,Any help would be appreciated..Thanks

Error:Undefined property: Illuminate\Support\Facades\Request::$email

Blade

@extends("layouts.master")

@section('title')
  My page
@endsection

@section('content')
  <div class="row">
    <div class="col-md-6">
      <h3>Sign-Up</h3>
      <form action="{{ route('signup') }}" method="post">

        <div class="form-group">
          <label for="email">Your email</label>
          <input class="form-control" type="text" name="email" id="email">
        </div>

        <div class="form-group">
          <label for="first_name">First Name</label>
          <input class="form-control" type="text" name="first_name" id="first_name">
        </div>

        <div class="form-group">
          <label for="password">Password</label>
          <input class="form-control"  type="password" name="password" id="password">
        </div>

        <button type="sumbit" class="btn btn-primary">sumbit</button>
        <input type="hidden" name="_token" value="{{ Session::token() }}">

      </form>
    </div>

    <div class="col-md-6">
      <h3>Login </h3>
      <form action="{{ route('signin') }}" method="post">

        <div class="form-group">
          <label for="email">Your email</label>
          <input class="form-control" type="text" name="email" id="email">
        </div>

        <div class="form-group">
          <label for="password">Password</label>
          <input class="form-control"  type="password" name="password" id="password">
        </div>

        <button type="sumbit" class="btn btn-primary">sumbit</button>
        <input type="hidden" name="_token" value="{{ Session::token() }}">

      </form>
    </div>
  </div>
@endsection
use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

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


Route::post('/signup', [
    'uses' => 'UserContro[email protected]',
    'as' => 'signup'

]);


Route::post('/signin', [
    'uses' => '[email protected]',
    'as' => 'signin'

]);

Route::get('/dashboard', [
    'uses' => '[email protected]',
    'as' => 'dashboard'

]);


Auth::routes();

Route::get('/home', '[email protected]')->name('home');

Controller

namespace App\Http\Controllers;

use App\Http\Requests;
use App\User;
use App\UserTypes;

use Auth;
use Hashids;
use Redirect;
use Request;
use Hash;


class UserController extends controller
{
    public function getdashboard()
    {
        return view('dashboard');
    }

    public function postSignUp(Request $request)
    {
        $email = $request->email;
        $first_name = $request->first_name;
        $password = bcrypt($request->password);


        $user = new User();
        $user->email = $email;
        $user->first_name = $first_name;
        $user->password = $password;

        $user->save();
        return redirect()->route('dashboard');
    }

    public function postSignIn(Request $request)
    {
        if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) {
            return redirect()->route('dashboard');
        }
        return redirect()->back();
    }
}

2 Answers

0
Community On

Change your Controller Function

use Illuminate\Http\Request;
public function postSignUp(Request $request)
{
    $email = $request->input('email');
    $first_name = $request->input('first_name');
    $password = bcrypt($request->input('password'));


    $user = new User();
    $user->email = $email;
    $user->first_name = $first_name;
    $user->password = $password;

    $user->save();
    return redirect()->route('dashboard');
}
public function postSignIn(Request $request)
{
    if (Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')])) {
        return redirect()->route('dashboard');
    }
    return redirect()->back();
}
0
ghanshyam nakiya On

This helps importing use Illuminate\Http\Request; instead of use Request;

use Illuminate\Http\Request; 

class UserController extends controller{
}