app/Http/Controllers/SparePartController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $data = request()->validate([
            'selesai_id' => 'required|exists:pekerjaan_selesai,id',
        ]);
        $selesai = PekerjaanSelesai::find($data['selesai_id']);
        $sparepart_id = $selesai->ccr->rjo->id.'-'.$selesai->ccr->id;
        $spare = SparePart::create([
            'id' => $sparepart_id,
            'customer_id' => $selesai->ccr->rjo->customer_id,
            'marketing_id' => $selesai->ccr->rjo->marketing_id,
            'ppc_id' => $selesai->ppc->id,
            'unit_code' => $selesai->ccr->rjo->unit_code,
            'part_name' => $selesai->ccr->rjo->part_name,
            'problem' => $selesai->ccr->rjo->problem,
            'job_desc' => $selesai->ccr->rjo->job_desc,
            'ccr_file' => $selesai->ccr->file,
            'date_received' => $selesai->ccr->rjo->date_received,
            'date_request' => $selesai->ccr->rjo->date_request,
            'date_finish' => $selesai->date_finish,
        ]);
        $route_download = route('sparepart.surat', $spare->id);
        $rjo = Rjo::find($selesai->ccr->rjo->id);
        $rjo->delete();
        return redirect()->route('sparepart.index')->with([
            'success' => 'Data Sparepart berhasil di archive dan surat jalan berhasil dibuat',
            'download' => $route_download
        ]);
    }
public function store ( Request $ request ) { $ data = request ( ) -> validate ( [ 'selesai_id' => 'required|exists:pekerjaan_selesai,id' , ] ) ; $ selesai = PekerjaanSelesai :: find ( $ data [ 'selesai_id' ] ) ; $ sparepart_id = $ selesai -> ccr -> rjo -> id . '-' . $ selesai -> ccr -> id ; $ spare = SparePart :: create ( [ 'id' => $ sparepart_id , 'customer_id' => $ selesai -> ccr -> rjo -> customer_id , 'marketing_id' => $ selesai -> ccr -> rjo -> marketing_id , 'ppc_id' => $ selesai -> ppc -> id , 'unit_code' => $ selesai -> ccr -> rjo -> unit_code , 'part_name' => $ selesai -> ccr -> rjo -> part_name , 'problem' => $ selesai -> ccr -> rjo -> problem , 'job_desc' => $ selesai -> ccr -> rjo -> job_desc , 'ccr_file' => $ selesai -> ccr -> file , 'date_received' => $ selesai -> ccr -> rjo -> date_received , 'date_request' => $ selesai -> ccr -> rjo -> date_request , 'date_finish' => $ selesai -> date_finish , ] ) ; $ route_download = route ( 'sparepart.surat' , $ spare -> id ) ; $ rjo = Rjo :: find ( $ selesai -> ccr -> rjo -> id ) ; $ rjo -> delete ( ) ; return redirect ( ) -> route ( 'sparepart.index' ) -> with ( [ 'success' => 'Data Sparepart berhasil di archive dan surat jalan berhasil dibuat' , 'download' => $ route_download ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// dd($selesai);