hasMany(HarimHistory::class); } protected function primaryArea(): Attribute { return Attribute::make( get: fn($value) => json_decode($value) ); } /** * @throws Throwable */ public function updateStateWithHistory(int $action, string $description , array $data): void { DB::transaction(function () use ($action, $description, $data) { $this->histories()->create([ 'expert_id' => auth()->user()->id, 'previous_state_id' => $this->state_id, 'previous_state_name' => $this->state_name, 'expert_description' => $description, 'action_id' => $action, 'action_name' => \App\Enums\HarimAction::name($action), ]); $this->update($data); }); } public function panjarehVahedHistories(): HasMany { return $this->hasMany(PanjarehVahedHistory::class); } protected function data(): Attribute { return Attribute::make( set: function ($value) { $iv = config('harim_web_services.Harim_Info.iv'); $keyString = config('harim_web_services.Harim_Info.key'); $key = hash('sha256',$keyString, true); $decrypted = openssl_decrypt($value,'aes-256-cbc',$key,false, $iv); return json_decode($decrypted); }, ); } public function latestDescription() { return $this->hasMany(HarimHistory::class) ->latestOfMany() ->value('expert_description'); } protected function forbiddenArea(): Attribute { return Attribute::make( get: fn($value) => json_decode($value) ); } protected function finalArea(): Attribute { return Attribute::make( get: fn($value) => json_decode($value) ); } protected function finalPlan(): Attribute { return Attribute::make( get: fn($value) => json_decode($value) ); } }