mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 10:54:34 -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)
|
public function store(StoreDocumentRequest $request)
|
||||||
{
|
{
|
||||||
$contact = auth()->user();
|
$contact = auth()->user();
|
||||||
|
|
||||||
Log::error($request->all());
|
|
||||||
|
|
||||||
Storage::makeDirectory('public/' . $contact->client->client_hash, 0755);
|
Storage::makeDirectory('public/' . $contact->client->client_hash, 0755);
|
||||||
|
|
||||||
$path = Storage::putFile('public/' . $contact->client->client_hash, $request->file('file'));
|
$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 = auth()->user();
|
||||||
$contact->avatar_size = $size;
|
$contact->avatar_size = $request->file('file')->getSize();
|
||||||
$contact->avatar_type = $type;
|
$contact->avatar_type = $request->file('file')->getClientOriginalExtension();
|
||||||
$contact->avatar = $url;
|
$contact->avatar = Storage::url($path);
|
||||||
$contact->save();
|
$contact->save();
|
||||||
|
|
||||||
|
return response()->json($contact);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
[2019-08-07 05:50:23] local.ERROR: array (
|
[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.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function destroy()
|
public function destroy()
|
||||||
@ -132,9 +126,7 @@ class DocumentController extends Controller
|
|||||||
$file = basename($contact->avatar);
|
$file = basename($contact->avatar);
|
||||||
$image_path = 'public/' . $contact->client->client_hash . '/' . $file;
|
$image_path = 'public/' . $contact->client->client_hash . '/' . $file;
|
||||||
|
|
||||||
Log::error($image_path);
|
|
||||||
Storage::delete($image_path);
|
Storage::delete($image_path);
|
||||||
|
|
||||||
|
|
||||||
$contact->avatar = '';
|
$contact->avatar = '';
|
||||||
$contact->avatar_type = '';
|
$contact->avatar_type = '';
|
||||||
|
@ -24,11 +24,7 @@ class StoreDocumentRequest extends Request
|
|||||||
|
|
||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
if( request('is_avatar') )
|
return true;
|
||||||
return request('is_avatar') == true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
@ -36,7 +32,8 @@ class StoreDocumentRequest extends Request
|
|||||||
//$this->sanitize();
|
//$this->sanitize();
|
||||||
|
|
||||||
return [
|
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('canceled', handleDocumentCanceled);
|
||||||
dropzone.on('error', handleDocumentError);
|
dropzone.on('error', handleDocumentError);
|
||||||
|
|
||||||
var mockFile = {
|
var mockFile = makeMockFile();
|
||||||
name: contact.avatar,
|
|
||||||
size: contact.avatar_size,
|
|
||||||
type: contact.avatar_type,
|
|
||||||
status: Dropzone.SUCCESS,
|
|
||||||
accepted: true,
|
|
||||||
url: contact.avatar,
|
|
||||||
mock: true
|
|
||||||
};
|
|
||||||
|
|
||||||
if(contact.avatar) {
|
if(contact.avatar) {
|
||||||
dropzone.emit('addedfile', mockFile);
|
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) {
|
function handleDocumentError(file, responseText) {
|
||||||
dropzone.removeFile(file);
|
|
||||||
// window.countUploadingDocuments--;
|
dropzone.removeFile(file);
|
||||||
for (var error in responseText.errors) {
|
|
||||||
|
|
||||||
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;
|
contact = response;
|
||||||
dropzone.files = [];
|
dropzone.files = [];
|
||||||
|
|
||||||
var mockFile = {
|
var mockFile = makeMockFile();
|
||||||
name: contact.avatar,
|
|
||||||
size: contact.avatar_size,
|
|
||||||
type: contact.avatar_type,
|
|
||||||
status: Dropzone.SUCCESS,
|
|
||||||
accepted: true,
|
|
||||||
url: contact.avatar,
|
|
||||||
mock: true
|
|
||||||
};
|
|
||||||
|
|
||||||
if(contact.avatar) {
|
if(contact.avatar) {
|
||||||
dropzone.emit('complete', mockFile);
|
dropzone.emit('complete', mockFile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user