0

I'm using Laravel 5 with Route Annotations. (The app\Http\route.php will be automaticaly deleted). For video about Route Annotations, you may have a look at https://www.youtube.com/watch?v=sOvgw40Dg4A

I build a ContactController.php with php artisan make:controller ContactController

And at store() function, I add return view('pages.contact'); to re-input another contact data.

When I give the script below on my pages\contact.blade.php :

{!! Form::open(['route'=>'contact.store']) !!}

It allways return error as below :

ErrorException in UrlGenerator.php line 237: Route [contact.store] not defined. (View: D:\www\mycontact\resources\views\pages\contact.blade.php)

which refer to :

public function route($name, $parameters = array(), $absolute = true)
{
  if ( ! is_null($route = $this->routes->getByName($name)))
  {
      return $this->toRoute($route, $parameters, $absolute);
  }

  throw new InvalidArgumentException("Route [{$name}] not defined.");
}

But when I change into :

{!! Form::open(['url'=>'contact']) !!}

it works normally.

How to fix my laravel so I can use the route ?

Below are the things that I have done :

composer require illuminate/html

At config\app.php , I add : 'Form' => 'Illuminate\Html\FormFacade' so I can use the {!! Form:: !!}

Then I execute the following command :

composer update
composer dump-autoload 
php artisan dump
php artisan clear-compiled
php artisan dump-autoload
php artisan optimize
php artisan route:clear
php artisan route:scan
php artisan route:list 

So... How to fix my laravel so in my blade, I can use {!! Form::open(['route'=>'contact.store']) !!} instead {!! Form::open(['url'=>'contact']) !!} ?

PS: I use XAMPP on Windows 7 Pro 64bit. And I already read : http://laravel.io/forum/10-11-2014-forms-doesnt-work-in-laravel-5

For my steps on Route Annotations, at App\Providers\RouteServiceProvider.php , I add my controllers with in

protected $scan = [
  'App\Http\Controllers\HomeController', // for http://localhost/myl5/
  'App\Http\Controllers\ContactController',  //  for http://localhost/myl5/contact
];
Galvion
  • 1,353
  • 7
  • 23
  • 35
  • Try `contact/store` instead of `contact.store`. Be sure to define the route to the ContactController in the routes folder – MiltoxBeyond Nov 14 '14 at 18:58
  • Did you set up the route in App/Http/routes.php? If not add the route and the method you want or you can do the `$router->Controller('/contact','ContactController');` Don't forget to name the methods if you do it this way to include the method of communication, i.e.: `postStore` or `getStore` – MiltoxBeyond Nov 14 '14 at 19:04
  • You need to show what routes you have defined in your `routes.php` file. – Marcin Nabiałek Nov 14 '14 at 19:07
  • I'm using route annotation. so there is no App/Http/routes.php – Galvion Nov 14 '14 at 19:27
  • for video about Route Annotation, you may look these video https://www.youtube.com/watch?v=sOvgw40Dg4A – Galvion Nov 14 '14 at 19:34
  • @SidhiCiang So show your route annotations – Marcin Nabiałek Nov 14 '14 at 20:01
  • Ok, I edited my question to describe how I make the Route Annotations in my L5. The route annotations work, so it does with my Controllers. Plus my route.php is being automatically deleted, because I'm using Route Annotations. :) – Galvion Nov 14 '14 at 20:53

0 Answers0