📕
Sprnva Docs
  • Introduction
  • What's New?
  • Installation
    • Requirements
    • Download Sprnva zip no composer required
    • Install Sprnva Using Composer
    • Setup Config
  • Deployment
  • File Structure
  • Database
    • Select
    • SelectLoop
    • Insert
    • Update
    • Delete
    • Query
    • Seeder
    • Paginate
    • With
    • andFilter
    • withCount
    • get
  • Query Builder
  • Migration
    • INSTANCES
      • NEW
      • RENAMETABLE
      • DROP
      • CHANGE
    • DUMPS
      • dump
      • dump prune
    • MAKE
    • MIGRATE
      • migrate
      • migrate fresh
    • ROLLBACK
  • Routing
    • with parameter
    • multiple parameters
    • with closure
    • group
    • controller grouping
  • Controllers
    • methods
  • Views
    • Passing Parameters
  • Validation
    • validate
      • validation type
  • Authentication
  • Alert Messages
  • Default Helpers
  • CSRF Protection
  • Email
  • Packages
    • Fortify
  • Themes and Templates
Powered by GitBook
On this page
  1. Routing

with closure

Sometimes we do not need a controller to display a view we just need to define a callable parameter in our routes.

Route::get('/home', function () {
    $pageTitle = "Home";
    return view('/home', compact('pageTitle'));
});

With this callable parameter we can do some logic in our routes or even query our database to fetch some data and then pass to our views.

We can also pass the route with a parameter and access it inside our callable parameter in our route.

Route::get('/profile/detail/{id}', function ($id) {
   echo $id;
});
Previousmultiple parametersNextgroup

Last updated 2 years ago