0

RESTfull コントローラーと Laravel 3 ルーティングを理解しようとしています。私は restfull コントローラー記事を作成しましたが、次のメソッドを作成したいと考えています。

GET: index 
GET: write // (new but new is reserved)
GET: edit

POST: create
PUT: update

DELETE: destroy

New articleただし、開始する前に、リダイレクトする必要があるビューでリンクを押すとリダイレクトされ続け、articles/write代わりにクロムエラーで空白のページにリダイレクトされます: Chrome は localhost を見つけられません。

私のコントローラー:

<?php

class Articles_Controller extends Base_Controller {

  public $restful = true;

    public function get_index()
    {
        return View::make('articles.index', array('articles' => Article::all()));
    }

    public function get_write()
    {
        return View::make('articles.new');
    }

    public function post_create()
    {
        return 'Created';
    }

}

私のルート:

?php


Route::get('/', 'home@index');

// Articles
Route::controller('articles');

私の見解:

<h1>Todays articles:</h1>
<?php

    if(sizeof($articles) == 0)
    {
        echo 'No articles published';
    }
?>
<br /><br />
<?= HTML::Link('articles/write', 'New article') ?>
4

1 に答える 1

1

使ってみて

HTML::link_to_action('articles@write', 'New article');

application/config/app.phptohttp://localhostまたはhttp://127.0.0.1!でルート URL を設定します。

于 2013-05-29T07:56:51.353 に答える