0

我在 laravel 4 中的 link_to_action 有问题

在 laravel 3 我会显示一个链接

{{ HTML::link_to_action('user/create', 'Create User') }}

但是由于我已经切换到 laravel 4,所以我正在创建像这个 UserController 这样的控制器但是当我尝试使用 HTML

{{ HTML::linkAction('user/create', 'Create User') }}

它给了我一个错误,即使有一个名为 create 的方法,操作也不存在。任何帮助将不胜感激。

这是我的控制器

<?php

class UserController extends \BaseController {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }
}
4

1 回答 1

3
// L3
{{ HTML::link_to_action('user@create', 'Create User') }}

// L4
{{ HTML::linkAction('UserController@create', 'Create User') }}

编辑:

// I think you missed that entry in your routes.php
Route::resource('user', 'UserController');
于 2013-06-01T19:23:51.303 回答