デフォルトのregister
ルートを使用してユーザーを作成すると、アプリ内にすべて入力できます。しかし、CRUDやMySQLコマンドを使用してユーザーを作成すると、ログインできません。 これらの資格情報は我々の記録と一致しません。 アンドレアとラファエロは、ログインすることができます(レジスタのデフォルトルートを作成します) マリノは(私のCRUD機能を生成する)ことはできませんが、Laravel 5.2ログインの問題
のroutes.php:
Route::group(['middleware' => ['web']], function() {
Route::resource('dash/reports', 'Dash\\ReportsController');
});
/* ruote for Admin */
Route::group(['middleware' => ['role:admin']], function() {
Route::resource('dash/categories', 'Dash\\CategoriesController');
});
Route::group(['middleware' => ['role:admin']], function() {
Route::resource('dash/roles', 'Dash\\RolesController');
});
Route::group(['middleware' => ['role:admin']], function() {
Route::resource('dash/permissions', 'Dash\\PermissionsController');
});
Route::group(['middleware' => ['role:admin']], function() {
Route::resource('dash/users', 'Dash\\UsersController');
});
/* another routes */
Route::auth();
Route::get('/home', '[email protected]');
Route::get('/', function() {return view('welcome');});
コントローラ(カスタムCRUD操作)
<?php
namespace App\Http\Controllers\Dash;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
use App\User;
use App\Report;
use App\Category;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Session;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class UsersController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Display a listing of the resource.
*
* @return void
*/
public function index()
{
$users = User::paginate(15);
return view('dash.users.index', compact('users'));
}
/**
* Show the form for creating a new resource.
*
* @return void
*/
public function create()
{
return view('dash.users.create');
}
/**
* Store a newly created resource in storage.
*
* @return void
*/
public function store(Request $request)
{
$this->validate($request, ['email' => 'required', 'name' => 'required', 'password' => 'required', 'surname' => 'required', ]);
$user = new User($request->all());
$user->password = bcrypt($request);
$user->save();
return redirect('dash/users');
}
/**
* Display the specified resource.
*
* @param int $id
*
* @return void
*/
public function show($id)
{
$user = User::findOrFail($id);
return view('dash.users.show', compact('user'));
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return void
*/
public function edit($id)
{
$user = User::findOrFail($id);
return view('dash.users.edit', compact('user'));
}
/**
* Update the specified resource in storage.
*
* @param int $id
*
* @return void
*/
public function update($id, Request $request)
{
$this->validate($request, ['email' => 'required', 'name' => 'required', 'password' => 'required', 'surname' => 'required', ]);
$user = User::findOrFail($id);
$user->update($request->all());
Session::flash('flash_message', 'User updated!');
return redirect('dash/users');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return void
*/
public function destroy($id)
{
User::destroy($id);
Session::flash('flash_message', 'User deleted!');
return redirect('dash/users');
}
}
ビュー:また
@extends('layouts.app')
@section('content')
<div class="container">
<h1>Create New User</h1>
<hr/>
{!! Form::open(['url' => '/dash/users', 'class' => 'form-horizontal']) !!}
<div class="form-group {{ $errors->has('email') ? 'has-error' : ''}}">
{!! Form::label('email', trans('users.email'), ['class' => 'col-sm-3 control-label']) !!}
<div class="col-sm-6">
{!! Form::text('email', null, ['class' => 'form-control', 'required' => 'required']) !!}
{!! $errors->first('email', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group {{ $errors->has('name') ? 'has-error' : ''}}">
{!! Form::label('name', trans('users.name'), ['class' => 'col-sm-3 control-label']) !!}
<div class="col-sm-6">
{!! Form::text('name', null, ['class' => 'form-control', 'required' => 'required']) !!}
{!! $errors->first('name', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group {{ $errors->has('password') ? 'has-error' : ''}}">
{!! Form::label('password', trans('users.password'), ['class' => 'col-sm-3 control-label']) !!}
<div class="col-sm-6">
{!! Form::text('password', null, ['class' => 'form-control', 'required' => 'required']) !!}
{!! $errors->first('password', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group {{ $errors->has('surname') ? 'has-error' : ''}}">
{!! Form::label('surname', trans('users.surname'), ['class' => 'col-sm-3 control-label']) !!}
<div class="col-sm-6">
{!! Form::text('surname', null, ['class' => 'form-control', 'required' => 'required']) !!}
{!! $errors->first('surname', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-3">
{!! Form::submit('Create', ['class' => 'btn btn-primary form-control']) !!}
</div>
</div>
{!! Form::close() !!}
@if ($errors->any())
<ul class="alert alert-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
</div>
@endsection
デフォルトpostLoginを()オーバーラップしてみてくださいためAuthControllerの私custon postLogin() - しかし、それはあなたがあなたから得るデータを指定する必要が あり
public function postLogin(LoginRequest $request)
{
if (Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')]))
{
return redirect('/dash-board');
}
return redirect('/login')->withErrors([
'email' => 'The credentials you entered did not match our records. Riprovare?',
]);
}
株式の全てをbcryptのことでしたコントローラとビュー&ルートコードpls –
あなたのCRを表示することはできますか? udコード? –
はい、私のポストを更新 – user0111001101