Alexander Solonik
Alexander Solonik

Reputation: 10230

Getting a NotFoundHttpException() Error in laravel

I just have a very simple product category creation form in laravel , like so:

{{ Form::open(array('url'=>'admin/category/create')) }}
          <p>
            {{ Form::label('name') }}
            {{ Form::text('name') }}
          </p>
          {{ Form::submit('Create Category' , array('class'=>'secondary-cart-btn')) }}
          {{ Form::close() }}

For the create method i have the following code:

  public function postCreate() {

    $validator = Validator::make(Input::all() , Category::$rules);

    if($validator->passes()) {
      $category = new Category;
      $category->name = Input::get('name');
      $category->save();

      return Redirect::to('admin/categories/index')
         ->with('message' , 'Category created');
    }

    return Redirect::to('admin/categories/index')
      ->with('message' , 'something went wrong')
      ->withError($validator)
      ->withInput();

  }

Now when i click on the submit button, i get the following error:

C:\xampp\htdocs\ecomm\bootstrap\compiled.php

if (!is_null($route)) { return $route->bind($request); } $others = $this->checkForAlternateVerbs($request); if (count($others) > 0) { return $this->getOtherMethodsRoute($request, $others); } throw new NotFoundHttpException(); } protected function checkForAlternateVerbs($request)

You can see the error more visvually HERE.

What am i doing wrong ?

Upvotes: 0

Views: 640

Answers (1)

Grald
Grald

Reputation: 464

Instead of

{{ Form::open(array('url'=>'admin/category/create')) }}
      <p>
        {{ Form::label('name') }}
        {{ Form::text('name') }}
      </p>
      {{ Form::submit('Create Category' , array('class'=>'secondary-cart-btn')) }}
      {{ Form::close() }}

try this:

{{ Form::open(array('route'=>'post.homes')) }}
      <p>
        {{ Form::label('name') }}
        {{ Form::text('name') }}
      </p>
      {{ Form::submit('Create Category' , array('class'=>'secondary-cart-btn')) }}
      {{ Form::close() }}

In routes.php:

Route::post('aboutus', array('as' => 'post.homes', 'uses' => 'HomeController@postContactUs'));

Upvotes: 3

Related Questions