PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, December 29, 2021

[FIXED] How to make route in laravel using GET Page?

 December 29, 2021     laravel, php, routes     No comments   

Issue

Before using laravel, usually I route my page using code like this:

//index.php
$get_page=$_GET['page'];
if (empty($get_page) or $get_page=='dashboard')
{
   include ('content/dashboard.php');   
}elseif ($get_page=='schedule')
{
  include ('content/schedule.php');
}

else{
    include ('404/404.php');
}

Is there anyway that I can route my page like that but in Laravel? I prefer to use format : www.example.com/?page=schedule rather than www.example.com/schedule


Solution

Route::get('/', function (Request $request) {
    if($request->query('page')) {
        $page = $request->query('page');
        return view($page);
    }
});

Documentation: https://laravel.com/docs/8.x/routing



Answered By - amlxv
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing