Laravel 5 - request is not instantiable

0

Witam. Mam pewien problem, podczas wykonywania formularza rejestracji w laravelu 5, wyskakuje mi błąd
BindingResolutionException in Container.php line 744:
Target [App\Http\Requests\Request] is not instantiable.

Kody:
routers.php

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




	Route::get('users', 'DodajController@index');
	Route::post('rejestracja', 'DodajController@rejestracja');

	


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

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

 
<?php DodajController.php ```php namespace App\Http\Controllers; use Illuminate\Support\Facades\DB; use App\Http\Controllers\Controller; use App\Http\Requests\Request; class DodajController extends Controller { /** * Show a list of all of the application's users. * * @return Response */ public function rejestracja(Request $request) { $post = $request->all(); $v =\Validator::make($request->all(), [ 'nick' => 'required', 'haslo' => 'required', 'rehaslo' => 'required', 'email' => 'required', ] ); if($v->fails()) { return redirect()->back()->withErrors($v->errors()); } else{ $data = array( 'nick' => $post['nick'], 'haslo' => $post['haslo'], 'rehaslo' => $post['rehaslo'], 'email' => $post['email'] ); $ch = DB::table('uzytkownicy')->insert($data); if($ch > 0) { return 'users'; } } } } ``` rejestracja.blade.php ```php @extends('layout') @section('login')

{{$errors->first('nick')}}

{{$errors->first('haslo')}}

{{$errors->first('rehaslo')}}

{{$errors->first('email')}}

<form action="{{action('DodajController@rejestracja') }}" method="post">

Rejestracja


<input type="hidden" name="_token" value="&lt;?= csrf_token(); ?">" >
		<td><input for="nick" maxlength="18" onfocus="this.placeholder=''" onblur="this.placeholder='Nick'" placeholder="Nick" type="text" name="nick"></td></tr>
		<td><input for="password" maxlength="18" onfocus="this.placeholder=''" onblur="this.placeholder='Hasło'" placeholder="Hasło" type="password" name="haslo"></td></tr>
		<td><input for="rehaslo" maxlength="18" onfocus="this.placeholder=''" onblur="this.placeholder='Powtórz Hasło'" placeholder="Powtórz Hasło" type="password" name="rehaslo"></td></tr>
		<td><input for="email" maxlength="50" onfocus="this.placeholder=''" onblur="this.placeholder='Email'" placeholder="Email" type="text" name="email"></td></tr>
		<input type="submit" value="Załóż konto"/>
	</form>

@stop



```php
request.php

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

abstract class Request extends FormRequest
{
    //
}
0

Wszystko jasne, wystarczyło dodać zamiast
tego:

use App\Http\Requests\Request;

to:

use Illuminate\Http\Request;

gdyż klasa request jest abstract.

Teraz pojawia się błąd

QueryException in Connection.php line 636:
SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value (SQL: insert into uzytkownicy (nick, haslo, email) values (cos, cos, [email protected]))
Ktoś ma jakiś pomysł ?

0

Zrobione. Pola muszą być przesyłane w ten sam sposób, jak są ułożone w tabeli.

1 użytkowników online, w tym zalogowanych: 0, gości: 1