link_to_route('pages.create') doesn't work in laravel 4.2

I have a problem within my routes. here is the error meesage "Route [pages.create] not defined". this my show.blade.php:

 {{ link_to_route('pages.create','page2')}} 

routes.php

 Route::resource('page', 'PagesController'); 

PagesController.php


class PagesController extends BaseController {

    public function index()
    {
        return View::make('pages.show');
    }

    public function create()
    {
        return "hai";
    }

    public function store()
    {
        //
    }

    public function show($id)
    {
        //
    }

    public function edit($id)
    {
        //
    }

    public function update($id)
    {
        //
    }

    public function destroy($id)
    {
        //
    }

}

Upvotes: 1

Views: 833

Answers (4)

just try to add the value in the after type method of your route and go to any method from the controller

  • index
  • edit
  • create
  • show
  • store
  • update
  • destroy

Upvotes: 0

Alireza Shirzad
Alireza Shirzad

Reputation: 16

When using the resource route method , route names are in this format:

'your_url.index',
'your_url.create',
'your_url.store',
'your_url.edit',
'your_url.update',
'your_url.destroy'

In your example you should replace 'pages' with 'page'

Upvotes: 0

Ross Edman
Ross Edman

Reputation: 823

It should be {{ route('page.create','page2')}}

When a resource generates routes it does not make them plural. So the routes available would be page.create, page.show, page.store, etc.

Also your PageController.php should be named KerjasamasController.php to be loaded properly and everything referencing PageController should be updated to KerjasamasController. I would read more about how PSR-4 autoloading works.

Upvotes: 1

Harsukh Makwana
Harsukh Makwana

Reputation: 4494

Please Try Here Laravel Function {{ HTML::linkRoute('pages.create', 'page2' }}

It Properly Work in laravel4.2

Upvotes: 1

Related Questions