[英]How can i put counter of leave in laravel?
在用戶名中,它將從mongodb的集合中獲取數據,但是在本月的總休假中,我想在本月進行清算,員工休了多少假 ?
<form id="myform" class="form-horizontal" method="POST" action="{{ url('approve-leave', $leaves->id) }}">
@csrf
<div class="row">
<label class="col-md-6"><strong> Employee Name</strong></label>
<div class="col-md-6">
{{$leaves->username}}
</div>
</div>
<hr>
<div class="row">
<label class="col-md-6"><strong> Total Leave in this month </strong></label>
<div class="col-md-6">
1
</div>
</div>
</form>
所以,請任何人幫助我該怎么做?
你和我有同樣的問題。 我使用以下方法解決了這個問題。 首先,我為year_wise_use_leave創建了單獨的表。 在該表中,我使用crone作業每月增加一次計數。 並直接顯示該表中的每月可休假。
對於批准/拒絕操作,將直接反映在該表中。 因此,如果您想獲取年假,那將很容易。
輸入用戶的年假后,您必須將其除以12並將其存儲在year_wise_use_leave表中。
這是我的老太太工作代碼
$userLeaves = UserAdditionalDetail::select('id', 'user_id', 'total_leaves')->whereHas('user', function ($query) {
$query->where('deleted_at', null);
})->get();
foreach ($userLeaves as $userLeave) {
$yearlyLeave = YearWiseUserLeave::where('user_id', $userLeave->user->id)->where('is_expired', 0)->first();
$yearlyLeave->total_leave += $userLeave->total_leaves / 12;
$yearlyLeave->save();
}
這里的UserAdditionalDetail是我的表,用於存儲用戶的年假。每月都會調用此crone作業。
希望這可以幫助 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.