Skip to content

Commit

Permalink
Merge pull request #12 from danielme85/dev
Browse files Browse the repository at this point in the history
Make datetime object less strict
  • Loading branch information
danielme85 authored Oct 11, 2019
2 parents 17632d9 + b07495b commit bd9da3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.1",
"illuminate/support": ">=5.6"
},
"require-dev": {
Expand Down
15 changes: 3 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,16 @@
[![Codecov](https://img.shields.io/codecov/c/github/danielme85/laravel-log-to-db.svg?style=flat-square)](https://codecov.io/gh/danielme85/laravel-log-to-db)
[![CodeFactor](https://www.codefactor.io/repository/github/danielme85/laravel-log-to-db/badge)](https://www.codefactor.io/repository/github/danielme85/laravel-log-to-db)

Custom Laravel 6/5.6+ Log channel handler that can store log events to SQL or MongoDB databases.
Custom Laravel 6 and >=5.6 Log channel handler that can store log events to SQL or MongoDB databases.
Uses Laravel native logging functionality.

## Installation
For latest Laravel 6 Support
Use the composer require or add to composer.json.
```
require danielme85/laravel-log-to-db
```

For Laravel 5.6 -> 5.* Support you can either use the v1 branch or a v1 release, ex:
```
require danielme85/laravel-log-to-db:dev-v1
```
or
```
require danielme85/laravel-log-to-db "~1.1"
```

If you are going to be using SQL database server to store log events you would need to run the migrations first. The MongoDB driver does not require the migration.
If you are using SQL database server to store log events you would need to run the migrations first. The MongoDB driver does not require the migration.
```
php artisan migrate
```
Expand Down
16 changes: 8 additions & 8 deletions src/Models/LogToDbCreateObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace danielme85\LaravelLogToDB\Models;

use Monolog\DateTimeImmutable;

/**
* Trait LogToDbCreateObject
*
Expand All @@ -26,9 +24,9 @@ public function getContextAttribute($value)
* DateTime Accessor
*
* @param $value
* @return DateTimeImmutable
* @return object
*/
public function getDatetimeAttribute($value) : DateTimeImmutable
public function getDatetimeAttribute($value)
{
return unserialize($value);
}
Expand Down Expand Up @@ -110,9 +108,9 @@ public function setContextAttribute(array $value)
/**
* DateTime Mutator
*
* @param DateTimeImmutable $value
* @param object $value
*/
public function setDatetimeAttribute(DateTimeImmutable $value)
public function setDatetimeAttribute(object $value)
{
$this->attributes['datetime'] = serialize($value);
}
Expand All @@ -133,7 +131,8 @@ public function setExtraAttribute($value)
* @param $value
* @return string
*/
private function jsonEncodeIfNotEmpty($value) {
private function jsonEncodeIfNotEmpty($value)
{
if (!empty($value)) {
return json_encode($value);
}
Expand All @@ -148,7 +147,8 @@ private function jsonEncodeIfNotEmpty($value) {
* @param bool $arraymode
* @return mixed
*/
private function jsonDecodeIfNotEmpty($value, $arraymode = true) {
private function jsonDecodeIfNotEmpty($value, $arraymode = true)
{
if (!empty($value)) {
return json_decode($value, $arraymode);
}
Expand Down

0 comments on commit bd9da3a

Please sign in to comment.