обновлена главная страница агента
This commit is contained in:
parent
a663a7932b
commit
c01e47aff2
@ -28,18 +28,11 @@ public function bitrixable(): MorphTo
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
protected function getSender(BitrixId $bitrixId)
|
||||
{
|
||||
static::creating(function (BitrixId $bitrixId)
|
||||
{
|
||||
if ($bitrixId->bx_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
$object = false;
|
||||
$sender = new BitrixSender();
|
||||
switch ( $bitrixId->bitrixable_type )
|
||||
{
|
||||
$sender = false;
|
||||
switch ($bitrixId->bitrixable_type) {
|
||||
case Deal::class:
|
||||
$deal = Deal::findOrFail($bitrixId->bitrixable_id);
|
||||
$sender = new SendDeal($deal);
|
||||
@ -63,9 +56,17 @@ protected static function booted()
|
||||
$object = $company;
|
||||
break;
|
||||
}
|
||||
if ($sender)
|
||||
return $sender;
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
//$bitrixId->token = Hash::make(json_encode([$object]));
|
||||
static::creating(function (BitrixId $bitrixId) {
|
||||
if ($bitrixId->bx_id) {
|
||||
return;
|
||||
}
|
||||
$sender = $this->getSender($bitrixId);
|
||||
if ($sender) {
|
||||
$bitrixId->token = hash('sha256', $bitrixId->bx_id . $bitrixId->bitrixable_id . $bitrixId->bitrixable_type);
|
||||
$sender->setCallbackUrl(
|
||||
route('api.bx.action', [
|
||||
@ -73,8 +74,7 @@ protected static function booted()
|
||||
])
|
||||
);
|
||||
$result = $sender->send();
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$id = $sender->resultData['id'];
|
||||
$bitrixId->bx_id = $id;
|
||||
return;
|
||||
@ -83,14 +83,14 @@ protected static function booted()
|
||||
throw new \Exception('Error of bitrix identifier getter for ' . $bitrixId->bitrixable_type . ' with id ' . $bitrixId->bitrixable_id);
|
||||
});
|
||||
|
||||
static::created(function (BitrixId $bitrixId)
|
||||
{
|
||||
if (!$bitrixId->bx_id)
|
||||
{
|
||||
//Агентов и клиентов отправляю после создания,
|
||||
//т.к. на стороне битрикса нужна связка сущностей
|
||||
//по созданной сделке
|
||||
static::created(function (BitrixId $bitrixId) {
|
||||
if (!$bitrixId->bx_id) {
|
||||
return;
|
||||
}
|
||||
switch ( $bitrixId->bitrixable_type )
|
||||
{
|
||||
switch ($bitrixId->bitrixable_type) {
|
||||
case Deal::class:
|
||||
$deal = Deal::findOrFail($bitrixId->bitrixable_id);
|
||||
$agentAppender = new SendDealAgent($deal);
|
||||
@ -98,8 +98,7 @@ protected static function booted()
|
||||
break;
|
||||
case Client::class:
|
||||
$client = Client::findOrFail($bitrixId->bitrixable_id);
|
||||
if ($dealClient = DealClients::where('client_id', $client->id)->orderByDesc('id')->first())
|
||||
{
|
||||
if ($dealClient = DealClients::where('client_id', $client->id)->orderByDesc('id')->first()) {
|
||||
$clientAppender = new SendDealClient(Deal::find($dealClient->deal_id), $client);
|
||||
$result = $clientAppender->send();
|
||||
}
|
||||
|
||||
@ -66,7 +66,6 @@ public function send()
|
||||
$postdata = http_build_query(
|
||||
$this->data
|
||||
);
|
||||
//dd($this->data);
|
||||
$opts = array(
|
||||
'ssl' => array(
|
||||
'verify_peer' => true,
|
||||
|
||||
@ -78,6 +78,15 @@ public static function firstOrCreate($attributes = [], $values = [])
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*protected function save() {
|
||||
if ($bitrixId = $this->bitrixy())
|
||||
{
|
||||
$bitrixId = $bitrixId->bx_id;
|
||||
|
||||
}
|
||||
parent::save();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ class="btn list-group-item list-group-item-action p-3 bg-white rounded border bo
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-wrap col-12 col-lg-6">
|
||||
<div class="form-wrap__inner p-2 px-sm-4 py-sm-3 bg-primary border rounded-3 mx-auto" style="z-index:2000">
|
||||
<div class="form-wrap__inner p-2 px-sm-4 py-sm-3 bg-primary border rounded-3 mx-auto" style="">
|
||||
<div class="h4 pb-2 mb-2 fw-bold d-flex flex-column">
|
||||
<small>Добавить клиента</small>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user