public function postUpload(Request $request) { $validator = Validator::make($request->all(), ['file_pdf' => 'required|mimes:pdf', 'jenis_dokumen' => 'required', 'kode_jra' => 'required']); if ($validator->fails()) { \Session::flash('alert-warning', 'Lengkapi Kembali Input Sebelum Upload'); return redirect()->back(); } $data['pr'] = ''; $data['po'] = ''; $data['gr'] = ''; $data['cd'] = ''; $data['checklist_id'] = ''; $file = $request->file('file_pdf'); $data = array_merge($data, $request->all()); $jra_dokumen_id = Jra_dokumen::select('id')->where('kode', $data['kode_jra'])->firstOrFail(); //id untuk jra_dokumen $data['jra_dokumen_id'] = $jra_dokumen_id->id; //id jra $data['created_by'] = Auth::user()->id; //created_by $data['file_name_pdf'] = $file->getClientOriginalName(); $filename = $this->fileRename($data['file_name_pdf']); $data['no_dokumen'] = $filename['no_file']; $validator = Validator::make($data, ['no_dokumen' => 'unique:dokumen|max:255', 'jra_dokumen_id' => 'required']); if ($validator->fails()) { $url = url("dokumen/detail/{$data['no_dokumen']}"); \Session::flash('alert-info', "No Dokumen <a href='{$url}'>{$data['no_dokumen']}</a> Sudah ada"); return redirect()->back(); } $data['nama_dokumen'] = $filename['nama_file']; $data['status_id'] = $this->status_id; $data['sub_jenis_id'] = $data['jenis_dokumen']; $data['visibility_id'] = $data['visibility']; $data['lokasi_file_pdf'] = $this->lokasi_file($data); $data['status_dokumen_id'] = '2'; $data['unit_tujuan'] = isset($data['tembusan']) && $data['unit_tujuan'] != '' ? $data['unit_tujuan'] : null; $data['tembusan'] = isset($data['tembusan']) ? $data['tembusan'] : null; // dd($data); // if($data['pr']!=''){ // $this->cekWBS($data['pr']); // } $dokumen = Dokumen::create($data); if ($data['checklist_id'] != '') { $dokumen->has_checklist()->attach($data['checklist_id']); } //dokumen pengadaan $this->insertDokumenPRPO($dokumen, $data['pr'], $data['po'], $data['gr'], $data['cd']); $this->insertFolder($data, $dokumen); if ($data['tembusan'] != null) { $dokumen->dokumen_tembusan()->attach($data['tembusan']); } if ($dokumen) { $dataupload = $this->uploadfile($data, $file); return redirect("dokumen/detail/{$dokumen->id}"); } \Session::flash('alert-error', 'Maaf, hanya akun Administrator yang berhak mengkases module tersebut.'); return redirect()->back(); }
public function getAjaxJraCekKode(Request $request) { $kode = $request->get('kode'); $jra = Jra_dokumen::where('kode', 'like', $kode)->get(); return $jra; }