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