app/Http/Controllers/SparePartController.php
/**
     * Make surat for specified resource.
     *
     * @param  \App\Models\SparePart  $sparepart
     * @return \Illuminate\Http\Response
     */
Make surat for specified resource.
Make surat for specified resource .
public function perintah(SparePart $sparepart)
    {
        $surat_perintah = new \PhpOffice\PhpWord\TemplateProcessor(storage_path('app/public/surat/ccr.docx'));
        $date_received = Carbon::parse($sparepart->date_received)->isoFormat('dddd, Do MMMM YYYY');
        $date_request = Carbon::parse($sparepart->date_request)->isoFormat('dddd, Do MMMM YYYY');
        $surat_perintah->setValues([
            'ccr_id' => $sparepart->ccr,
            'tahun' => date('Y'),
            'customer_name' => $sparepart->customer->nama,
            'date_received' => $date_received,
            'date_request' => $date_request,
            'unit_model' => $sparepart->unit_code.'-'.$sparepart->part_name,
            'job_desc' => $sparepart->job_desc,
        ]);
        $name_surat = 'Surat Perintah Kerja CCR no.'.$sparepart->ccr.'.docx';
        $surat_perintah->saveAs($name_surat);
        return response()->download(public_path($name_surat))->deleteFileAfterSend(true);
    }
public function perintah ( SparePart $ sparepart ) { $ surat_perintah = new \ PhpOffice \ PhpWord \ TemplateProcessor ( storage_path ( 'app/public/surat/ccr.docx' ) ) ; $ date_received = Carbon :: parse ( $ sparepart -> date_received ) -> isoFormat ( 'dddd, Do MMMM YYYY' ) ; $ date_request = Carbon :: parse ( $ sparepart -> date_request ) -> isoFormat ( 'dddd, Do MMMM YYYY' ) ; $ surat_perintah -> setValues ( [ 'ccr_id' => $ sparepart -> ccr , 'tahun' => date ( 'Y' ) , 'customer_name' => $ sparepart -> customer -> nama , 'date_received' => $ date_received , 'date_request' => $ date_request , 'unit_model' => $ sparepart -> unit_code . '-' . $ sparepart -> part_name , 'job_desc' => $ sparepart -> job_desc , ] ) ; $ name_surat = 'Surat Perintah Kerja CCR no.' . $ sparepart -> ccr . '.docx' ; $ surat_perintah -> saveAs ( $ name_surat ) ; return response ( ) -> download ( public_path ( $ name_surat ) ) -> deleteFileAfterSend ( true ) ; }
Make surat for specified resource.
Make surat for specified resource .