As in subject, today i'm creating a Login panel with new Laravel 5.6. Simply i used an included Laravel's Panel with User Model and i created UserController :
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
class UserController extends Controller
{
// Auto loading middleware
public function __construct()
{
$this->middleware('auth');
}
public function add()
{
return view('User.add');
}
public function save(Request $request)
{
// Metoda 1
User::create($request->all());
}
public function login()
{
return view('welcome');
}
public function register()
{
return view('auth.register');
}
}
That's Laravel view "login" refactored by me :
<main>
<section class="well-md well-md--inset-3 marker relative">
<div class="container-fluid container-inset">
@if(!empty($msg))
@endif
<h2 class="text-center text-md-left">Logowanie</h2>
<form class='rd-mailform' method="post" action="">
@csrf
<fieldset>
<div class="row flow-offset">
<div class="col-sm-12">
<label data-add-placeholder="">
<input type="text"
name="email"
class="" value=""
required autofocus
placeholder="Twój email"
data-constraints="@NotEmpty @Email"/>
</label>
<label data-add-placeholder="">
<input type="password"
name="haslo"
class="" value=""
required autofocus
placeholder="Hasło"
data-constraints="@NotEmpty @Password"/>
</label>
<label>
<div class="remember">Zapamiętaj</div>
<div class="justify-checkbox">
<input type="checkbox" name="remember" />
</div>
</label>
</div>
<div class="mfControls text-center text-lg-right">
<button class="btn btn-default btn-md uppercase " type="submit">Wyślij</button>
</div>
<div class="mfInfo"></div>
</div>
</fieldset>
</form>
</div>
</section>
</main>
And here are my routes :
// Not protected sites
/////////////////////////////////////////////////////////////////////////
Route::get('/' , 'HomeController@welcome');
Route::get('/onas' , [
'uses' => 'HomeController@onas',
'as' => 'Home@onas'
]);
Route::get('/cennik' , [
'uses' => 'HomeController@cennik',
'as' => 'Home@cennik'
]);
Route::get('/samochody' , [
'uses' => 'HomeController@samochody',
'as' => 'Home@samochody'
]);
Route::get('/uslugi' , [
'uses' => 'HomeController@uslugi',
'as' => 'Home@uslugi'
]);
Route::get('/konto' , [
'uses' => 'HomeController@konto',
'as' => 'Home@konto'
]);
Route::get('/kontakt' , [
'uses' => 'MailController@kontakt',
'as' => 'Mail@kontakt'
]);
Route::post('/kontakt' , 'MailController@wyslij');
// Protected routes
////////////////////////////////////////////////////////////////////////////
Route::group(['middleware' => 'auth'], function()
{
Route::get('/add' , 'UserController@add');
Route::post('/save' , [ // Tablica taka posiada wiele różnych kluczy
'uses' => 'UserController@save' ,
'as' => 'User.Save'
]);
Route::get('/show/{user}' , [
'uses' => 'UserController@show' ,
'as' => 'User.Show'
]);
Route::get('/login' , 'UserController@login');
Route::get('/register' , 'UserController@register');
Database migration :
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('imie');
$table->string('nazwisko');
$table->string('ulica');
$table->string('numer');
$table->string('kod-pocztowy');
$table->string('miasto');
$table->string('telefon');
$table->string('nip');
$table->string('email')->unique();
$table->string('haslo');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
My question is, why i can not login the user ? Database columns are matched. Please help me guys !
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2osGEFU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire