33 lines
857 B
PHP
33 lines
857 B
PHP
<?php
|
|
|
|
namespace Modules\Plan7\Traits;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
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)
|
|
]);
|
|
}
|
|
public function getPlan7Data()
|
|
{
|
|
if ($plan7 = DealPlan7::where('deal_id', $this->id)->first()) {
|
|
$this->plan7Data = json_decode($plan7->data);
|
|
return $plan7->data;
|
|
}
|
|
return [];
|
|
}
|
|
}
|
|
|
|
|