final test before deploy
This commit is contained in:
parent
58dfe912f7
commit
cec6a23397
|
|
@ -140,9 +140,9 @@ public function apply()
|
|||
public function upload(DocumentUploadRequest $request,$attachment_id)
|
||||
{
|
||||
|
||||
$attachment = BrokerAttachment::with(['broker_application','document'])->find($attachment_id);
|
||||
$broker_attachment = BrokerAttachment::with(['broker_application','broker_document'])->find($attachment_id);
|
||||
|
||||
if(!$attachment || !$attachment->broker_application || $attachment->broker_application->account_id != $this->account->id ){
|
||||
if(!$broker_attachment || !$broker_attachment->broker_application || $broker_attachment->broker_application->account_id != $this->account->id ){
|
||||
|
||||
return response()->json(['success' => false, 'message' =>'Bad request'],400);
|
||||
}
|
||||
|
|
@ -150,12 +150,12 @@ public function upload(DocumentUploadRequest $request,$attachment_id)
|
|||
$uploadedFile = $request->file('file');
|
||||
|
||||
|
||||
if($attachment->document->max_size != 0
|
||||
&& $uploadedFile->getSize() > $attachment->document->max_size * 1024){//max size in kilobytes
|
||||
if($broker_attachment->broker_document->max_size != 0
|
||||
&& $uploadedFile->getSize() > $broker_attachment->broker_document->max_size * 1024){//max size in kilobytes
|
||||
return response()->json(['success' => false, 'message' =>trans('app.application.upload_max_size')],422);
|
||||
}
|
||||
|
||||
$filename = Str::snake($attachment->name).'.'.$uploadedFile->getClientOriginalExtension();
|
||||
$filename = Str::snake($broker_attachment->name).'.'.$uploadedFile->getClientOriginalExtension();
|
||||
|
||||
$directory = 'broker-documents/'.Carbon::today()->year.'/'.$this->account->id;
|
||||
|
||||
|
|
@ -165,10 +165,10 @@ public function upload(DocumentUploadRequest $request,$attachment_id)
|
|||
return response()->json(['success' => false, 'message' =>trans('app.application.upload_failure')],400);
|
||||
}
|
||||
|
||||
$attachment->file = $directory.'/'.$filename;
|
||||
$attachment->size = number_format($uploadedFile->getSize()/1024, 2, '.', '');
|
||||
$attachment->type = $uploadedFile->getClientOriginalExtension();
|
||||
$attachment->save();
|
||||
$broker_attachment->file = $directory.'/'.$filename;
|
||||
$broker_attachment->size = number_format($uploadedFile->getSize()/1024, 2, '.', '');
|
||||
$broker_attachment->type = $uploadedFile->getClientOriginalExtension();
|
||||
$broker_attachment->save();
|
||||
|
||||
return response()->json(['success' => true, 'message' =>trans('app.app.application.upload_success')]);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ public function toArray($request)
|
|||
{
|
||||
return [
|
||||
'attachment_id' => $this->id,
|
||||
'attachment_name' => $this->document->name ?: $this->name,
|
||||
'attachment_name' => $this->broker_document->name ?: $this->name,
|
||||
'attachment_size' => $this->size,
|
||||
'attachment_file_type' => $this->type,
|
||||
'attachment_file_path' => is_null($this->file) ? null:Storage::url($this->file),
|
||||
'document_name' => $this->document->name,
|
||||
'document_description' => $this->document->description,
|
||||
'document_max_size' => $this->document->max_size,
|
||||
'is_required' => $this->document->is_required,
|
||||
'document_name' => $this->broker_document->name,
|
||||
'document_description' => $this->broker_document->description,
|
||||
'document_max_size' => $this->broker_document->max_size,
|
||||
'is_required' => $this->broker_document->is_required,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public function broker_application(){
|
|||
return $this->belongsTo(BrokerApplication::class, 'broker_application_id');
|
||||
}
|
||||
|
||||
public function document(){
|
||||
public function broker_document(){
|
||||
return $this->belongsTo(BrokerDocument::class, 'broker_document_id');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue