Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Docs issue #125

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion docs/credential-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,34 @@ For the package to know which model you want to use, you will need to call the f

```php
use Webfox\Xero\Xero;
use App\Models\Settings;

Xero::useModelStore(Settings::class);
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
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ return Application::configure(basePath: dirname(__DIR__))

#### Laravel 8-10

Use the `reportable` method in the `App\Exceptions\Handler` class:
Use the `renderable` method in the `App\Exceptions\Handler` class:

```php
public function register()
{
$this->reportable(function (OAuthException $e) {
$this->renderable(function (OAuthException $e) {
// Handle when the user clicks cancel on the Xero authorization screen
return redirect('/my/xero/connect/page')->with('errorMessage', $e->getMessage());
});
Expand Down
Loading