【发布时间】:2018-09-21 18:38:24
【问题描述】:
我是 Laravel 5 和学习的新手。现在我已经创建了登录表单,我想检查用户是否有效(匹配表中的用户)并采取一些措施。
现在我正在从controller (AdminLoginController.php) 获取所有表单数据。现在我不知道如何传递给模型以检查用户是否存在。
查看(login.blade.php)
//I have used this form action {{ URL::to('administrator/userAuthentication') }}
<form name="frmLogin" action="{{ URL::to('administrator/userAuthentication') }}" method="post">
<input name="_token" type="hidden" value="{{ csrf_token() }}"/>
<div class="form-group has-feedback">
<input type="text" name="username" id="username"class="form-control" placeholder="Username">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" name="password" id="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<?php /*<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox"> Remember Me
</label>
</div>
</div><!-- /.col -->*/ ?>
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Login</button>
</div><!-- /.col -->
</div>
</form>
控制器(AdminLoginController.php)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class AdminLoginController extends Controller
{
/**
* Handle an authentication attempt for admin user.
*
* @return Response
*/
public function userAuthentication(Request $request)
{
echo "<pre>";
return $request;
echo "</pre>";
}
}
模型(AdminLoginModel.php)
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class AdminLoginModel extends Model
{
public function checkAuthentication()
{
// code
}
}
我不知道我做得对还是不需要你的建议。
谢谢。
【问题讨论】:
标签: php laravel laravel-5 eloquent