0

Method [postSignin] does not exist on [App\Http\Controllers\UserController]. I'm trying to create a login in form. The signup worked but when I sign in, I get this error. I'm now getting Parse error: syntax error, unexpected ';', expecting ',' or '

Here is my Route:

Auth::routes();

Route::get('/', function () {
    return view('welcome');
})->name('home');

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

Route::post('/signin', [
    'uses' => 'UserController@postSignIn',
    'as' => 'signin'
]);

Route::get('/dashboard', [
    'uses' => 'UserController@getDashboard',
    'as' => 'dashboard'
]);

My controller:

<?php

namespace App\Http\Controllers;

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;

}

UserController:

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Authenticatable;

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

    Auth::login($user);

    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();
}
public function method(Request $req)
{
    dd($req->all();
}

}

And my blade:

<form action="{{ route('signin') }}" method="post">

What did I do wrong?

pinealda
  • 11
  • 4

1 Answers1

1

in you web.php

route::post('signin','UserControllerr@method')->name('signin');

in your App\Http\Controllers\UserController add like this

public function method(Request $req){
    dd($req->all();
}
bipin
  • 421
  • 8
  • 21
  • I replaced method with @postSignIn. Now I'm getting: Method [method] does not exist on [App\Http\Controllers\UserController]." – pinealda Jan 31 '18 at 09:24
  • @pinealda upadted my answer please check – bipin Jan 31 '18 at 09:27
  • do I put method or SignIn? and it is expecting ',' – pinealda Jan 31 '18 at 09:42
  • @pinealda updated my answer check – bipin Jan 31 '18 at 10:06
  • i'm not sure what you updated.. I have public function method(Request $req) { dd($req->all(); } And I get same error. – pinealda Jan 31 '18 at 10:17
  • @pinealda updated my answer please check – bipin Jan 31 '18 at 10:34
  • Im sorry but Idk what have you updated because I put the same code as you first post and its been same since.. Check my updated post. – pinealda Jan 31 '18 at 19:19
  • @pinealda if you seen carefully you last line of user controller code has error dd($req->all(); here missing is ) so change it to dd($req->all()); .. if you getting error in controller your browser will display error line number. In your case it giving syntax error dd($req->all(); here missing is ) so change it to dd($req->all()); – bipin Feb 01 '18 at 01:56