Merge branch 'develop' into trunk

This commit is contained in:
Vincent BRIDIER 2025-12-19 08:52:57 +01:00
commit e7ca76950a
5 changed files with 31 additions and 13 deletions

View file

@ -25,8 +25,8 @@ REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_HOST=dev-mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

View file

@ -128,12 +128,12 @@ class ClaimController extends Controller
*/
public function edit(Claim $claim): \Illuminate\Contracts\View\View
{
$customerClaimModels = !is_null($claim->customer) ? Claim::query()
->whereNotNull('customer_id')
$customerClaimModels = !is_null($claim->customerInfos) ? Claim::query()
->where('hashcode', $claim->customerInfos->hashcode)
->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
->whereHas('customer', fn($q) => $q->whereKey($claim->customer->getKey()))
->whereNot('id', $claim->getKey())
->whereNot('status', ClaimStatus::treated)->paginate($this->jsonItemPerPagination) : collect();
->paginate($this->jsonItemPerPagination) : collect();
$brandModels = CollectionHelper::paginate(
Brand::getUserAssociatedBrands(),
$this->jsonItemPerPagination,
@ -147,7 +147,6 @@ class ClaimController extends Controller
ClaimMailTemplate::getAllModelsFromBrand($claim->brand->getKey()),
$this->jsonItemPerPagination,
);
$customerModel = CustomerInfo::query()->where('hashcode', $claim->hashcode)->first();
return view('bo.pages.claims.edit', [
'claimModel' => $claim->load(['brand', 'claimSubject']),
@ -156,7 +155,7 @@ class ClaimController extends Controller
'claimMessageModels' => $claimMessageModels,
'claimSubjectModels' => $claimSubjectModels,
'claimTemplateModels' => $claimTemplateModels,
'customerModel' => $customerModel,
'customerInfoModel' => $claim->customerInfos,
]);
}

View file

@ -170,6 +170,22 @@ class Claim extends Model implements IsExportable
// * METHODS
/**
* 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();
}
return null;
}
/**
* Convert the integer to base 36 and make uppercase.
*

View file

@ -16,7 +16,7 @@ return new class extends Migration
Schema::table('claims', function (Blueprint $table) {
$table->dropForeign('claims_customer_id_foreign');
$table->dropColumn('customer_id');
$table->string('hashcode')->nullable()->unique()->after('id');
$table->string('hashcode')->nullable()->comment('Claim associated Customer infos by Hashcode.')->after('id');
});
}

View file

@ -31,10 +31,10 @@
{{ trim(sprintf('%s %s', $claimModel->first_name, $claimModel->last_name)) }}
</h5>
<p class="text-muted mb-2">{{ e($claimModel->email) }}</p>
@if ($customerModel && auth()->user()->can('view', \App\Models\Customer::class))
@if ($customerInfoModel && auth()->user()->can('view', \App\Models\Customer::class))
<a href="{{ route('bo.customers.show', [
'customer' => $customerModel,
'brand' => $customerModel->brand,
'customer' => $customerInfoModel->customer_id,
'brand' => $customerInfoModel->brand,
]) }}" target="_blank" rel="noopener">
{{ __('Lien vers la fiche client') }}
<i class="fas fa-arrow-up-right-from-square ms-1"></i>
@ -47,7 +47,10 @@
@endif
</div>
<div class="col-12 col-lg-8 border-top border-lg-top-0 border-lg-start border-lg-3 border-lg-primary mt-2 pt-2 mt-lg-0 pt-lg-0">
<div class="claim-message-collapse" data-json='@json(['message' => $claimModel->message])'></div>
@php
$message = sprintf("%s : %s\n%s", __('Date et heure'), $claimModel->created_at->format("d/m/Y H:i:s"), $claimModel->message);
@endphp
<div class="claim-message-collapse" data-json='@json(["message" => $message])'></div>
@if ($claimModel->file)
<div class="d-flex flex-row justify-content-start align-items-center">
<p class="m-0 me-2">Fichier:</p>