Issues (5)

src/LaravelTracerServiceProvider.php (1 issue)

1
<?php
2
3
namespace ProtoneMedia\LaravelTracer;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\ServiceProvider;
7
8
class LaravelTracerServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        if ($this->app->runningInConsole()) {
16
            $this->publishes([
17
                __DIR__ . '/../config/config.php' => config_path('laravel-tracer.php'),
18
            ], 'config');
19
20
            if (!class_exists('CreateUserRequestsTable')) {
21
                $this->publishes([
22
                    __DIR__ . '/../database/migrations/create_user_requests_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_user_requests_table.php'),
23
                ], 'migrations');
24
            }
25
        }
26
    }
27
28
    /**
29
     * Register the application services.
30
     */
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'laravel-tracer');
34
35
        // setter for the qualified route
36
        Request::macro('qualifyAs', function (string $name, $secondsBetweenLogs = null) {
37
            $this->qualifiedRoute = new QualifiedRoute($this->route(), $name, $secondsBetweenLogs);
0 ignored issues
show
Bug Best Practice introduced by
The property qualifiedRoute does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
        });
39
40
        // getter for the qualified route
41
        Request::macro('qualifiedRoute', function (): QualifiedRoute {
42
            return $this->qualifiedRoute ?: QualifiedRoute::fromRequest($this);
43
        });
44
    }
45
}
46