Skip to content

Commit

Permalink
Stop using obsolete global helpers from Laravel
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Jul 24, 2020
1 parent 7baa200 commit bbab916
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions docs/extend/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ For the controller that shows a single resource, extend the `Flarum\Api\Controll

```php
use Flarum\Api\Controller\AbstractShowController;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;
use Tobscure\JsonApi\Document;

Expand All @@ -294,7 +295,7 @@ class ShowTagController extends AbstractShowController

protected function data(Request $request, Document $document)
{
$id = array_get($request->getQueryParams(), 'id');
$id = Arr::get($request->getQueryParams(), 'id');

return Tag::findOrFail($id);
}
Expand All @@ -307,6 +308,7 @@ For the controller that creates a resource, extend the `Flarum\Api\Controller\Ab

```php
use Flarum\Api\Controller\AbstractCreateController;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;
use Tobscure\JsonApi\Document;

Expand All @@ -316,10 +318,10 @@ class CreateTagController extends AbstractCreateController

protected function data(Request $request, Document $document)
{
$attributes = array_get($request->getParsedBody(), 'data.attributes');
$attributes = Arr::get($request->getParsedBody(), 'data.attributes');

return Tag::create([
'name' => array_get($attributes, 'name')
'name' => Arr::get($attributes, 'name')
]);
}
}
Expand All @@ -335,13 +337,14 @@ For the controller that deletes a resource, extend the `Flarum\Api\Controller\Ab

```php
use Flarum\Api\Controller\AbstractDeleteController;
use Illuminate\Support\Arr;
use Psr\Http\Message\ServerRequestInterface as Request;

class DeleteTagController extends AbstractDeleteController
{
protected function delete(Request $request)
{
$id = array_get($request->getQueryParams(), 'id');
$id = Arr::get($request->getQueryParams(), 'id');

Tag::findOrFail($id)->delete();
}
Expand Down
4 changes: 3 additions & 1 deletion docs/extend/routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ Sometimes you will need to capture segments of the URI within your route. You ma
The values of these parameters will be merged with the request's query params, which you can access in your controller by calling `$request->getQueryParams()`:

```php
$id = array_get($request->getQueryParams(), 'id');
use Illuminate\Support\Arr;

$id = Arr::get($request->getQueryParams(), 'id');
```

### Generating URLs
Expand Down

0 comments on commit bbab916

Please sign in to comment.