From 2a56bf4c67a43198ca3c65d3ab08236dbc4c28d2 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 31 Mar 2026 14:59:48 +0200 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=F0=9F=94=A5=20move=20claim=20custom?= =?UTF-8?q?er=20association=20into=20server=20side?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/V4/ClaimController.php | 13 ++++++++++++- app/Http/Requests/Api/V4/SendClaimRequest.php | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/V4/ClaimController.php b/app/Http/Controllers/Api/V4/ClaimController.php index f2e5fd2..08c2aa4 100644 --- a/app/Http/Controllers/Api/V4/ClaimController.php +++ b/app/Http/Controllers/Api/V4/ClaimController.php @@ -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()) { diff --git a/app/Http/Requests/Api/V4/SendClaimRequest.php b/app/Http/Requests/Api/V4/SendClaimRequest.php index a6c232f..145aab7 100644 --- a/app/Http/Requests/Api/V4/SendClaimRequest.php +++ b/app/Http/Requests/Api/V4/SendClaimRequest.php @@ -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', ]; } } From 1920acf6e634bc75d73b8d08abb21073be86c63c Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 31 Mar 2026 15:01:10 +0200 Subject: [PATCH 2/4] =?UTF-8?q?test:=20=E2=9C=85=20update=20and=20pass=20a?= =?UTF-8?q?ll=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/CRM/ApiV4/ClaimTest.php | 4 ++-- tests/Client/CrmClientClaimTest.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/CRM/ApiV4/ClaimTest.php b/tests/CRM/ApiV4/ClaimTest.php index d77a021..1ce23c1 100644 --- a/tests/CRM/ApiV4/ClaimTest.php +++ b/tests/CRM/ApiV4/ClaimTest.php @@ -4,6 +4,7 @@ namespace Tests\CRM\ApiV4; use App\Enums\ApiError; use App\Enums\ApiStatus; +use App\Lib\Helpers\FileHelper; use App\Models\Claim; use App\Models\ClaimSubject; use App\Models\Customer; @@ -55,7 +56,6 @@ class ClaimTest extends ApiBase [ 'brand_id' => $brand->getKey(), 'subject_id' => $subject->getKey(), - 'hashcode' => $customer->hashcode, ] )); $claimModel = Claim::query()->where([ @@ -72,7 +72,7 @@ class ClaimTest extends ApiBase $claimModel = Claim::query()->where('email', 'claim@hotmail.fr')->firstOrFail(); $this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.'); $this->assertTrue( - Storage::disk('public')->exists(str_replace('storage/', '', $claimModel->file)), + Storage::disk('private')->exists(FileHelper::getPrivateFilePath($claimModel->file)), "The file does not exist: {$claimModel->file}" ); } diff --git a/tests/Client/CrmClientClaimTest.php b/tests/Client/CrmClientClaimTest.php index 5dc0983..fb1d36e 100644 --- a/tests/Client/CrmClientClaimTest.php +++ b/tests/Client/CrmClientClaimTest.php @@ -2,6 +2,7 @@ namespace Tests\Client; +use App\Lib\Helpers\FileHelper; use App\Models\Claim as ModelsClaim; use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Storage; @@ -36,7 +37,7 @@ class CrmClientClaimTest extends CrmClientTester $claimModel = ModelsClaim::query()->where('email', 'claim@hotmail.fr')->firstOrFail(); $this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.'); $this->assertTrue( - Storage::disk('public')->exists(str_replace('storage/', '', $claimModel->file)), + Storage::disk('private')->exists(FileHelper::getPrivateFilePath($claimModel->file)), "The file does not exist: {$claimModel->file}" ); } From c4d45c25010f8f90848fec29503cbcf6da0e8bc9 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 31 Mar 2026 15:25:55 +0200 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=F0=9F=9A=A8=20resolve=20phpcs=20err?= =?UTF-8?q?ors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Bo/ClaimController.php | 6 ++++-- app/Mail/TransferredToDigitalCountMail.php | 3 +-- app/Models/Claim.php | 3 +-- app/Traits/Controllers/ExportDatas.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Bo/ClaimController.php b/app/Http/Controllers/Bo/ClaimController.php index a176e37..625fc01 100644 --- a/app/Http/Controllers/Bo/ClaimController.php +++ b/app/Http/Controllers/Bo/ClaimController.php @@ -20,7 +20,6 @@ use App\Models\Claim; use App\Models\ClaimMailTemplate; use App\Models\ClaimMessage; use App\Models\ClaimSubject; -use App\Models\CustomerInfo; use App\Traits\Controllers\ExportDatas; use App\Traits\Controllers\UpdateModelPublished; use Illuminate\Http\Request; @@ -111,7 +110,10 @@ class ClaimController extends Controller ) ->when( auth('backend')->user()->brands()->count() === 1, - fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', auth('backend')->user()->brands()->pluck('id'))) + fn($q) => $q->whereHas( + 'brand', + fn($q) => $q->where('id', auth('backend')->user()->brands()->pluck('id')) + ) ); $claimSubjectModels = $request->filled('brand') || (auth('backend')->user()->brands()->count() === 1) ? $claimSubjectModels->orderBy('label', 'ASC')->get() : diff --git a/app/Mail/TransferredToDigitalCountMail.php b/app/Mail/TransferredToDigitalCountMail.php index b2a12ec..0e97944 100644 --- a/app/Mail/TransferredToDigitalCountMail.php +++ b/app/Mail/TransferredToDigitalCountMail.php @@ -9,7 +9,7 @@ class TransferredToDigitalCountMail extends Mailable /** * Create a new message instance. * - * @param int $count + * @param integer $count * @return void */ public function __construct(private int $count) @@ -30,4 +30,3 @@ class TransferredToDigitalCountMail extends Mailable ->with('count', $this->count); } } - diff --git a/app/Models/Claim.php b/app/Models/Claim.php index 6532852..732d55a 100644 --- a/app/Models/Claim.php +++ b/app/Models/Claim.php @@ -172,14 +172,13 @@ class Claim extends Model implements IsExportable /** * Get CustomerInfos - * + * * If Customer Haschcode <> null * * @return CustomerInfo|null */ public function getCustomerInfosAttribute(): CustomerInfo|null { - //FIXME: Rename en customer_info_hashcode if (!is_null($this->hashcode)) { return CustomerInfo::query()->where('hashcode', $this->hashcode)->first(); } diff --git a/app/Traits/Controllers/ExportDatas.php b/app/Traits/Controllers/ExportDatas.php index 5b7d950..0f859aa 100644 --- a/app/Traits/Controllers/ExportDatas.php +++ b/app/Traits/Controllers/ExportDatas.php @@ -83,7 +83,7 @@ trait ExportDatas if (!file_exists($tempDir)) { Storage::disk('private')->makeDirectory('export', 0755, true); } - + $zipName = tempnam($tempDir, 'zip'); if (!$zip->open($zipName, ZipArchive::OVERWRITE)) { From b23a1ab79564462b6fcdc12087892aa9052609d3 Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 31 Mar 2026 15:26:15 +0200 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=F0=9F=94=96=20release=20v4.1.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client b/client index 0f95357..f098255 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit 0f95357f46faecdad638a88858c66f2ce41ab87a +Subproject commit f09825531bb86c5df3b4a443620534eeda3578b4 diff --git a/composer.json b/composer.json index f0ee68c..c18973f 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "ldc/ldccrm", - "version": "4.1.7", + "version": "4.1.8", "type": "project", "description": "LDC CRM", "license": "MIT",