예제 #1
0
 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 '';
     }
 }
예제 #2
0
파일: PostRepo.php 프로젝트: abada/xadmin
 public function addImage($postId, $fileMediaId)
 {
     $file = FileMedia::find($fileMediaId);
     $post = Post::find($postId);
     $post->feature_image = $file->filename;
     $post->save();
     return $post;
 }
예제 #3
0
 /**
  * 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'));
 }
예제 #4
0
 public function delete($id)
 {
     $fileMedia = FileMedia::findOrFail($id);
     $fileMedia->delete();
     return File::delete(config('admin.fileUploadDirectory') . $fileMedia->filename);
 }
예제 #5
0
 public function index()
 {
     $files = FileMedia::orderBy('created_at', 'DESC')->get();
     $selectType = 'multiple';
     return view('cms::file.files', compact('files', 'selectType'));
 }