我正在使用Laravel 5.3.我有4张桌子.默认Users
表.Departments
,Position
,Employees
表.
Users
表有 ID | Email | Password
Departments
table has ID | Department | User_Id
- 这User_Id
是外键来自Users
table'sID
Positions
table has ID | Position | Department_Id
- 这Department_Id
是外键来自Departments
table'sID
Employees
table has ID | Employee | Position_Id
- 这Position_Id
是外键来自Positions
table'sID
用户可以拥有多个Departments
.Departments
可以有多个Positions
,Positions
可以有多个Employees
.因此,如果用户不同,我如何从该用户创建的所有4个表中检索所有数据?
我正在使用Laravel 5.3
. 我已经在 Laravel 的默认Auth
. 但是,如果帐户/用户未通过验证电子邮件地址激活,我找不到停止发送密码重置链接的方法。目前,如果用户创建一个帐户并且不验证他/她可以使用密码重置链接登录的电子邮件地址。
这是我在用户表中的内容
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable();;
$table->string('username')->unique();
$table->string('email')->unique();
$table->string('company')->nullable();;
$table->string('password');
$table->boolean('activated')->default(false);
$table->rememberToken();
$table->timestamps();
});
Schema::create('user_activations', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->string('token')->index();
$table->timestamp('created_at');
});
}
Run Code Online (Sandbox Code Playgroud)
更新 我试图通过更新以下功能来做到这一点。但它不起作用
public function reset(Request $request)
{
if (!$request->activated) {
return redirect('/');
} else {
$this->validate($request, $this->rules(), $this->validationErrorMessages());
$response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) {
$this->resetPassword($user, $password);
}
);
return $response == Password::PASSWORD_RESET
? $this->sendResetResponse($response)
: $this->sendResetFailedResponse($request, $response);
} …
Run Code Online (Sandbox Code Playgroud) 我有以下功能 -
public function search_profile(Request $request)
{
$search_keyword = $request->search;
$search_user = $request->user;
$user_public = User::where('username', $request->user)->first();
$tags_list = Tag::orderBy('tag', 'asc')->get();
$bookmarks = Bookmark::orderBy('created_at','desc')->where('bookmarker', $search_user)->where('public', '1')->where('tags', 'rlike', $search_keyword)->orwhere('title', 'rlike', $search_keyword)->orwhere('description', 'rlike', $search_keyword)->orwhere('contents', 'rlike', $search_keyword)->paginate(15);
$bookmarks_all = Bookmark::orderBy('created_at','desc')->where('bookmarker', $search_user)->where('public', '1')->where('tags', 'rlike', $search_keyword)->orwhere('title', 'rlike', $search_keyword)->orwhere('description', 'rlike', $search_keyword)->orwhere('contents', 'rlike', $search_keyword)->get();
return view('profile_search')->with('bookmark', $bookmarks)->with('tags_list', $tags_list)->with('bookmarks_all', $bookmarks_all)->with('username', $user_public)->with('search_keyword', $search_keyword);
}
Run Code Online (Sandbox Code Playgroud)
但我什至从其他人那里得到了结果bookmarker
。例如 - 如果$search_keyword = 'laravel'
和$serach_user = 'zack'
。我也从其他用户那里得到结果。
我是 Laravel 的新手。那么我在查询中做错了什么?
在尝试使用Google Material Design Lite的响应功能时,此代码会在调整浏览器窗口大小时按预期隐藏消息,但当我在Chrome DevTools设备模拟器或实际设备上查看我的页面时,它只会显示"桌面"版本.如何修复HTML?
<html>
<head>
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.1/material.indigo-pink.min.css">
</head>
<body>
<div class="mdl-cell--hide-phone mdl-cell--hide-tablet">
You are on a desktop
</div>
<div class="mdl-cell--hide-desktop mdl-cell--hide-tablet">
You are on a phone
</div>
<div class="mdl-cell--hide-desktop mdl-cell--hide-phone">
You are on a tablet
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我在这里有一段代码:
if (Math.random() < 0.80) {
var img = $('#img');
}
$(document).mousemove(function(event) {
var mouse_x = event.pageX;
var mouse_y = event.pageY;
$(img).css({
'top': mouse_y+'px',
'left': mouse_x+'px',
'display' : 'block',
'position' : 'absolute'
});
});
Run Code Online (Sandbox Code Playgroud)
在这个脚本中,我不明白该if (Math.random() < 0.80)
行在做什么.又是如何Math.random()
得到它的价值,来自哪里?