44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Partials;
|
|
|
|
use Livewire\Component;
|
|
use App\Models\UserCounselingRequests;
|
|
|
|
class Form extends Component
|
|
{
|
|
public $full_name;
|
|
public $phone_number;
|
|
public $description;
|
|
public $textSuccess = '';
|
|
|
|
public function counselingRequest()
|
|
{
|
|
if (is_null($this->full_name) && is_null($this->phone_number) && is_null($this->description)) {
|
|
return [
|
|
'status' => 'error',
|
|
'message' => 'اطلاعات را به صورت کامل تکمیل کنید.',
|
|
];
|
|
}
|
|
$phone = convertPersianToEnglishNumber($this->phone_number);
|
|
$phone = ltrim($phone, '0');
|
|
$phone = substr($phone, 0, 2) == '98' ? substr($phone, 2) : $phone;
|
|
$phone = str_replace('+98', '', $phone);
|
|
$phone = '0' . $phone;
|
|
|
|
UserCounselingRequests::create([
|
|
'full_name' => $this->full_name,
|
|
'phone_number' => $phone,
|
|
'counseling_text' => $this->description,
|
|
]);
|
|
|
|
$this->textSuccess = 'پیام شما با موفقیت دریافت شد.';
|
|
return $this->dispatch('ticket_ok');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.partials.form');
|
|
}
|
|
}
|