Monday, March 20, 2017

Laravel PHP deciding which button was clicked in the form of a view

I have form that opens on default localhost:8000 in laravel . In this form i have three buttons "create task" ,"delete task" and "update task" . I want to open a specific view on click of any of these button through my Task_controller.My form is opening "/decide" route and this route is opening the Task_controller for taking decision.

   <!DOCTYPE html>
   <html>
   <head>
   </head>
   <body>
   <h1>TASK</h1>
   <form action="/decide">
   <input type="submit" name="cbtn" value="create task">
   <input type="submit" name="ubtn" value="update task">
   <input type="submit" name="dbtn" value="delete task"> 
   </form>
   </body>
   </html>

My route file goes like this

     Route::get('/', function () {
           return view('task');
     });

     Route::get('/create_task', function () {
           return view('create_task');
     });

     Route::get('/decide', "Task_Controller@decide");

and my controller file goes like this

     <?php

     namespace App\Http\Controllers;

     use Illuminate\Http\Request;

     class Task_Controller extends Controller
     {
     //
     public function decide()
     {
          $input = Input::get('cbtn');
          if (isset($input))
          echo "create button";
     }
     }

Right now with this code "Class 'App\Http\Controllers\Input' not found" this error is occuring



via akshay

Advertisement