App\Http\Controllers\Laralum\Laralum::addDownload PHP Method

addDownload() public static method

public static addDownload ( $file_name )
    public static function addDownload($file_name)
    {
        if (Laralum::isDocument($file_name)) {
            $file = Document::where('name', $file_name)->first();
            $file->downloads = $file->downloads + 1;
            $file->save();
        }
    }

Usage Example

Example #1
0
 public static function downloadFile($file_name)
 {
     # Add a new download to the file if it's a document
     if (Laralum::isDocument($file_name)) {
         Laralum::addDownload($file_name);
     }
     return response()->download(storage_path('app/' . $file_name));
 }