MIF_E31211891/app/Http/Controllers/PesertaSemproController.php

66 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use App\Models\SeminarProposal;
class PesertaSemproController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$no = 1;
// Filter Tahun
$tahuns = SeminarProposal::selectRaw('YEAR(created_at) as year')->groupBy('year')->pluck('year');
$tahun = $request->tahun;
// Tangani filter tahun
$seminarProposals = SeminarProposal::whereIn(SeminarProposal::raw('YEAR(created_at)'), $tahuns)
->when($tahun, function ($query, $tahun) {
return $query->whereYear('created_at', $tahun);
})
->with(['mahasiswa', 'pengajuan.dosenPembimbing']);
$seminarProposals = $seminarProposals->get();
// Mengembalikan view dengan data seminar proposal
return view('peserta-sempro', compact('no', 'tahun', 'tahuns', 'seminarProposals'));
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}