Skip to content

Commit

Permalink
relation added.
Browse files Browse the repository at this point in the history
  • Loading branch information
halilcosdu committed Apr 30, 2024
1 parent bae66c3 commit b0e076b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ return [
```php
$log = LogWeaver::description('User logged in')
->logResource('event')
->content(['user_id' => 1, 'email' => 'test@example.com'])
->content(['email' => 'test@example.com'])
->level('info')
->relation(['user_id' => 1])
->toArray();
```

Expand Down
1 change: 1 addition & 0 deletions src/Facades/LogWeaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @method static \HalilCosdu\LogWeaver\LogWeaver content(array $content): static
* @method static \HalilCosdu\LogWeaver\LogWeaver disk(string $disk): static
* @method static \HalilCosdu\LogWeaver\LogWeaver directory(string $directory): static
* @method static \HalilCosdu\LogWeaver\LogWeaver relation(?array $relation): static
* @method static \HalilCosdu\LogWeaver\LogWeaver log(?string $path = null, bool $wait = false): array
* @method static \HalilCosdu\LogWeaver\LogWeaver download(string $path, $name = null, array $headers = []): StreamedResponse
* @method array toArray(): array
Expand Down
16 changes: 16 additions & 0 deletions src/LogWeaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class LogWeaver implements Arrayable, Jsonable

private string $directory = 'logs';

private ?array $relation = null;

public function getDescription(): string
{
return $this->description;
Expand All @@ -42,6 +44,18 @@ public function directory(string $directory): static
return $this;
}

public function relation(?array $relation): static
{
$this->relation = $relation;

return $this;
}

public function getRelation(): ?array
{
return $this->relation;
}

public function getLogResource(): string
{
return $this->logResource;
Expand Down Expand Up @@ -106,6 +120,7 @@ private function validateParameters(): void
'log_resource' => $this->getLogResource(),
'description' => $this->getDescription(),
'content' => $this->getContent(),
'relation' => $this->getRelation(),
];

$rules = [
Expand Down Expand Up @@ -138,6 +153,7 @@ private function getValidatedData(): array
'level' => $this->getLevel(),
'description' => $this->getDescription(),
'content' => $this->getContent(),
'relation' => $this->getRelation(),
];
}

Expand Down

0 comments on commit b0e076b

Please sign in to comment.