feat: add private business intake review and reserved objects
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ExistingBusiness;
|
||||
use App\Models\ExistingBusinessObject;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -69,9 +70,12 @@ final class ExistingBusinessDrafts
|
||||
});
|
||||
}
|
||||
|
||||
private function snapshot(ExistingBusiness $business, User $actor, string $action, string $reason): void
|
||||
public function snapshot(ExistingBusiness $business, User $actor, string $action, string $reason): void
|
||||
{
|
||||
$snapshot = json_encode(['record' => $business->attributesToArray(), 'payload' => $business->payload], JSON_THROW_ON_ERROR);
|
||||
$snapshot = json_encode(['record' => $business->attributesToArray(), 'payload' => $business->payload,
|
||||
'objects' => ExistingBusinessObject::where('business_id', $business->id)->orderBy('id')->get()
|
||||
->map(fn ($object) => [...$object->attributesToArray(), 'payload' => $object->payload])->all(),
|
||||
], JSON_THROW_ON_ERROR);
|
||||
DB::table('existing_business_revisions')->insert(['id' => (string) Str::uuid(), 'business_id' => $business->id,
|
||||
'version_no' => $business->version_no, 'actor_id' => $actor->id, 'action' => $action,
|
||||
'reason' => Crypt::encryptString($reason), 'snapshot' => Crypt::encryptString($snapshot), 'sha256' => hash('sha256', $snapshot)]);
|
||||
|
||||
Reference in New Issue
Block a user