Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesFreeman authored Dec 6, 2024
1 parent 8dd91ee commit 03ecff0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion docs/credential-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,32 @@ For the package to know which model you want to use, you will need to call the f
use Webfox\Xero\Xero;
use App\Models\User;

Xero::useModelStore(User::find(1));
Xero::useModelStore(Settings::first());
```

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.

<?php
namespace App\Http\Middleware;
use Closure;
use Webfox\Xero\Xero;
use Illuminate\Http\Request;
class ConfigureXeroMiddleware
{
public function handle(Request $request, Closure $next)
{
if ($request->user()) {
Xero::useModelStore($request->user()->currentTeam);
}

return $next($request);

}
}

By default, the package will use the `xero_credentials` field, Should you need to rename this field, you can do so by calling:

```php
Expand Down

0 comments on commit 03ecff0

Please sign in to comment.