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