Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
support injection and creates a singleton instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Kummer committed Jun 1, 2016
1 parent 2df52de commit 6d7283d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ For Google Analytics you should place the statement right behind the `body` tag

<body>{!! Analytics::render() !!}

### Dependency Injection (since 1.2.0)

You can inject the analytics provider by referencing the interface:

class PageController extends Controller
{
public function show(\Ipunkt\LaravelAnalytics\Contracts\AnalyticsProviderInterface $analytics)
{
$analytics->setUserId(md5(\Auth::user()->id)); // identical to Analytics::setUserId(md5(\Auth::user()->id));
return view('welcome');
}
}

## How to use

The `GoogleAnalytics` Provider automatically controls the local environment behaviour for testing purposes.
Expand Down

0 comments on commit 6d7283d

Please sign in to comment.