fix: 🔥 move claim customer association into server side
This commit is contained in:
parent
e170cf351e
commit
2a56bf4c67
2 changed files with 12 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ use App\Exceptions\Api\V4\CrmException;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\V4\SendClaimRequest;
|
||||
use App\Models\Claim;
|
||||
use App\Models\CustomerInfo;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Arr;
|
||||
use Uwil\LaravelCommon\Helpers\FileHelper;
|
||||
|
|
@ -24,7 +25,17 @@ class ClaimController extends Controller
|
|||
{
|
||||
$claimModel = (new Claim())->fill(Arr::except($request->validated(), 'file'));
|
||||
if ($request->filled('file')) {
|
||||
$claimModel->file = FileHelper::storeBase64File('claim', $request->file, private: true);
|
||||
$claimModel->file = FileHelper::storeBase64File(
|
||||
tableName: 'claim',
|
||||
fileBase64: $request->file,
|
||||
private: true,
|
||||
);
|
||||
}
|
||||
|
||||
// Add customer relation if exist.
|
||||
$crmCustomer = CustomerInfo::getFromEmail($claimModel->brand, $claimModel->email)->first();
|
||||
if (!is_null($crmCustomer)) {
|
||||
$claimModel->hashcode = $crmCustomer->hashcode;
|
||||
}
|
||||
|
||||
if (!$claimModel->saveOrFail()) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ class SendClaimRequest extends BaseApiRequest
|
|||
'message' => 'required|string|min:3',
|
||||
'brand_id' => 'required|integer|exists:brands,id',
|
||||
'subject_id' => 'required|integer|exists:claim_subjects,id',
|
||||
'hashcode' => 'sometimes|nullable|string|size:36',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue