Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File/avatar uploads #226

Closed
3 of 4 tasks
nabeelio opened this issue Apr 1, 2018 · 7 comments
Closed
3 of 4 tasks

File/avatar uploads #226

nabeelio opened this issue Apr 1, 2018 · 7 comments

Comments

@nabeelio
Copy link
Owner

nabeelio commented Apr 1, 2018

file uploads

  • files table that looks like expenses - with a ref_class and ref_class_id to allow attaching files to different assets - aircraft, airports initially
  • generic file uploader component and service class

avatar

  • avatar column in user table
  • avatar upload and change
@joooseb
Copy link
Contributor

joooseb commented Apr 25, 2018

I'll take this Issue, we'll use the simple upload file method of Laravel?, phpvms have a external package to manage images?

@nabeelio
Copy link
Owner Author

@joooseb yes, let's use the simple upload... it should upload to public/uploads/avatars, and then it should store the path (from the public/ folder) in the avatar column... so just uploads/avatar/avatar.png. And then, it'll look like, in a template, {{ $user->avatar }}, and that should have the correct link. The getAvatarAttribute() on the user model should "just" work.

There should also be a clear avatar button. And then we can do the same thing for the rank table. I was thinking we can use Intervention/image to resize the images. I think we should create a config section in config/phpvms.php, for it:

'avatar' => [
  'width': '200px',
  'height': '200px',
],

And that can be used to dictate the resizing.

@nabeelio
Copy link
Owner Author

And once that's working, it should work about the same for ranks, except into public/uploads/ranks. Then on the profile page, if there's a rank image, it can be shown there

@joooseb
Copy link
Contributor

joooseb commented Apr 29, 2018

Ok, thanks you for the information. I worked with intervention package in other Laravel project, I'll install the package into phpvms (so the PR will contain a modification into composer.json) and I'm going to start to work, I will back soon :)!

@nabeelio
Copy link
Owner Author

Thanks, take your time!

@joooseb
Copy link
Contributor

joooseb commented May 1, 2018

Nabeel, getAvatarAttribute() is conflicting the final avatar route
http://phpvms.test/{"path":"public\/uploads\/avatars\/PSD0001.png"}
I don't know why this attribute is necesary, I have a conventional method to upload files and call it with {{ url($user->avatar) }} and it works fine, but with attribute no

@nabeelio
Copy link
Owner Author

nabeelio commented May 1, 2018

Hmm, I'm not exactly sure what you mean. Do you mean the link above it what it's creating? The getAvatarAttribute is needed because it returns a File object, which I use to build the URL - it's needed because some people might be on shared hosting, where the URL root is / instead of /public. I modified the Laravel bootloader to detect which index.php is being called and then re-setting the root public (which is how the helper public_asset() that I added works).

@nabeelio nabeelio closed this as completed May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants