1
votes

I am new for laravel 5.3.Now i have created a form and when i submit my form it shows an error like

ReflectionException in Container.php line 749: Class App\Http\Controllers\registration does not exist

  1. in Container.php line 749
  2. at ReflectionClass->__construct('App\Http\Controllers\registration') in Container.php line 749
  3. at Container->build('App\Http\Controllers\registration', array()) in Container.php line 644
  4. at Container->make('App\Http\Controllers\registration', array()) in Application.php line 709
  5. at Application->make('App\Http\Controllers\registration') in Route.php line 203 at Route->getController() in Route.php line 316
  6. at Route->controllerMiddleware() in Route.php line 278
  7. at Route->gatherMiddleware() in Router.php line 655
  8. at Router->gatherRouteMiddleware(object(Route)) in Router.php line 635
  9. at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 618
  10. at Router->dispatchToRoute(object(Request)) in Router.php line 596
  11. at Router->dispatch(object(Request)) in Kernel.php line 268
  12. at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) in Pipeline.php line 53
  13. at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
  14. at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
  15. at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 33
  16. at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 104
  17. at Pipeline->then(object(Closure)) in Kernel.php line 150
  18. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
  19. at Kernel->handle(object(Request)) in index.php line 53
  20. at require_once('C:\xampp\htdocs\laravel_demo\public\index.php') in server.php line 21

I have a route like

Route::resource('registration','RegistrationController');
Route::post('store','registration@store');

Here my RegistrationController is renamed as registration

My RegistrationController:

<?php

namespace App\Http\Controllers;
use DB;
use Illuminate\Http\Request;
use App\RegistrationModel;
class RegistrationController extends Controller
{
  public  function index()
  {
     // $uers=DB::table('tset')->get();
      //return $uers;
       return view('pages.registration');
     // return view('pages.registration')->with('users',$uers);  //return users from db
  }

  public function store()
  {

  }
}

My view page:

{{Form::open(array('action' => 'registration@store', 'method' => 'post'))}}
<table>
    <tr>
        <td>
           Entr SNO:
        </td>
        <td>
         {!! Form::text('sno', null, ['class' => 'form-control']) !!}
        </td>
    </tr>
    <tr>
         <td>
          Enter Name:
        </td>
        <td>
         {!! Form::text('sname', null, ['class' => 'form-control']) !!}
        </td>
    </tr>
    <tr>
         <td>
          Enter Course:
        </td>
        <td>
         {!! Form::text('course', null, ['class' => 'form-control']) !!}
        </td>
    </tr>
    <tr>
         <td>
           Entr SNO:
        </td>
        <td>
       {{ Form::select('number', [1, 2, 3], null, ['class' => 'field']) }}
        </td>
    </tr>
        <tr>
            <td>
    {!! Form::submit('Submitform', ['class' => 'btn btn-primary']) !!}
            </td>
    </tr>
</table>
{!! Form::close() !!}

I don't know why i get this error when i click on save button for saving a post.Please help me

1

1 Answers

2
votes

You should add new methods to a resource controller by adding a route to that method separately before you register the resource.

So your route should be as: (Notice the sequence)

Route::post('store','RegistrationController@store');
Route::resource('registration','RegistrationController');

And your in your view it should be used as:

{{Form::open(array('action' => 'RegistrationController@store', 'method' => 'post'))}}

Note - Don't rename your RegistrationController

From the docs

If you need to add additional routes to a resource controller beyond the default set of resource routes, you should define those routes before your call to Route::resource; otherwise, the routes defined by the resource method may unintentionally take precedence over your supplemental routes.