mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
clean up
This commit is contained in:
parent
9823df51b3
commit
433a2a01d7
@ -49,21 +49,19 @@ class DocumentController extends Controller
|
||||
public function store(StoreDocumentRequest $request)
|
||||
{
|
||||
$contact = auth()->user();
|
||||
|
||||
Log::error($request->all());
|
||||
|
||||
Storage::makeDirectory('public/' . $contact->client->client_hash, 0755);
|
||||
|
||||
$path = Storage::putFile('public/' . $contact->client->client_hash, $request->file('file'));
|
||||
$url = Storage::url($path);
|
||||
$size = $request->file('file')->getSize();
|
||||
$type = $request->file('file')->getClientOriginalExtension();
|
||||
|
||||
$contact = auth()->user();
|
||||
$contact->avatar_size = $size;
|
||||
$contact->avatar_type = $type;
|
||||
$contact->avatar = $url;
|
||||
$contact->avatar_size = $request->file('file')->getSize();
|
||||
$contact->avatar_type = $request->file('file')->getClientOriginalExtension();
|
||||
$contact->avatar = Storage::url($path);
|
||||
$contact->save();
|
||||
|
||||
return response()->json($contact);
|
||||
|
||||
|
||||
/*
|
||||
[2019-08-07 05:50:23] local.ERROR: array (
|
||||
@ -80,9 +78,6 @@ class DocumentController extends Controller
|
||||
)),
|
||||
)
|
||||
*/
|
||||
|
||||
return response()->json($contact);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +117,6 @@ class DocumentController extends Controller
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy()
|
||||
@ -132,9 +126,7 @@ class DocumentController extends Controller
|
||||
$file = basename($contact->avatar);
|
||||
$image_path = 'public/' . $contact->client->client_hash . '/' . $file;
|
||||
|
||||
Log::error($image_path);
|
||||
Storage::delete($image_path);
|
||||
|
||||
|
||||
$contact->avatar = '';
|
||||
$contact->avatar_type = '';
|
||||
|
@ -24,11 +24,7 @@ class StoreDocumentRequest extends Request
|
||||
|
||||
public function authorize() : bool
|
||||
{
|
||||
if( request('is_avatar') )
|
||||
return request('is_avatar') == true;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules()
|
||||
@ -36,7 +32,8 @@ class StoreDocumentRequest extends Request
|
||||
//$this->sanitize();
|
||||
|
||||
return [
|
||||
'file' => 'required|max:10000|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx'
|
||||
// 'file' => 'required|max:10000|mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx'
|
||||
'file' => 'required|max:10000|mimes:png,svg,jpeg,gif,jpg,bmp'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -80,15 +80,7 @@
|
||||
//dropzone.on('canceled', handleDocumentCanceled);
|
||||
dropzone.on('error', handleDocumentError);
|
||||
|
||||
var mockFile = {
|
||||
name: contact.avatar,
|
||||
size: contact.avatar_size,
|
||||
type: contact.avatar_type,
|
||||
status: Dropzone.SUCCESS,
|
||||
accepted: true,
|
||||
url: contact.avatar,
|
||||
mock: true
|
||||
};
|
||||
var mockFile = makeMockFile();
|
||||
|
||||
if(contact.avatar) {
|
||||
dropzone.emit('addedfile', mockFile);
|
||||
@ -108,14 +100,30 @@
|
||||
|
||||
}
|
||||
|
||||
function makeMockFile()
|
||||
{
|
||||
var mockFile = {
|
||||
name: contact.avatar,
|
||||
size: contact.avatar_size,
|
||||
type: contact.avatar_type,
|
||||
status: Dropzone.SUCCESS,
|
||||
accepted: true,
|
||||
url: contact.avatar,
|
||||
mock: true
|
||||
};
|
||||
|
||||
return mockFile;
|
||||
}
|
||||
|
||||
function handleDocumentError(file, responseText) {
|
||||
dropzone.removeFile(file);
|
||||
// window.countUploadingDocuments--;
|
||||
for (var error in responseText.errors) {
|
||||
|
||||
dropzone.removeFile(file);
|
||||
|
||||
swal({title: '{{ctrans('texts.error')}}', text: responseText.errors[error]});
|
||||
for (var error in responseText.errors) {
|
||||
|
||||
}
|
||||
swal({title: '{{ctrans('texts.error')}}', text: responseText.errors[error]});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -137,15 +145,7 @@
|
||||
contact = response;
|
||||
dropzone.files = [];
|
||||
|
||||
var mockFile = {
|
||||
name: contact.avatar,
|
||||
size: contact.avatar_size,
|
||||
type: contact.avatar_type,
|
||||
status: Dropzone.SUCCESS,
|
||||
accepted: true,
|
||||
url: contact.avatar,
|
||||
mock: true
|
||||
};
|
||||
var mockFile = makeMockFile();
|
||||
|
||||
if(contact.avatar) {
|
||||
dropzone.emit('complete', mockFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user