Skip to content

Commit bd9da3a

Browse files
authored
Merge pull request #12 from danielme85/dev
Make datetime object less strict
2 parents 17632d9 + b07495b commit bd9da3a

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=7.2",
14+
"php": ">=7.1",
1515
"illuminate/support": ">=5.6"
1616
},
1717
"require-dev": {

readme.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,16 @@
77
[![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)
88
[![CodeFactor](https://www.codefactor.io/repository/github/danielme85/laravel-log-to-db/badge)](https://www.codefactor.io/repository/github/danielme85/laravel-log-to-db)
99

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

1313
## Installation
14-
For latest Laravel 6 Support
14+
Use the composer require or add to composer.json.
1515
```
1616
require danielme85/laravel-log-to-db
1717
```
1818

19-
For Laravel 5.6 -> 5.* Support you can either use the v1 branch or a v1 release, ex:
20-
```
21-
require danielme85/laravel-log-to-db:dev-v1
22-
```
23-
or
24-
```
25-
require danielme85/laravel-log-to-db "~1.1"
26-
```
27-
28-
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.
19+
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.
2920
```
3021
php artisan migrate
3122
```

src/Models/LogToDbCreateObject.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace danielme85\LaravelLogToDB\Models;
44

5-
use Monolog\DateTimeImmutable;
6-
75
/**
86
* Trait LogToDbCreateObject
97
*
@@ -26,9 +24,9 @@ public function getContextAttribute($value)
2624
* DateTime Accessor
2725
*
2826
* @param $value
29-
* @return DateTimeImmutable
27+
* @return object
3028
*/
31-
public function getDatetimeAttribute($value) : DateTimeImmutable
29+
public function getDatetimeAttribute($value)
3230
{
3331
return unserialize($value);
3432
}
@@ -110,9 +108,9 @@ public function setContextAttribute(array $value)
110108
/**
111109
* DateTime Mutator
112110
*
113-
* @param DateTimeImmutable $value
111+
* @param object $value
114112
*/
115-
public function setDatetimeAttribute(DateTimeImmutable $value)
113+
public function setDatetimeAttribute(object $value)
116114
{
117115
$this->attributes['datetime'] = serialize($value);
118116
}
@@ -133,7 +131,8 @@ public function setExtraAttribute($value)
133131
* @param $value
134132
* @return string
135133
*/
136-
private function jsonEncodeIfNotEmpty($value) {
134+
private function jsonEncodeIfNotEmpty($value)
135+
{
137136
if (!empty($value)) {
138137
return json_encode($value);
139138
}
@@ -148,7 +147,8 @@ private function jsonEncodeIfNotEmpty($value) {
148147
* @param bool $arraymode
149148
* @return mixed
150149
*/
151-
private function jsonDecodeIfNotEmpty($value, $arraymode = true) {
150+
private function jsonDecodeIfNotEmpty($value, $arraymode = true)
151+
{
152152
if (!empty($value)) {
153153
return json_decode($value, $arraymode);
154154
}

0 commit comments

Comments
 (0)