Skip to content

Commit b84b0e3

Browse files
committed
* Less strict type check of dateTime object to support Laravel 5 and 6.
* Experiment with Travis and multiple Laravel framework testing.
1 parent f5a5ed7 commit b84b0e3

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

.travis.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
language: php
22
php:
3+
- 7.1
34
- 7.2
45
- 7.3
6+
env:
7+
- LARAVEL_VERSION=5.*
8+
- LARAVEL_VERSION=6.*
9+
10+
matrix:
11+
fast_finish: true
12+
exclude:
13+
- php: 7.1
14+
env: LARAVEL_VERSION=6.*
15+
- php: 7.3
16+
env: LARAVEL_VERSION=5.*
17+
518
services:
619
- mysql
720
- mongodb
821
before_script:
922
- pecl install mongodb
1023
- mysql -e 'CREATE DATABASE testing;'
11-
- composer self-update
12-
- composer install --no-interaction
24+
- travis_retry composer self-update
25+
- travis_retry composer install --no-interaction
26+
- if [ "$LARAVEL_VERSION" != "" ]; then composer require --dev "laravel/laravel:${LARAVEL_VERSION}" --no-update; fi;
27+
- composer update
1328
script:
1429
- vendor/bin/phpunit --coverage-clover=coverage.xml
1530
after_success:

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)