Now, we need to make some minor changes to our controllers in order to use the resource we just created. To avoid any mistakes, we will look at the code for all of our controllers:
- Edit the Bike controller by replacing the content in App/Http/Controllers/API/BikeController.php with the following code:
<?phpnamespace App\Http\Controllers\API;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use App\Bike;use Validator;use App\Http\Resources\BikesResource;class BikeController extends Controller{ /** * Protect update and delete methods, only for authenticated users. * * @return Unauthorized */ public function __construct() { $this->middleware('auth:api')->except(['index']); } /** * Display a listing ...