SAW Kk
SAW Kk

Reputation: 74

I am unable to view created page using routing and controller in Laravel

I am new Laravel, and this is my first project, I got this project which already has some pages and I have to add an admin login page, so I created adminlogin.blade.php file in the resource folder, and make controller using command

php artisan make:controller AdminController

then in AdminController, I have created a function

public function viewAdminLogin() {
    return "Hello From admin login controller";//not working
    return view('adminlogin');//this one also not working, i have tried both return statement one by one.
}

Then in routes/web.php, I added this code

    <?php
    use Illuminate\Support\Facades\Route;
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */

    Route::get('/pricing', 'CalculatorController@index');

    Route::post('/quote', 'CalculatorController@quote');

    Route::get('/', 'Controller@index');

    // pages view
    Route::get('/howitworks', 'Controller@howitworks');

    Route::get('/US-Domestic-Shipping-Services', 'Controller@USDomesticShippingServices');

    Route::get('/International-Shipping-Services', 'Controller@InternationalShippingServices');

    Route::get('/Ship-Packages', 'Controller@ShipPackages');

    Route::get('/Ship-Envelopes', 'Controller@ShipEnvelopes');

    Route::get('/Student-Shipping', 'Controller@StudentShipping');

    Route::get('/about', 'Controller@About');

    Route::get('/FAQs', 'Controller@FAQs');

    Route::get('/Prohibited-Items', 'Controller@ProhibitedItems');

    Route::get('/Track-Shipment', 'Controller@TrackShipment');

    Route::get('/contact', 'Controller@Contact']);

    Route::get('/adminlogin', 'AdminController@viewAdminLogin');

I have also run these series of command after importing this project:

composer install
php artisan key:generate
php artisan migrate
php artisan db:seed
php artisan serve

after running http://127.0.0.1:8000/adminlogin it is returning a 404 page, Please help Thank you for reading.

Upvotes: 1

Views: 93

Answers (2)

Hedayatullah Sarwary
Hedayatullah Sarwary

Reputation: 2834

Run the following clear commands:

//---Regenerates the list of all classes that need to be included in the project
composer dump-autoload;
//---Remove Routes Cache
php artisan route:clear;
//---Flush the application cache
php artisan cache:clear;
//---Remove the configuration cache file
php artisan config:cache;
php artisan config:clear;

And after that restart your server

php artisan serve

Upvotes: 1

STA
STA

Reputation: 34678

If your route has been cached, then you need to clear the cache data :

php artisan route:clear

If you want to cache it, then simply run :

php artisan route:cache

Here is the official documentation about route caching

Upvotes: 1

Related Questions