Home > Back-end >  How I can create Routes in Laravel 8.x
How I can create Routes in Laravel 8.x

Time:02-14

I don't know if I'm so stupid or my laravel is broken, BUT, here it is.

That's my api.php:

Route::get('/airport', [\App\Http\Controllers\AirportsController::class, 'index']);
Route::post('/airports', [\App\Http\Controllers\AirportsController::class, 'create']);
Route::get('/registrator', [\App\Http\Controllers\RegistrationController::class, 'index']);

The airport and airports work great. It's add all data in db or get data from db. But registartor just don't work. It shows ERROR 404 and that's all.

RegistrationController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class RegistrationController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return 1;
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

It's just show ERROR 404 in anyway, not matter what request I do. I mean, I can rename airport in airportt and restart my server, but It still will show me ERROR 404, until I change airportt to airport

CodePudding user response:

All what I need to do is just clear route cache using artisan. Just enter a commang in cmd: php artisan route:clear

CodePudding user response:

You could do

php artisan optimize

in your command it will clear multiple things like

Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Files cached successfully!
  • Related