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

Update laravel/index.md file #2036

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions laravel/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ final class BookProvider implements ProviderInterface
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
{
$book = BookModel::find($uriVariables['id']);
return new Book(id: $book->id, title: $book->title);
return new BookModel(id: $book->id, title: $book->title);
noweh marked this conversation as resolved.
Show resolved Hide resolved
}
}
```
Expand All @@ -242,6 +242,7 @@ Register the state provider:

namespace App\Providers;

use App\State\BookProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\ServiceProvider;

Expand All @@ -253,7 +254,7 @@ class ApiServiceProvider extends ServiceProvider
return new BookProvider();
});

$this->app->tag([BookProvider::class], ProviderInterface::class);
$this->app->tag([BookProvider::class], 'provider');
noweh marked this conversation as resolved.
Show resolved Hide resolved
}
}
```
Expand Down Expand Up @@ -624,6 +625,7 @@ API Platform provides an easy shortcut to some [useful filters](./filters.md), f
namespace App\Models;

use ApiPlatform\Metadata\ApiResource;
+use ApiPlatform\Metadata\QueryParameter;
+use ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter;
use Illuminate\Database\Eloquent\Model;

Expand All @@ -643,6 +645,7 @@ It's also possible to enable filters on every exposed property:
namespace App\Models;

use ApiPlatform\Metadata\ApiResource;
+use ApiPlatform\Metadata\QueryParameter;
+use ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter;
+use ApiPlatform\Laravel\Eloquent\Filter\OrderFilter;
use Illuminate\Database\Eloquent\Model;
Expand Down