82 lines
2.5 KiB
PHP
82 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DashboardMobileController extends Controller
|
|
{
|
|
public function tampilMataPelajaran(Request $request)
|
|
{
|
|
$id_kelas = $request->input('id_kelas');
|
|
|
|
$mataPelajaran = DB::table('mata_pelajaran')
|
|
->select('mata_pelajaran.id_mapel', 'mata_pelajaran.nama_mapel', 'kelas.nama_kelas')
|
|
->join('mengajar as mengajar_mapel', 'mengajar_mapel.id_mapel', '=', 'mata_pelajaran.id_mapel')
|
|
->join('kelas', 'kelas.id_kelas', '=', 'mengajar_mapel.id_kelas')
|
|
->where('kelas.id_kelas', $id_kelas)
|
|
->get();
|
|
|
|
return response()->json($mataPelajaran);
|
|
}
|
|
|
|
public function tampilTugas(Request $request)
|
|
{
|
|
$id_kelas = $request->input('id_kelas');
|
|
|
|
$tugas = DB::table('tugas')
|
|
->select('tugas.id_tugas', 'materi.judul_materi', 'tugas.tenggat_waktu', 'tugas.keterangan')
|
|
->join('materi', 'materi.id_materi', '=', 'tugas.id_materi')
|
|
->join('mata_pelajaran', 'mata_pelajaran.id_mapel', '=', 'materi.id_mapel')
|
|
->join('mengajar', 'mengajar.id_mapel', '=', 'mata_pelajaran.id_mapel')
|
|
->join('kelas', 'kelas.id_kelas', '=', 'mengajar.id_kelas')
|
|
->where('kelas.id_kelas', $id_kelas)
|
|
->get();
|
|
|
|
return response()->json($tugas);
|
|
}
|
|
|
|
|
|
public function tampilMateri(Request $request)
|
|
{
|
|
$id_mapel = $request->input('id_mapel');
|
|
|
|
$materi = DB::table('materi')
|
|
->select('materi.id_materi', 'materi.judul_materi', 'materi.keterangan')
|
|
->join('mata_pelajaran', 'mata_pelajaran.id_mapel', '=', 'materi.id_mapel')
|
|
->where('mata_pelajaran.id_mapel', $id_mapel)
|
|
->get();
|
|
|
|
return response()->json($materi);
|
|
|
|
}
|
|
|
|
|
|
//tidak digunakan
|
|
public function downloadMateri(Request $request)
|
|
{
|
|
|
|
$id_materi = $request->input('id_materi');
|
|
|
|
|
|
$fileName = DB::table('materi')
|
|
->where('id_materi', $id_materi)
|
|
->value('lampiran_materi');
|
|
|
|
// Dapatkan path lengkap ke file
|
|
$filePath = public_path('assets/documents/materi/' . $fileName);
|
|
|
|
// Periksa apakah file ada
|
|
if (file_exists($filePath)) {
|
|
// Jika ada, kirimkan file sebagai respons
|
|
return response()
|
|
->download($filePath, $fileName);
|
|
} else {
|
|
// Jika tidak, kirimkan respons file tidak ditemukan
|
|
return response()->json();
|
|
}
|
|
|
|
}
|
|
} |