diff --git a/app/Http/Controllers/ClientPortal/DocumentController.php b/app/Http/Controllers/ClientPortal/DocumentController.php index 1d6866d1e785..77181d3fe9a9 100644 --- a/app/Http/Controllers/ClientPortal/DocumentController.php +++ b/app/Http/Controllers/ClientPortal/DocumentController.php @@ -52,15 +52,19 @@ class DocumentController extends Controller Log::error($request->all()); - Storage::makeDirectory(public_path() . $contact->client->client_hash, 0755); + Storage::makeDirectory('public/' . $contact->client->client_hash, 0755); - $path = Storage::putFile($contact->client->client_hash, $request->file('file')); + $path = Storage::putFile('public/' . $contact->client->client_hash, $request->file('file')); $url = Storage::url($path); Log::error($path); Log::error($url); + tap((auth()->user())->update([ + 'avatar' => $url, + ])); + /* [2019-08-07 05:50:23] local.ERROR: array ( '_token' => '7KoEVRjB2Fq8XBVFRUFbhQFjKm4rY9h0AGSlpdj3', diff --git a/app/Http/Controllers/ClientPortal/ProfileController.php b/app/Http/Controllers/ClientPortal/ProfileController.php index b2ce5ad0f04c..aa13a6f2a9f2 100644 --- a/app/Http/Controllers/ClientPortal/ProfileController.php +++ b/app/Http/Controllers/ClientPortal/ProfileController.php @@ -37,6 +37,7 @@ class ProfileController extends Controller */ public function edit(ClientContact $client_contact) { + /* Dropzone configuration */ $data = [ 'params' => [ 'is_avatar' => TRUE, diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 030ddb4027a8..9e2516b7353f 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -36,13 +36,12 @@ class BaseModel extends Model ]; protected $dateFormat = 'Y-m-d H:i:s.u'; - + public function getHashedIdAttribute() { return $this->encodePrimaryKey($this->id); } - public function __call($method, $params) { $entity = strtolower(class_basename($this)); diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index a23ef5bd16cb..20731ca286ef 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -68,7 +68,7 @@ class ClientContact extends Authenticatable 'email', 'avatar', ]; - + /**/ public function getRouteKeyName() { @@ -80,6 +80,14 @@ class ClientContact extends Authenticatable return $this->encodePrimaryKey($this->id); } + public function setAvatarAttribute() + { + if(!filter_var($this->attributes['avatar'], FILTER_VALIDATE_URL)) + return url('/') . $this->attributes['avatar']; + else + return $this->attributes['avatar']; + } + public function client() { return $this->belongsTo(Client::class); diff --git a/resources/views/generic/dropzone.blade.php b/resources/views/generic/dropzone.blade.php index f67829438586..ddeda7c5ea6f 100644 --- a/resources/views/generic/dropzone.blade.php +++ b/resources/views/generic/dropzone.blade.php @@ -13,6 +13,10 @@ margin-left: auto; margin-right: auto; } + .dropzone .dz-preview .dz-image { + width: 250px; + height: 250px; + } @stop
@@ -37,6 +41,8 @@ '{!! $key !!}' : '{!! $value !!}', @endforeach }, + thumbnailWidth: 250, + thumbnailHeight: 250, addRemoveLinks: true, dictRemoveFileConfirmation: "{{ctrans('texts.are_you_sure')}}", dictDefaultMessage : "{{ctrans('texts.dropzone_default_message')}}", diff --git a/resources/views/portal/default/profile/index.blade.php b/resources/views/portal/default/profile/index.blade.php index 5deeb1d5b663..e13f941a3f2b 100644 --- a/resources/views/portal/default/profile/index.blade.php +++ b/resources/views/portal/default/profile/index.blade.php @@ -17,8 +17,6 @@
- - @include('generic.dropzone')