cyberfly
12/7/2018 - 3:32 AM

Laravel DomPDF show image in PDF

<img class="image-uploaded center img-responsive" src="{{ public_path($office_photo['storage_path']) }}">

<img src="{{ public_path("storage/images/".$user->profile_pic) }}" alt="" style="width: 150px; height: 150px;">
    private function getAttachedMedia($model, $collection_name='')
    {
        $uploaded_media = [];

        if (empty($collection_name)) {
            $uploaded_files = $model->getMedia();
        }
        else {
            $uploaded_files = $model->getMedia($collection_name);
        }

        if ($uploaded_files->count()) {

            foreach ($uploaded_files as $file) {

                $uploaded_media[] = [
                    'id' => $file->id,
                    'name' => $file->name,
                    'mime_type' => $file->mime_type,
                    'url' => $file->getFullUrl(),
                    'storage_path' => $file->getUrl(),
                    'full_path' => $file->getPath(),
                ];
            }
        }

        return $uploaded_media;
    }