だから私は(動作しませんどの)は、このコードを持っている:使用変数 - LARAVEL
明らか$accessuser = AccessUser::where('user_id', Auth::user()->id)
->with(['overtimes' => function ($qry) use ($accessuser) {
$qry->where('waiting_for', $accessuser->access_level)->get();
}])->get();
、私はちょうどaccess_level
列の値を取得し、それを比較したいです〜waiting_for
の列。
解決方法はありますか?
Schema::create('accesschart_user_maps', function (Blueprint $table) {
$table->increments('id');
$table->integer('accesschart_id')->unsigned();
$table->integer('user_id')->unsigned()->nullable();
$table->integer('access_level')->unsigned()->nullable();
$table->timestamps();
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('accesschart_id')
->references('id')->on('access_charts')
->onDelete('cascade');
});
マイOvertime
モデル::
Schema::create('overtimes', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('accesschart_id')->unsigned()->nullable();
$table->integer('remarks_by')->unsigned()->nullable();
$table->integer('waiting_for')->nullable();
$table->datetime('date_from');
$table->datetime('date_to');
$table->longtext('reason');
$table->longtext('remarks')->nullable();
$table->integer('status')->nullable();
$table->timestamps();
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('remarks_by')
->references('id')->on('users')
->onDelete('cascade');
});
ここに私のAccesschartUserMap
モデルだ
EDITED
など、あなたが私のテーブル構造に関する追加情報が必要な場合は、私に教えてください達成したいクエリは次のとおりです。
SELECT accessuser.user_id,accessuser.accesschart_id,accessuser.access_level,overtimes.waiting_for
FROM accesschart_user_maps as accessuser
INNER JOIN overtimes ON accessuser.accesschart_id = overtimes.id
WHERE accessuser.user_id = 7 and accessuser.access_level=overtimes.waiting_for
AccessUser、Overtimeおよび必要なものの例に関する5つの追加情報をお待ちください – yoeunes
こんにちは! @yoeunes、私は私の質問を更新しました。編集したものを参照してください。 –