【发布时间】:2018-05-24 00:39:36
【问题描述】:
我有用户和员工表。我想在登录后显示员工详细信息。人员显示将列出与登录用户相同部分的人员。例如,如果 Adam (section/seksyen=A) 登录,则显示的人员列表是 A 部门的人员。
如何在 laravel 中查询?
表用户:
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
$table->string('section');
$table->string('type');
});
}
桌员:
public function up()
{
Schema::create('staffs', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->string('nama');
$table->string('emel')->unique();
$table->string('seksyen');
$table->string('jawatan');
$table->string('alamat');
$table->string('no kakitangan');
});
我试过这个查询,但没有用。
$data['data'] = DB::table('staffs')
->join('users', 'users.section', '=', 'staffs.seksyen')
->where('seksyen','=','Auth(section)')->get();
【问题讨论】:
-
究竟是什么不起作用?你真的在使用
'Auth(section)'吗?