company confirmer fixed

This commit is contained in:
Thekindbull 2024-12-27 17:00:34 +08:00
parent c896647a35
commit 2f8444f4a4
5 changed files with 8 additions and 6 deletions

View File

@ -24,17 +24,17 @@ public function __invoke(Request $request)
$company = Company::create($data); $company = Company::create($data);
if (!$company) if (!$company)
{ {
return back()->with('error', __('Company creation error'))->withInput(); return back()->withErrors(['msg' => 'Company creation error'])->withInput();
} }
$data['callback_url'] = route('company.status.update', [ $data['callback_url'] = route('company.status.update', [
'company' => $company->id, 'company_id' => $company->id,
'secret' => $company->secret 'secret' => $company->secret
]); ]);
$companyConfirmByBitrix = new SendCompany($company->id, $data); $companyConfirmByBitrix = new SendCompany($company->id, $data);
if (!$sender = $companyConfirmByBitrix->send()) if (!$sender = $companyConfirmByBitrix->send())
{ {
$company->delete(); $company->delete();
return back()->with('error', __('Company creation error'))->withInput(); return back()->withErrors(['msg' => 'Company creation error'])->withInput();
} }
return view('company.created'); return view('company.created');
} }

View File

@ -30,7 +30,6 @@ public function send()
'content' => $postdata 'content' => $postdata
) )
); );
try try
{ {
$context = stream_context_create($opts); $context = stream_context_create($opts);

View File

@ -55,7 +55,7 @@ public function send()
$data = [ $data = [
'IBLOCK_TYPE_ID' => $this->IBLOCK_TYPE_ID, 'IBLOCK_TYPE_ID' => $this->IBLOCK_TYPE_ID,
'IBLOCK_ID' => $this->IBLOCK_ID, 'IBLOCK_ID' => $this->IBLOCK_ID,
'ELEMENT_CODE' => $this->ID, 'ELEMENT_CODE' => 'lk' . $this->ID,
'FIELDS' => $this->data 'FIELDS' => $this->data
]; ];
$sender = new BitrixSender($this->URL, $data); $sender = new BitrixSender($this->URL, $data);

View File

@ -9,7 +9,7 @@
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-md-8"> <div class="col-md-8">
<div class="card"> <div class="card">
<div class="card-header">{{ __('Create company form') }}</div> <div class="card-header">Форма регистрации агентства</div>
<div class="card-body"> <div class="card-body">
<form action="{{ route('company.create') }}" method="post"> <form action="{{ route('company.create') }}" method="post">
@csrf @csrf

View File

@ -37,6 +37,9 @@
<img src={{ url('/images/logo.png') }} alt="Alfa logo" width="70"> <img src={{ url('/images/logo.png') }} alt="Alfa logo" width="70">
</div> </div>
</div> </div>
@if ($errors->any())
{!! implode('', $errors->all('<div>:message</div>')) !!}
@endif
@yield('content') @yield('content')
</body> </body>