feat: add dashboard transfer and assistance summaries
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use App\Models\RiwayatBantuan;
|
||||
use App\Models\RumahIbadah;
|
||||
use App\Models\RumahMiskin;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -36,6 +37,18 @@ class BantuanController extends Controller
|
||||
'tanggal_bantuan' => 'required|date',
|
||||
'ibadah_id' => 'nullable|integer|exists:rumah_ibadah,id',
|
||||
]);
|
||||
|
||||
$user = auth()->user();
|
||||
if ($user->hasRole('pengurus_ibadah') && !empty($validated['ibadah_id'])) {
|
||||
$ownsIbadah = RumahIbadah::where('id', $validated['ibadah_id'])
|
||||
->where('user_id', $user->id)
|
||||
->exists();
|
||||
|
||||
if (!$ownsIbadah) {
|
||||
return response()->json(['message' => 'Tidak berhak mencatat bantuan dari rumah ibadah ini'], 403);
|
||||
}
|
||||
}
|
||||
|
||||
$bantuan = RiwayatBantuan::create([
|
||||
'id_rumah' => $idRumah,
|
||||
'dicatat_oleh' => auth()->id(),
|
||||
|
||||
Reference in New Issue
Block a user