insyaallah revisi done

This commit is contained in:
Jagad R R
2025-01-23 17:46:38 +07:00
parent 6034c331c5
commit 3a01df56e9
32 changed files with 825 additions and 360 deletions
@@ -22,36 +22,28 @@ class DashboardController extends Controller
public function index()
{
$role = auth()->user()->getRoleNames()[0];
$closing_date = env('CLOSING_DATE');
$startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
$forms = [
'vehicle' => FormVehicleRunningCost::whereMonth('tanggal', date('m'))
->whereYear('tanggal', date('Y'))
->where('tanggal', '<=', date('Y-m-'.$closing_date))
->whereRaw('DAY(CURDATE()) <= '.$closing_date)
->whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc')
->get(),
'upcountry' => FormUpCountry::whereMonth('tanggal', date('m'))
->whereYear('tanggal', date('Y'))
->where('tanggal', '<=', date('Y-m-'.$closing_date))
->whereRaw('DAY(CURDATE()) <= '.$closing_date)
->whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc')
->get(),
'entertainment' => FormEntertaimentPresentation::whereMonth('tanggal', date('m'))
->whereYear('tanggal', date('Y'))
->where('tanggal', '<=', date('Y-m-'.$closing_date))
->whereRaw('DAY(CURDATE()) <= '.$closing_date)
->whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc')
->get(),
'meeting' => FormMeetingSeminar::whereMonth('created_at', date('m'))
->whereYear('created_at', date('Y'))
->where('created_at', '<=', date('Y-m-'.$closing_date))
->whereRaw('DAY(CURDATE()) <= '.$closing_date)
->whereBetween('created_at', [$startDate, $closingDateNextMonth])
->orderBy('created_at', 'desc')
->get(),
'others' => FormOthers::whereMonth('tanggal', date('m'))
->whereYear('tanggal', date('Y'))
->where('tanggal', '<=', date('Y-m-'.$closing_date))
->whereRaw('DAY(CURDATE()) <= '.$closing_date)
->whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc')
->get(),
];
@@ -117,14 +109,24 @@ class DashboardController extends Controller
]);
}
public function mark_read()
public function mark_read($id)
{
$this->checkAuthorization(auth()->user(), ['notification.delete']);
$receiver_id = auth()->user()->id;
Notifications::where('receiver_id', $receiver_id)->where('id', $id)->update(['is_read' => 1]);
return response()->json(['message' => 'Notification marked as read.']);
}
public function mark_all_read()
{
$this->checkAuthorization(auth()->user(), ['notification.delete']);
$receiver_id = auth()->user()->id;
Notifications::where('receiver_id', $receiver_id)->update(['is_read' => 1]);
session()->flash('success', 'Notifications marked as read.');
session()->flash('success', 'All notifications marked as read.');
return redirect()->back();
}
}