Commit ac2c602c authored by Reinol Simangunsong's avatar Reinol Simangunsong
Browse files

tes

No related merge requests found
Showing with 166 additions and 22 deletions
+166 -22
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Imports\UsulanDiklatImport;
use App\Models\ArsipBrosur;
use App\Models\Brosur;
use App\Models\UsulanBrosur;
use App\Models\UsulanDiklat;
use Illuminate\Support\Facades\Storage;
class BrosurUmumController extends Controller
{
public function create()
{
return view('umum.createusulan');
}
public function index(Request $request)
{
// Ambil input pencarian
$search = $request->input('search');
// Query data dengan pencarian dan paginasi
$usulan = ArsipBrosur::when($search, function ($query, $search) {
return $query->where('nama_penyelenggara', 'like', "%$search%");
})->paginate(10);
// Log hanya jika data ada
if ($usulan->isNotEmpty()) {
Log::info('Data retrieved for usulan', ['data' => $usulan->items()]);
} else {
Log::info('No data found for usulan', ['search' => $search]);
}
// Return view dengan data
return view('umum.usulan', compact('usulan', 'search'));
}
public function store(Request $request)
{
Log::info('Form submitted', $request->all());
// Validasi input dan file
$request->validate([
'nama_penyelenggara' => 'required',
'alamat' => 'required',
'no_telepon' => 'required',
'no_hp' => 'required',
'status_ajuan' => 'nullable',
'katalog_excel' => 'nullable|mimes:xlsx,xls|max:2048',
'katalog_pdf' => 'nullable|mimes:pdf|max:2048',
]);
$usulan_diklat = new ArsipBrosur();
$usulan_diklat->nama_penyelenggara = $request->nama_penyelenggara;
$usulan_diklat->alamat = $request->alamat;
$usulan_diklat->no_telepon = $request->no_telepon;
$usulan_diklat->no_hp = $request->no_hp;
$usulan_diklat->status_ajuan = $request->status_ajuan ?? 'Pending';
// Cek apakah file berhasil diupload
if ($request->hasFile('katalog_pdf')) {
Log::info('PDF file uploaded');
$pdf = $request->file('katalog_pdf');
$pdfName = time() . '_' . $pdf->getClientOriginalName();
$pdf->move(public_path('uploads/pdf'), $pdfName);
$usulan_diklat->katalog_pdf = 'uploads/pdf/' . $pdfName;
} else {
Log::info('No PDF file uploaded');
} if ($request->hasFile('katalog_excel')) {
Log::info('Excel file uploaded');
$excel = $request->file('katalog_excel');
$excelName = time() . '_' . $excel->getClientOriginalName();
$excel->move(public_path('uploads/excel'), $excelName);
$usulan_diklat->katalog_excel = 'uploads/excel/' . $excelName;
} else {
Log::info('No Excel file uploaded');
}
// Simpan data ke database
$usulan_diklat->save();
Log::info('Data saved to database');
return redirect()->route('umum.usulan')->with('success', 'Usulan diklat berhasil ditambahkan.');
}
}
......@@ -38,15 +38,15 @@ public function store(Request $request)
'unit_kerja' => 'required',
'jenis_pelatihan' => 'required',
'nama_pelatihan' => 'required',
'tempat_pelaksanaan' => 'nullable|date',
'tahun_pelatihan' => 'required|numeric',
'pelaksanaan' => 'required',
'mode_pelatihan' => 'required',
'waktu_pelaksanaan' => 'required',
'biaya_per_orang' => 'nullable|numeric',
'tempat_pelaksanaan'=> 'required',
//'biaya_per_orang' => 'nullable|numeric',
'judul_laporan' => 'required',
'latar_belakang' => 'required',
'link_katalog' => 'nullable|url',
//'link_katalog' => 'nullable|url',
'unggah_laporan' => 'nullable|mimes:pdf,doc,docx|max:2048',
]);
......@@ -60,14 +60,14 @@ public function store(Request $request)
$usulan_laporan_diklat->jenis_pelatihan = $request->jenis_pelatihan;
$usulan_laporan_diklat->nama_pelatihan = $request->nama_pelatihan;
$usulan_laporan_diklat->tahun_pelatihan = $request->tahun_pelatihan;
$usulan_laporan_diklat->tempat_pelaksanaan = $request->tempat_pelaksanaan;
$usulan_laporan_diklat->pelaksanaan = $request->pelaksanaan;
$usulan_laporan_diklat->mode_pelatihan = $request->mode_pelatihan;
$usulan_laporan_diklat->waktu_pelaksanaan = $request->waktu_pelaksanaan;
$usulan_laporan_diklat->biaya_per_orang = $request->biaya_per_orang;
$usulan_laporan_diklat->tempat_pelaksanaan = $request->tempat_pelaksanaan;
//$usulan_laporan_diklat->biaya_per_orang = $request->biaya_per_orang;
$usulan_laporan_diklat->judul_laporan = $request->judul_laporan;
$usulan_laporan_diklat->latar_belakang = $request->latar_belakang;
$usulan_laporan_diklat->link_katalog = $request->link_katalog;
//$usulan_laporan_diklat->link_katalog = $request->link_katalog;
......
......@@ -3,19 +3,29 @@
namespace App\Http\Controllers;
use App\Models\Pelatihan;
use App\Models\PelaksanaanPelatihan;
use App\Models\JenisPelatihan;
use App\Models\MetodePelatihan;
use App\Models\Golongan;
use App\Models\UnitKerja;
use Illuminate\Http\Request;
class PelatihanController extends Controller
{
// In your Controller
// In your PelatihanController (or equivalent controller)
public function index()
{
// Assuming you have a Pelatihan model that points to 'nama_pelatihan' table
$nama_pelatihan = Pelatihan::paginate(10); // Adjust '10' for the records per page
return view('ekatalog.pelatihan', compact('nama_pelatihan'));
}
public function index()
{
// Mengambil data dari masing-masing model
$pelaksanaan_pelatihan = PelaksanaanPelatihan::all();
$jenisPelatihan = JenisPelatihan::all();
$metodePelatihan = MetodePelatihan::all();
$golongan = Golongan::all();
$unitKerja = UnitKerja::all();
// Menampilkan view dengan data
return view('pelatihan.index', compact('pelatihan', 'jenisPelatihan', 'metodePelatihan', 'golongan', 'unitKerja'));
}
public function create()
{
......
......@@ -26,7 +26,8 @@ class ArsipLaporan extends Model
'latar_belakang',
'unggah_laporan', // Add this if it's part of your fillable fields (file uploads)
'status_ajuan',
'tanggal_ajuan'
'tanggal_ajuan',
'no_hp'
];
// If you don't have 'created_at' and 'updated_at' in the table,
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UnitKerja extends Model
{
use HasFactory;
protected $table = 'unit_kerja';
protected $fillable = [
'kode_unitkerja',
'sub_unitkerja',
'unitkerja',
'singkatan',
];
}
......@@ -19,13 +19,15 @@ class UsulanLaporan extends Model
'jenis_pelatihan',
'nama_pelatihan',
'tahun_pelatihan',
'tempat_pelaksanan',
'pelaksanaan',
'mode_pelatihan',
'waktu_pelaksanaan',
'judul_laporan',
'latar_belakang',
'unggah_laporan',
'status_ajuan'
'status_ajuan',
'no_hp'
];
// Enable timestamps (created_at, updated_at)
......
......@@ -11,16 +11,21 @@
*/
public function up()
{
Schema::table('admin', function (Blueprint $table) {
$table->boolean('is_admin')->default(0); // 0 untuk bukan admin, 1 untuk admin
Schema::create('unit_kerja', function (Blueprint $table) {
$table->id('id');
$table->integer('kode_unitkerja')->length(6);
$table->string('sub_unitkerja', 200);
$table->string('unitkerja', 200);
$table->string('singkatan', 100);
$table->timestamps();
});
}
public function down()
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('admin', function (Blueprint $table) {
$table->dropColumn('is_admin');
});
Schema::dropIfExists('unit_kerja');
}
};
......@@ -9,23 +9,19 @@
/**
* Run the migrations.
*/
public function up()
public function up(): void
{
Schema::create('admin', function (Blueprint $table) {
Schema::create('pelatihan', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('admin');
Schema::dropIfExists('pelatihan');
}
};
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment