File upload & model path in one line #36825
-
Here is a trait Im using to create a file name and append it to the Makes adding public file uploads that are only attached to a model very clean: public function store(CreateProfileRequest $request)
{
$request->upload('banner');
$profile = Profile::create($request->validated());
return redirect()->route('profiles.show', $profile);
} The image path is saved on the model: <img src="{{ $profile->banner }}" /> |
Beta Was this translation helpful? Give feedback.
Answered by
dillingham
Mar 31, 2021
Replies: 1 comment 3 replies
-
What do you think about using a trait for this? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/dillingham/interacts-with-uploads
Initial attempt works. Will add tests later