Skip to content

Commit

Permalink
stored file src helper
Browse files Browse the repository at this point in the history
  • Loading branch information
boxfrommars committed Nov 24, 2015
1 parent 495204d commit 9c4bb72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,6 @@ protected function addHtmlOption($optionName, $optionValue, $options){

protected function fileSrc($filename)
{
return !empty($filename) ? implode('/', ['', config('rutorika-form.public_storage_path'), $filename]) : '';
return stored_file_src($filename);
}
}
12 changes: 12 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@ function delete_form($url, $label = '<i class="fa fa-close"></i>')
$form .= Form::close();

return $form;
}

function stored_file_src($filename)
{
if (empty($filename)) {
return '';
} elseif (preg_match('/^https?:\/\//', $filename)) {
return $filename;
} else {
$pathToStorage = config('rutorika-form.public_storage_path');
return "/{$pathToStorage}/{$filename}";
}
}

0 comments on commit 9c4bb72

Please sign in to comment.