I am trying to create an API for my application so that I can share the endpoint and have one application as the main application with business logic, and the other can communicate with the open endpoint in order to use the function as services.
I get an error when I try to get to the endpoint.
Below is my route /api.php
<?php use App\PostModell; use App\Http\Resources\PostModellResource; use Illuminate\Http\Request; Route::middleware('auth:api')->get('/user', function (Request $request) { return $request->user(); }); Route::get( '/cars',function(){ return new PostModellResource(PostModell::all()); });
My resource class looks like
lass PostModellResource extends Resource { public function toArray($request) { return [ 'id'=>$this->id, 'title'=>$this->title, 'body'=>$this->body, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; }
Error
Sorry, the page you are looking for could not be found.
source share