40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\Calls;
|
|
|
|
use Livewire\Component;
|
|
|
|
class SendMessageButton extends Component
|
|
{
|
|
public $callable;
|
|
public $call;
|
|
|
|
public function mount($callable, $call)
|
|
{
|
|
$this->callable = $callable;
|
|
$this->call = $call;
|
|
}
|
|
|
|
public function createConversation()
|
|
{
|
|
if (!$this->callable || $this->callable->isRemoved()) {
|
|
return;
|
|
}
|
|
|
|
$activeProfile = getActiveProfile();
|
|
$conversation = $activeProfile->createConversationWith($this->callable);
|
|
|
|
$locale = $activeProfile->lang_preference ?? app()->getLocale();
|
|
$firstName = explode(' ', trim($this->callable->name ?? ''))[0];
|
|
$callTitle = $this->call->tag?->translation?->name ?? $this->call->tag?->name ?? '';
|
|
$prefillMessage = __('Hello :name,', ['name' => $firstName], $locale) . "\n" . __('About your :title call, ', ['title' => $callTitle], $locale);
|
|
|
|
return redirect()->route('chat', ['conversation' => $conversation->id, 'prefill' => $prefillMessage]);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.calls.send-message-button');
|
|
}
|
|
}
|