Skip to content

Commit 3373d8c

Browse files
JamesFreemanhailwood
authored andcommitted
update docs
1 parent 7f14a98 commit 3373d8c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/credential-storage.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,32 @@ For the package to know which model you want to use, you will need to call the f
3131
use Webfox\Xero\Xero;
3232
use App\Models\User;
3333

34-
Xero::useModelStore(User::find(1));
34+
Xero::useModelStore(Settings::first());
3535
```
3636

37+
If you need to resolve a model depending on some application state such as the authenticated user, this should be added to [a custom middleware](https://laravel.com/docs/11.x/middleware#defining-middleware) instead of the app service provider, e.g.
38+
39+
<?php
40+
41+
namespace App\Http\Middleware;
42+
43+
use Closure;
44+
use Webfox\Xero\Xero;
45+
use Illuminate\Http\Request;
46+
47+
class ConfigureXeroMiddleware
48+
{
49+
public function handle(Request $request, Closure $next)
50+
{
51+
if ($request->user()) {
52+
Xero::useModelStore($request->user()->currentTeam);
53+
}
54+
55+
return $next($request);
56+
57+
}
58+
}
59+
3760
By default, the package will use the `xero_credentials` field, Should you need to rename this field, you can do so by calling:
3861

3962
```php

0 commit comments

Comments
 (0)