Create API Controller
php artisan make:controller BookController --resource --model=Book --api
Route Example
Route::apiResource('/books', 'api\BookApiController');
Simple Response
Create And Use Resource
php artisan make:resource UserCollection
--------------------------------------
public function toArray($request)
{
return [
...
'posts' => PostResource::collection($this->posts),
...
]
------------------------
return UserResource::collection(User::all());
Problem installing passport?
First try
composer require laravel/passport:7.5.1
If it doesn't work then,
composer require laravel/passport:7.5.1 --with-all-dependencies
How to install api login feature with passport
Comments
Post a Comment