добавлены трейты и таблицы для работы с plan7 и отправки в битрикс
This commit is contained in:
parent
d9366946c4
commit
d711d11760
@ -13,7 +13,7 @@ class SendDeal extends BitrixSender
|
|||||||
public function __construct(Deal $deal)
|
public function __construct(Deal $deal)
|
||||||
{
|
{
|
||||||
$this->addDataItem('complexName', $deal->complex->name);
|
$this->addDataItem('complexName', $deal->complex->name);
|
||||||
if ($plan7Data = $deal->getPlan7Data()) {
|
if ($plan7Data = $deal->plan7Data || $plan7Data = $deal->getPlan7Data()) {
|
||||||
$this->addDataItem('plan7', $plan7Data);
|
$this->addDataItem('plan7', $plan7Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ protected static function create(array $attributes = [])
|
|||||||
$model = new static();
|
$model = new static();
|
||||||
$model->fill($attributes);
|
$model->fill($attributes);
|
||||||
$model->save();
|
$model->save();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$model->setBitrixId();
|
$model->setBitrixId();
|
||||||
|
|||||||
@ -211,7 +211,14 @@ public function back()
|
|||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
|
$deal = new Deal();
|
||||||
|
$deal->complex_id = $this->complexId;
|
||||||
|
$deal->agent_id = $this->agentId;
|
||||||
|
if ($this->plan7Room) {
|
||||||
|
$deal->plan7Data = $this->plan7Room;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
|
|
||||||
!$deal = Deal::create([
|
!$deal = Deal::create([
|
||||||
'agent_id' => $this->agentId,
|
'agent_id' => $this->agentId,
|
||||||
'complex_id' => $this->complexId,
|
'complex_id' => $this->complexId,
|
||||||
@ -221,7 +228,7 @@ public function save()
|
|||||||
$this->status = FormStatus::ERROR;
|
$this->status = FormStatus::ERROR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->plan7Room) {
|
if ($this->plan7Room) {
|
||||||
$deal->setPlan7Data($this->plan7Room['id'], $this->plan7Room);
|
$deal->setPlan7Data($this->plan7Room['id'], $this->plan7Room);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,8 +10,10 @@
|
|||||||
use Modules\Plan7\Models\DealPlan7;
|
use Modules\Plan7\Models\DealPlan7;
|
||||||
trait Plan7Deal
|
trait Plan7Deal
|
||||||
{
|
{
|
||||||
|
public $plan7Data;
|
||||||
public function setPlan7Data($id, $data)
|
public function setPlan7Data($id, $data)
|
||||||
{
|
{
|
||||||
|
$this->plan7Data = $data;
|
||||||
return DealPlan7::updateOrCreate(['deal_id' => $this->id], [
|
return DealPlan7::updateOrCreate(['deal_id' => $this->id], [
|
||||||
'plan7_id' => $id,
|
'plan7_id' => $id,
|
||||||
'data' => json_encode($data)
|
'data' => json_encode($data)
|
||||||
@ -20,6 +22,7 @@ public function setPlan7Data($id, $data)
|
|||||||
public function getPlan7Data()
|
public function getPlan7Data()
|
||||||
{
|
{
|
||||||
if ($plan7 = DealPlan7::where('deal_id', $this->id)->first()) {
|
if ($plan7 = DealPlan7::where('deal_id', $this->id)->first()) {
|
||||||
|
$this->plan7Data = json_decode($plan7->data);
|
||||||
return $plan7->data;
|
return $plan7->data;
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user