Skip to content

Commit 8823b07

Browse files
committed
Fixes #71
1 parent ab8dd2e commit 8823b07

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "crestapps/laravel-code-generator",
33
"license": "MIT",
44
"description": "An intelligent code generator for Laravel framework that will save you time! This awesome tool will help you generate resources like views, controllers, routes, migrations, languages and/or form-requests! It is extremely flexible and customizable to cover many on the use cases. It is shipped with cross-browsers compatible template, along with a client-side validation to modernize your application.",
5-
"version": "v2.2.11",
5+
"version": "v2.2.12",
66
"keywords": [
77
"laravel","crud","crud generator",
88
"laravel crud generator","laravel crud builder",

src/HtmlGenerators/HtmlGeneratorBase.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,26 @@ protected function getShowRowHtmlField($stub, Field $field)
129129
{
130130
$this->replaceFieldName($stub, $field->name)
131131
->replaceModelName($stub, $this->modelName)
132-
->replaceRowFieldValue($stub, $this->getFieldAccessorValue($field, 'show'))
132+
->replaceRowFieldValue($stub, $this->getFieldValueForShow($field))
133133
->replaceFieldTitle($stub, $this->getTitle($field->getLabel(), true));
134134

135135
return $stub;
136136
}
137+
/**
138+
* Gets the value to use in the show view
139+
*
140+
* @param Field $field
141+
*
142+
* @return string
143+
*/
144+
protected function getFieldValueForShow(Field $field)
145+
{
146+
if ($field->isFile()) {
147+
return sprintf("asset('storage/' . %s)", $this->getFieldAccessorValue($field, 'show'));
148+
}
149+
150+
return $this->getFieldAccessorValue($field, 'show');
151+
}
137152

138153
/**
139154
* Gets header cells' html code for the index view using the current fields colelction.
@@ -292,10 +307,6 @@ protected function getFieldAccessorValue(Field $field, $view)
292307
return sprintf("implode('%s', %s)", $field->optionsDelimiter, $fieldAccessor);
293308
}
294309

295-
if ($field->isFile()) {
296-
return sprintf("basename(%s)", $fieldAccessor);
297-
}
298-
299310
return $fieldAccessor;
300311
}
301312

templates/default-collective/controller-upload-method-5.3.stub

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
return '';
1313
}
1414

15-
return $file->store(config('codegenerator.files_upload_path'), config('filesystems.default'));
15+
$path = config('codegenerator.files_upload_path', 'uploads');
16+
$saved = $file->store('public/' . $path, config('filesystems.default'));
17+
18+
return substr($saved, 7);
1619
}

templates/default/controller-upload-method-5.3.stub

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
return '';
1313
}
1414

15-
return $file->store(config('codegenerator.files_upload_path'), config('filesystems.default'));
15+
$path = config('codegenerator.files_upload_path', 'uploads');
16+
$saved = $file->store('public/' . $path, config('filesystems.default'));
17+
18+
return substr($saved, 7);
1619
}

0 commit comments

Comments
 (0)