Beispiel #1
0
 public static function downloadUpdateNearlyOneFile($file_cd, $resource_id)
 {
     $files = DownloadFile::where('file_cd', '=', $file_cd)->where('resource_id', '=', $resource_id)->orderBy('updated_at', 'desc')->get();
     if (isset($files)) {
         return $files[0];
     } else {
         return false;
     }
 }
Beispiel #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     // return $id;
     // $cat = Cat::find($id);
     $cat = $id;
     if ($cat->created_user_id !== Auth::id() && Auth::user()->user_type === Config::get('db_const.DB_USERS_USER_TYPE_COMMON')) {
         abort(403);
     }
     $icons = DownloadFile::downloadFiles(Config::get('db_const.DB_FILE_FILE_CD_CAT_ICON_CODE'), $cat->id);
     if ($icons) {
         $cat->icons = $icons;
     }
     return view('cats.edit')->with('cat', $cat);
 }
Beispiel #3
0
 /**
  * Download the file in storage.
  *
  * @param  int  $file_cd
  * @param  int  $resource_id
  * @return Response
  */
 public function downloadOne($file_cd, $resource_id)
 {
     //
     // echo $file_cd . '/' . $resource_id;
     $file = DownloadFile::downloadUpdateNearlyOneFile($file_cd, $resource_id);
     $real_path = storage_path() . $file->save_path;
     $headers = array('Content-Type:' . $file->type);
     // return $file->save_path;
     $realFile = $real_path . DIRECTORY_SEPARATOR . $file->save_name;
     return Response::download($realFile, $file->real_name, $headers);
 }