Merge branch 'develop' into trunk
This commit is contained in:
commit
01f3c8a319
10 changed files with 25 additions and 14 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()) {
|
||||
|
|
|
|||
|
|
@ -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() :
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
2
client
2
client
|
|
@ -1 +1 @@
|
|||
Subproject commit 0f95357f46faecdad638a88858c66f2ce41ab87a
|
||||
Subproject commit f09825531bb86c5df3b4a443620534eeda3578b4
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ldc/ldccrm",
|
||||
"version": "4.1.7",
|
||||
"version": "4.1.8",
|
||||
"type": "project",
|
||||
"description": "LDC CRM",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue