-
app/Jobs/LogAccountAudit.php
Open in GitHubuse Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use App\Services\Logs\LogAccountAction; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class LogAccountAudit implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public array $auditLog; public function __construct(array $auditLog) { $this->auditLog = $auditLog; } public function handle(): void { (new LogAccountAction)->execute([ 'company_id' => $this->auditLog['company_id'], 'author_id' => $this->auditLog['author_id'], 'author_name' => $this->auditLog['author_name'], 'audited_at' => $this->auditLog['audited_at'], 'action' => $this->auditLog['action'], 'objects' => $this->auditLog['objects'], ]); } }
-
app/Services/Company/Adminland/Company/JoinCompany.php
Open in GitHubuse App\Jobs\LogAccountAudit; use App\Services\BaseService; use App\Models\Company\Company; class JoinCompany extends BaseService { // public function execute(array $data): Company { $this->data = $data; $this->validate(); $this->findCompany(); $this->addUser(); $this->logAccountAudit(); return $this->company; } // private function logAccountAudit(): void { LogAccountAudit::dispatch([ 'company_id' => $this->company->id, 'action' => 'employee_joined_company', 'author_id' => $this->employee->id, 'author_name' => $this->employee->name, 'audited_at' => Carbon::now(), 'objects' => json_encode([ 'company_name' => $this->company->name, ]), ])->onQueue('low'); } } }