1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Working on dropzone uploads

This commit is contained in:
David Bomba 2019-08-08 10:22:54 +10:00
parent 3e91a4f700
commit fac762391a
6 changed files with 23 additions and 7 deletions

View File

@ -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',

View File

@ -37,6 +37,7 @@ class ProfileController extends Controller
*/
public function edit(ClientContact $client_contact)
{
/* Dropzone configuration */
$data = [
'params' => [
'is_avatar' => TRUE,

View File

@ -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));

View File

@ -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);

View File

@ -13,6 +13,10 @@
margin-left: auto;
margin-right: auto;
}
.dropzone .dz-preview .dz-image {
width: 250px;
height: 250px;
}
</style>
@stop
<div id="dropzone">
@ -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')}}",

View File

@ -17,8 +17,6 @@
<div class="card-body">
<i class="fa fa-user fa-5x"></i>
@include('generic.dropzone')
</div>