function _fileMediaPreview(FileMedia $file) { if (in_array($file->mime_type, ['image/jpeg', 'image/png', 'image/gif', 'image/jpg'])) { return '<img class="filemedia-preview" width="60" alt="' . $file->name() . '" src="' . $file->path() . '" />'; } else { return ''; } }
public function addImage($postId, $fileMediaId) { $file = FileMedia::find($fileMediaId); $post = Post::find($postId); $post->feature_image = $file->filename; $post->save(); return $post; }
/** * Select files for a single post. * * @param Request $request * @return Response */ public function postMedia(Request $request) { $postId = $request->get('post'); if (!$postId) { return redirect()->route('admin.root')->with('message', 'Seems like you have not selected a post.'); } $files = FileMedia::orderBy('created_at', 'DESC')->get(); $selectType = 'single'; return view('cms::post.post-files', compact('files', 'postId', 'selectType')); }
public function delete($id) { $fileMedia = FileMedia::findOrFail($id); $fileMedia->delete(); return File::delete(config('admin.fileUploadDirectory') . $fileMedia->filename); }
public function index() { $files = FileMedia::orderBy('created_at', 'DESC')->get(); $selectType = 'multiple'; return view('cms::file.files', compact('files', 'selectType')); }