0
votes

I am a new programmer on laravel. I am currently using laravel 5.2. I ran into this error while i was trying to input data into a form i created as welcome.blade.php. I have check the route and it seems very okay. I dont what i may be doing wrong. This is problem display ReflectionException in Route.php line 280: Method App\Http\Controllers\UserController::Signup() does not exist

UserController

<?php

namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;

class UserController extends Controller
{

    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()->back();
    }

    public function postSignIn(Request $request)
    {

    }
}

Routes

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::group(['middleware' => ['web']], function () {
    Route::get('/', function () {
        return view('welcome');
    });

    Route::post('/signup', [
        'uses' => 'UserController@Signup',
        'as'   => 'signup',
    ]);
});

welcome.blade.php

@extends('layouts.master')
@section('title')
    Welcome!
@endsection
@section('content')
    <div class="row">
        <div class="col-md-6">
            <h2>Sign Up</h2>
            <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">Your First Name</label>
                    <input class="form-control" type="text" name="first_name" id="first_name">
                </div>

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

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

        <div class="col-md-6">
            <h2>Sign In</h2>
            <form action="#" 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">Your Password</label>
                    <input class="form-control" type="text" name="password" id="password"></div>

                <button type="submit" class="btn btn-primary">Submit</button>
            </form>
        </div>
    </div>
@endsection
2
use same name that you used in route fileRajesh kumar
Just an FYI, the first form in your blade file was missing a closing tag.Rwd

2 Answers

0
votes

You're using diffrent function name according to route, both will be same. Replace your function name with this:-

postSignUp to SignUp
0
votes

Thanks for your contribution as suggested i change the postSignUp to SignUp in the userController

public function postSignUp(Request $request)
change to
 public function SignUp(Request $request)
also in the route I change the
 'uses' => 'UserController@Signup',
change to
 'uses' => 'UserController@SignUp',