I'm a begginer in this PHP framework, Laravel .. so I got this problem , tryin' to fix it from hours and does't work.
FatalErrorException in routes.php line 24: syntax error, unexpected '}'
i have maded all the steps until here , learning from this course of Mindspace on youtube , https://www.youtube.com/watch?v=hJIc9lVTJj4&index=1&list=PL55RiY5tL51oloSGk5XdO2MGjPqc0BxGV#t=741.263237
(ps. i have maded also the connection with database and all these stuffs presented in that tutorial)
my routes.php
<?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.
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function() {
Route::get('/', function () {
return view('welcome');
});
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
])
}); ---- line 24 is here
and UserController.php
namespace App\Http\Controllers;
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)
{
}
}
and the welcome.blade.php
<div class="col-md-6">
<h3>Sign Up</h3>
<form action="{{ route('signup') }}" method="post">
<div class="form-group">
<label for="email">Your E-Mail</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="password" name="password" id="password">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<input type="hidden" name="_token" value = "{{ Session::token() }}">
</form>
</div>
答案 0 :(得分:2)
你错过了一个分号:
// ...
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]); // <<=== HERE
});