for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Audit\Services;
use Carbon\Carbon;
use Illuminate\Support\Facades\Schema;
use Audit\Models\Audits;
class AuditsService
{
public function __construct(Audits $model)
$this->model = $model;
model
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
public function log($request)
$requestData = json_encode(
[
'referer' => $request->server('HTTP_REFERER', null),
'user_agent' => $request->server('HTTP_USER_AGENT', null),
'host' => $request->server('HTTP_HOST', null),
'remote_addr' => $request->server('REMOTE_ADDR', null),
'uri' => $request->server('REQUEST_URI', null),
'method' => $request->server('REQUEST_METHOD', null),
'query' => $request->server('QUERY_STRING', null),
'time' => $request->server('REQUEST_TIME', null),
]
);
$route = 'todo/Route';
$business = 0;
$user = 0;
/**
* @todo data faltando
*/
$requestData = md5($requestData);
if (Schema::hasTable('audits')) {
$this->model->create(
'route' => $route,
'business' => $business,
'user' => $user,
'data' => $requestData,
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: